Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-74224

[hp-application-automation-tools-plugin] Extract inline script block and event handlers in com/microfocus/application/automation/tools/octane/testrunner/TestsToRunConverterBuilder/config.jelly

XMLWordPrintable

      Problems

      == Inline Script Block
      Line: 103
      ----
      <script>
              function insertFormat(sender){
                  var index = sender.selectedIndex;
                  var options = sender.options;
      
                  var parent = getTableParent(sender);
                  var txtFormat = parent.querySelector(".custom-configuration-text");
      
                  if(options[index].value === 'basic'){
                      txtFormat.value = "{\n\t\"testPattern\": \"$package.$class#$testName\",\n\t\"testDelimiter\": \",\"\n}";
                  }
                  else if(options[index].value === 'extended'){
      
                      txtFormat.value = "{"+
                      "\n\t\"testPattern\": \"$package.$class#$testName\","+
                      "\n\t\"testDelimiter\": \",\","+
                      "\n\t\"prefix\": \"\","+
                      "\n\t\"suffix\": \"\","+
                      "\n\t\"replacements\": ["+
      
                      "\n\t\{"+
                      "\n\t\t\"type\": \"replaceString\","+
                      "\n\t\t\"target\": \"$package|$class|$testName\","+
                      "\n\t\t\"string\": \"aaa\","+
                      "\n\t\t\"replacement\": \"bbb\""+
                      "\n\t\}"+
      
                      "\n\t\{"+
                      "\n\t\t\"type\": \"replaceRegexFirst\","+
                      "\n\t\t\"target\": \"$package|$class|$testName\","+
                      "\n\t\t\"regex\": \"aaa\","+
                      "\n\t\t\"replacement\": \"bbb\""+
                      "\n\t\}"+
      
                      "\n\t\{"+
                      "\n\t\t\"type\": \"joinString\","+
                      "\n\t\t\"target\": \"$package|$class|$testName\","+
                      "\n\t\t\"prefix\": \"\","+
                      "\n\t\t\"suffix\": \"\""+
                      "\n\t\}"+
      
                      "\n\t]"+
                      "\n}";
                  }
                  sender.selectedIndex = 0;
              }
      
              function frameworkChanged(sender) {
                  var parent = getTableParent(sender);
                  var bCustom = sender.options[sender.selectedIndex].value === 'custom' ? true : false;
                  var parent = getTableParent(sender)
                  enableElements(bCustom,parent);
              }
      
              function enableElements(isCustom, parent){
      
                  var txtFormat = parent.querySelector(".custom-configuration-text");
                  if(txtFormat){
                      txtFormat.disabled = !isCustom;
                  }
      
                  var fillFormat = parent.querySelector(".custom-configuration-fill");
                  if(fillFormat){
                      if(isCustom){
                          fillFormat.classList.remove("hidden");
                      } else {
                          fillFormat.classList.add("hidden");
                      }
                  }
              }
      
              function getTableParent(element){
                  var myElement = element;
                  var counter = 0;
                  while(myElement.nodeName.toLowerCase()!=="table"){
                      myElement = myElement.parentElement;
                      counter++;
                      if(counter>=4){
                          break;
                      }
                  }
                  return myElement;
              }
          </script>
      ----
      
      == Inline Event Handler
      Line: 36
      ----
      <select name="teststorunconverter.framework" onchange="frameworkChanged(this)">
      ----
      
      == Inline Event Handler
      Line: 50
      ----
      <select class="custom-configuration-fill" onchange="insertFormat(this)">
      ----
      
      == Inline Event Handler
      Line: 60
      ----
      <select class="custom-configuration-fill hidden" onchange="insertFormat(this)">
      ----
      

      Solutions

      https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks
      https://www.jenkins.io/doc/developer/security/csp/#inline-event-handlers

            Unassigned Unassigned
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: