tor-browser

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

test_bug593174.html (2694B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=593174
      5 -->
      6 <head>
      7  <title>Test for Bug 593174</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=593174">Mozilla Bug 593174</a>
     13 
     14 <script>
     15 
     16 SimpleTest.waitForExplicitFinish();
     17 
     18 var loadCount = 0;
     19 var popup = null;
     20 
     21 const kOriginalLocation = location.href;
     22 
     23 function iframeLoaded(identifier) {
     24  loadCount++;
     25  dump("iframeLoaded. loadCount=" + loadCount +
     26                    " identifier='" + identifier + "'\n");
     27 
     28  var iframe = document.getElementById('iframe');
     29  var iframeCw = iframe.contentWindow;
     30 
     31  if (loadCount == 1) {
     32    // Test 1: Navigate iframe1.  This page should be the referer.
     33    // We'll get a callback from the inner page when its iframe finishes
     34    // loading, so get rid of the onload listener on our iframe.
     35 
     36    // Change this page's URI using replaceState; the referrer should be this
     37    // new value, not our original location.
     38    history.replaceState('', '', Math.random());
     39 
     40    iframe.onload = null;
     41    iframeCw.location = 'file_bug593174_2.html';
     42  }
     43  else if (loadCount == 2) {
     44    // Test 1: Check that this page is the referer.
     45    is(iframeCw.document.referrer, String(document.location), 'outer iframe referrer');
     46 
     47    // Test 2: file_bug593174_2.html itself contains an iframe, whose src is a
     48    // data: uri.  Call into that inner iframe and have it set its
     49    // document.location.  The new document's referrer should be
     50    // file_bug593174_2.html.
     51 
     52    // We'll get a call to iframeLoaded when this finishes.
     53    iframeCw.navigateInnerIframe();
     54  }
     55  else if (loadCount == 3) {
     56    is(iframeCw.getInnerIframeReferrer(), String(iframeCw.location), 'inner iframe referrer');
     57 
     58    // Now do the test again, this time with a popup.
     59    popup = window.open('file_bug593174_1.html');
     60    popup.onload = iframeLoaded('popup/outer');
     61  }
     62  else if (loadCount == 4) {
     63    history.replaceState('', '', Math.random());
     64 
     65    popup.onload = null;
     66    popup.location = 'file_bug593174_2.html';
     67  }
     68  else if (loadCount == 5) {
     69    is(popup.document.referrer, String(document.location), 'popup referrer after replaceState');
     70    popup.navigateInnerIframe();
     71  }
     72  else if (loadCount == 6) {
     73    is(popup.getInnerIframeReferrer(), String(popup.location), 'popup/inner iframe referrer');
     74    popup.close();
     75    history.replaceState('', '', kOriginalLocation);
     76    SimpleTest.finish();
     77  }
     78 }
     79 
     80 </script>
     81 
     82 <iframe onload='iframeLoaded("outer")' id='iframe' src='file_bug593174_1.html'></iframe>
     83 
     84 </body>
     85 </html>