dom/tests/mochitest/bugs/test_bug593174.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/bugs/test_bug593174.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=593174
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 593174</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=593174">Mozilla Bug 593174</a>
    1.16 +
    1.17 +<script>
    1.18 +
    1.19 +SimpleTest.waitForExplicitFinish();
    1.20 +
    1.21 +var loadCount = 0;
    1.22 +var popup = null;
    1.23 +
    1.24 +const kOriginalLocation = location.href;
    1.25 +
    1.26 +function iframeLoaded(identifier) {
    1.27 +  loadCount++;
    1.28 +  dump("iframeLoaded. loadCount=" + loadCount +
    1.29 +                    " identifier='" + identifier + "'\n");
    1.30 +
    1.31 +  var iframe = document.getElementById('iframe');
    1.32 +  var iframeCw = iframe.contentWindow;
    1.33 +
    1.34 +  if (loadCount == 1) {
    1.35 +    // Test 1: Navigate iframe1.  This page should be the referer.
    1.36 +    // We'll get a callback from the inner page when its iframe finishes
    1.37 +    // loading, so get rid of the onload listener on our iframe.
    1.38 +
    1.39 +    // Change this page's URI using replaceState; the referrer should be this
    1.40 +    // new value, not our original location.
    1.41 +    history.replaceState('', '', Math.random());
    1.42 +
    1.43 +    iframe.onload = null;
    1.44 +    iframeCw.location = 'file_bug593174_2.html';
    1.45 +  }
    1.46 +  else if (loadCount == 2) {
    1.47 +    // Test 1: Check that this page is the referer.
    1.48 +    is(iframeCw.document.referrer, document.location, 'outer iframe referrer');
    1.49 +
    1.50 +    // Test 2: file_bug593174_2.html itself contains an iframe, whose src is a
    1.51 +    // data: uri.  Call into that inner iframe and have it set its
    1.52 +    // document.location.  The new document's referrer should be
    1.53 +    // file_bug593174_2.html.
    1.54 +
    1.55 +    // We'll get a call to iframeLoaded when this finishes.
    1.56 +    iframeCw.navigateInnerIframe();
    1.57 +  }
    1.58 +  else if (loadCount == 3) {
    1.59 +    is(iframeCw.getInnerIframeReferrer(), iframeCw.location, 'inner iframe referrer');
    1.60 +
    1.61 +    // Now do the test again, this time with a popup.
    1.62 +    popup = window.open('file_bug593174_1.html');
    1.63 +    popup.onload = iframeLoaded('popup/outer');
    1.64 +  }
    1.65 +  else if (loadCount == 4) {
    1.66 +    history.replaceState('', '', Math.random());
    1.67 +
    1.68 +    popup.onload = null;
    1.69 +    popup.location = 'file_bug593174_2.html';
    1.70 +  }
    1.71 +  else if (loadCount == 5) {
    1.72 +    is(popup.document.referrer, document.location, 'popup referrer after replaceState');
    1.73 +    popup.navigateInnerIframe();
    1.74 +  }
    1.75 +  else if (loadCount == 6) {
    1.76 +    is(popup.getInnerIframeReferrer(), popup.location, 'popup/inner iframe referrer');
    1.77 +    popup.close();
    1.78 +    history.replaceState('', '', kOriginalLocation);
    1.79 +    SimpleTest.finish();
    1.80 +  }
    1.81 +}
    1.82 +
    1.83 +</script>
    1.84 +
    1.85 +<iframe onload='iframeLoaded("outer")' id='iframe' src='file_bug593174_1.html'></iframe>
    1.86 +
    1.87 +</body>
    1.88 +</html>

mercurial