dom/tests/mochitest/bugs/test_bug593174.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 type="text/javascript" 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>
    14 <script>
    16 SimpleTest.waitForExplicitFinish();
    18 var loadCount = 0;
    19 var popup = null;
    21 const kOriginalLocation = location.href;
    23 function iframeLoaded(identifier) {
    24   loadCount++;
    25   dump("iframeLoaded. loadCount=" + loadCount +
    26                     " identifier='" + identifier + "'\n");
    28   var iframe = document.getElementById('iframe');
    29   var iframeCw = iframe.contentWindow;
    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.
    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());
    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, document.location, 'outer iframe referrer');
    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.
    52     // We'll get a call to iframeLoaded when this finishes.
    53     iframeCw.navigateInnerIframe();
    54   }
    55   else if (loadCount == 3) {
    56     is(iframeCw.getInnerIframeReferrer(), iframeCw.location, 'inner iframe referrer');
    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());
    65     popup.onload = null;
    66     popup.location = 'file_bug593174_2.html';
    67   }
    68   else if (loadCount == 5) {
    69     is(popup.document.referrer, document.location, 'popup referrer after replaceState');
    70     popup.navigateInnerIframe();
    71   }
    72   else if (loadCount == 6) {
    73     is(popup.getInnerIframeReferrer(), popup.location, 'popup/inner iframe referrer');
    74     popup.close();
    75     history.replaceState('', '', kOriginalLocation);
    76     SimpleTest.finish();
    77   }
    78 }
    80 </script>
    82 <iframe onload='iframeLoaded("outer")' id='iframe' src='file_bug593174_1.html'></iframe>
    84 </body>
    85 </html>

mercurial