tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug704320-1.html (2965B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=704320
      5 This Test is split into two for Bug 1453396
      6 -->
      7 <head>
      8  <meta charset="utf-8">
      9  <title>Test for Bug 704320-Part1</title>
     10  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     11  <script type="application/javascript" src="referrerHelper.js"></script>
     12  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     13 
     14 <script type="application/javascript">
     15 
     16 //generates URLs to test
     17 var generateURLArray = (function(from, to){
     18  const baseURL = '://example.com/tests/dom/base/test/bug704320.sjs?action=create-1st-level-iframe&scheme-from=';
     19  const schemeTo = '&scheme-to=';
     20 
     21  return [
     22    from + baseURL + from + schemeTo + to + '&policy=no-referrer-when-downgrade',
     23    from + baseURL + from + schemeTo + to + '&policy=no-referrer',
     24    from + baseURL + from + schemeTo + to + '&policy=unsafe-url',
     25    from + baseURL + from + schemeTo + to + '&policy=origin',
     26    from + baseURL + from + schemeTo + to + '&policy=origin-when-cross-origin',
     27    from + baseURL + from + schemeTo + to + '&policy=same-origin',
     28    from + baseURL + from + schemeTo + to + '&policy=strict-origin',
     29    from + baseURL + from + schemeTo + to + '&policy=strict-origin-when-cross-origin',
     30  ];
     31 });
     32 
     33 let testIframeUrls = [generateURLArray('http', 'http'),
     34                      generateURLArray('https', 'https')];
     35 
     36 SimpleTest.waitForExplicitFinish();
     37 let advance = function(testName) {
     38  testsGenerator[testName].next();
     39 };
     40 
     41 let testNames = ['testframeone', 'testframetwo'];
     42 let isTestFinished = 0;
     43 
     44 function checkTestsCompleted() {
     45  isTestFinished++;
     46  if (isTestFinished == 2) {
     47    SimpleTest.finish();
     48  }
     49 }
     50 let testsGenerator = {};
     51 SimpleTest.requestLongerTimeout(4);
     52 /**
     53 * This is the main test routine -- serialized by use of a generator.
     54 * It performs all tests in sequence using four iframes.
     55 */
     56 function startTests(testName, iframeUrls) {
     57  testsGenerator[testName] = (function*() {
     58    var testframe = document.getElementById(testName);
     59    testframe.onload = function() {
     60      advance(testName);
     61    }
     62 
     63    // load the test frame from iframeUrls[url]
     64    // it will call back into this function via postMessage when it finishes
     65    // loading and continue beyond the yield.
     66    for(url in iframeUrls) {
     67      yield testframe.src = iframeUrls[url];
     68      // run test and check result for loaded test URL
     69      yield checkExpectedGlobalResults(testName);
     70    }
     71    checkTestsCompleted();
     72  })();
     73 }
     74 
     75 for (i = 0; i < testIframeUrls.length; i++) {
     76  startTests(testNames[i], testIframeUrls[i]);
     77 }
     78 
     79 </script>
     80 </head>
     81 
     82 <body onload="testsGenerator[testNames[0]].next();
     83              testsGenerator[testNames[1]].next();">
     84 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=704320">Mozilla Bug 704320 - HTTP/HTTPS to HTTPS/HTTP</a>
     85 <p id="display"></p>
     86 <pre id="content">
     87 </pre>
     88  <iframe id="testframeone"></iframe>
     89  <iframe id="testframetwo"></iframe>
     90 </body>