tor-browser

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

test_bug704320-2.html (3257B)


      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-Part2</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 // We do not want HTTPS upgrades to interfere with this test. For that,
     17 // see dom/security/test/referrer-policy/test_referrer_redirect.html.
     18 SpecialPowers.pushPrefEnv({
     19  set: [
     20    ["dom.security.https_first", false],
     21    ["security.mixed_content.upgrade_display_content", false]
     22  ],
     23 });
     24 
     25 //generates URLs to test
     26 var generateURLArray = (function(from, to){
     27  const baseURL = '://example.com/tests/dom/base/test/bug704320.sjs?action=create-1st-level-iframe&scheme-from=';
     28  const schemeTo = '&scheme-to=';
     29 
     30  return [
     31    from + baseURL + from + schemeTo + to + '&policy=no-referrer-when-downgrade',
     32    from + baseURL + from + schemeTo + to + '&policy=no-referrer',
     33    from + baseURL + from + schemeTo + to + '&policy=unsafe-url',
     34    from + baseURL + from + schemeTo + to + '&policy=origin',
     35    from + baseURL + from + schemeTo + to + '&policy=origin-when-cross-origin',
     36    from + baseURL + from + schemeTo + to + '&policy=same-origin',
     37    from + baseURL + from + schemeTo + to + '&policy=strict-origin',
     38    from + baseURL + from + schemeTo + to + '&policy=strict-origin-when-cross-origin',
     39  ];
     40 });
     41 
     42 let testIframeUrls = [generateURLArray('http', 'https'),
     43                      generateURLArray('https', 'http')];
     44 
     45 SimpleTest.waitForExplicitFinish();
     46 let advance = function(testName) {
     47  testsGenerator[testName].next();
     48 };
     49 
     50 let testNames = ['testframeone', 'testframetwo'];
     51 let isTestFinished = 0;
     52 
     53 function checkTestsCompleted() {
     54  isTestFinished++;
     55  if (isTestFinished == 2) {
     56    SimpleTest.finish();
     57  }
     58 }
     59 let testsGenerator = {};
     60 SimpleTest.requestLongerTimeout(4);
     61 /**
     62 * This is the main test routine -- serialized by use of a generator.
     63 * It performs all tests in sequence using four iframes.
     64 */
     65 function startTests(testName, iframeUrls) {
     66  testsGenerator[testName] = (function*() {
     67    var testframe = document.getElementById(testName);
     68    testframe.onload = function() {
     69      advance(testName);
     70    }
     71 
     72    // load the test frame from iframeUrls[url]
     73    // it will call back into this function via postMessage when it finishes
     74    // loading and continue beyond the yield.
     75    for(url in iframeUrls) {
     76      yield testframe.src = iframeUrls[url];
     77      // run test and check result for loaded test URL
     78      yield checkExpectedGlobalResults(testName);
     79    }
     80    checkTestsCompleted();
     81  })();
     82 }
     83 
     84 for (i = 0; i < testIframeUrls.length; i++) {
     85  startTests(testNames[i], testIframeUrls[i]);
     86 }
     87 
     88 </script>
     89 </head>
     90 
     91 <body onload="testsGenerator[testNames[0]].next();
     92              testsGenerator[testNames[1]].next();">
     93 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=704320">Mozilla Bug 704320 - HTTP/HTTPS to HTTPS/HTTP</a>
     94 <p id="display"></p>
     95 <pre id="content">
     96 </pre>
     97  <iframe id="testframeone"></iframe>
     98  <iframe id="testframetwo"></iframe>
     99 </body>