dom/tests/mochitest/bugs/test_bug593174.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial