Bug 1424023 - Test run time reduced using another new iframe. r=ckerschb
authorVinothkumar Nagasayanan <vnagasayanan@mozilla.com>
Tue, 10 Apr 2018 17:43:16 -0400
changeset 412748 a6edd350b230916c11bcfbb5d68676b461bba28a
parent 412747 01b340d03aeb0fe825b80d6cf1ac0f85b9197e14
child 412749 1c1e0d112e260b3213d81c429f25f99b34716eef
push id33818
push userapavel@mozilla.com
push dateWed, 11 Apr 2018 14:36:40 +0000
treeherdermozilla-central@cfe6399e142c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1424023
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1424023 - Test run time reduced using another new iframe. r=ckerschb
dom/base/test/referrerHelper.js
dom/base/test/test_bug704320.html
--- a/dom/base/test/referrerHelper.js
+++ b/dom/base/test/referrerHelper.js
@@ -72,33 +72,33 @@ function checkIndividualResults(testname
           ok(false, "Can't get results from the counter server.");
           SimpleTest.finish();
         });
 }
 
 /**
  * Grabs the results via XHR and checks them
  */
-function checkExpectedGlobalResults() {
+function checkExpectedGlobalResults(testName) {
   var url = 'bug704320.sjs?action=get-test-results';
   doXHR(url,
 	function(xhr) {
 	      var response = JSON.parse(xhr.response);
 
 	      for (type in response) {
 		for (scheme in response[type]) {
 		  for (policy in response[type][scheme]) {
 		    var expectedResult = EXPECTED_RESULTS[type] === undefined ?
 		      	EXPECTED_RESULTS['default'][scheme][policy] :
 		      	EXPECTED_RESULTS[type][scheme][policy];
 		    is(response[type][scheme][policy], expectedResult, type + ' ' + scheme + ' ' + policy);
 		  }
 		}
 	      }
-		advance();
+		advance(testName);
 	},
 	function(xhr) {
           	ok(false, "Can't get results from the counter server.");
 		SimpleTest.finish();
 	});
 }
 
 
--- a/dom/base/test/test_bug704320.html
+++ b/dom/base/test/test_bug704320.html
@@ -24,51 +24,73 @@ var generateURLArray = (function(from, t
     from + baseURL + from + schemeTo + to + '&policy=origin',
     from + baseURL + from + schemeTo + to + '&policy=origin-when-cross-origin',
     from + baseURL + from + schemeTo + to + '&policy=same-origin',
     from + baseURL + from + schemeTo + to + '&policy=strict-origin',
     from + baseURL + from + schemeTo + to + '&policy=strict-origin-when-cross-origin',
   ];
 });
 
-var testIframeUrls = generateURLArray('http', 'http');
-testIframeUrls = testIframeUrls.concat(generateURLArray('https', 'https'));
-testIframeUrls = testIframeUrls.concat(generateURLArray('http', 'https'));
-testIframeUrls = testIframeUrls.concat(generateURLArray('https', 'http'));
+let testIframeUrls = [generateURLArray('http', 'http'),
+                      generateURLArray('https', 'https'),
+                      generateURLArray('http', 'https'),
+                      generateURLArray('https', 'http')];
 
 SimpleTest.waitForExplicitFinish();
-var advance = function() { tests.next(); };
+let advance = function(testName) {
+  testsGenerator[testName].next();
+};
+
+let testNames = ['testframeone', 'testframetwo', 'testframethree',
+                 'testframefour'];
+let isTestFinished = 0;
 
+function checkTestsCompleted() {
+  isTestFinished++;
+  if (isTestFinished == 4) {
+    SimpleTest.finish();
+  }
+}
+let testsGenerator = {};
+SimpleTest.requestLongerTimeout(4);
 /**
  * This is the main test routine -- serialized by use of a generator.
- * It performs all tests in sequence using in the same iframe.
+ * It performs all tests in sequence using four iframes.
  */
-var tests = (function*() {
-  SimpleTest.requestLongerTimeout(4);
-  var iframe = document.getElementById("testframe");
-  iframe.onload = function() {
-     advance();
-  }
+function startTests(testName, testIframeUrls) {
+  testsGenerator[testName] = (function*() {
+    var testframe = document.getElementById(testName);
+    testframe.onload = function() {
+      advance(testName);
+    }
 
-  // load the test frame from testIframeUrls[url]
-  // it will call back into this function via postMessage when it finishes loading.
-  // and continue beyond the yield.
-  for(url in testIframeUrls) {
-    yield iframe.src = testIframeUrls[url];
-    // run test and check result for loaded test URL
-    yield checkExpectedGlobalResults();
-  }
+    // load the test frame from testIframeUrls[url]
+    // it will call back into this function via postMessage when it finishes
+    // loading and continue beyond the yield.
+    for(url in testIframeUrls) {
+      yield testframe.src = testIframeUrls[url];
+      // run test and check result for loaded test URL
+      yield checkExpectedGlobalResults(testName);
+    }
+    checkTestsCompleted();
+  })();
+}
 
-  // complete.
-  SimpleTest.finish();
-})();
+for (i = 0; i < testIframeUrls.length; i++) {
+  startTests(testNames[i], testIframeUrls[i]);
+}
 
 </script>
 </head>
 
-<body onload="tests.next();">
+<body onload="testsGenerator[testNames[0]].next();
+              testsGenerator[testNames[1]].next();
+              testsGenerator[testNames[2]].next();
+              testsGenerator[testNames[3]].next();">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=704320">Mozilla Bug 704320 - HTTP/HTTPS to HTTPS/HTTP</a>
 <p id="display"></p>
 <pre id="content">
 </pre>
-  <iframe id="testframe"></iframe>
-
+  <iframe id="testframeone"></iframe>
+  <iframe id="testframetwo"></iframe>
+  <iframe id="testframethree"></iframe>
+  <iframe id="testframefour"></iframe>
 </body>