Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | <!-- |
michael@0 | 2 | Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | --> |
michael@0 | 5 | <!DOCTYPE HTML> |
michael@0 | 6 | <html> |
michael@0 | 7 | <head> |
michael@0 | 8 | <meta charset="utf-8"> |
michael@0 | 9 | <title>Test for DOM Worker Threads</title> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"></div> |
michael@0 | 16 | <pre id="test"> |
michael@0 | 17 | <iframe id="workerFrame" src="suspend_iframe.html" onload="subframeLoaded();"> |
michael@0 | 18 | </iframe> |
michael@0 | 19 | <script class="testbody" type="text/javascript"> |
michael@0 | 20 | |
michael@0 | 21 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 22 | |
michael@0 | 23 | var iframe; |
michael@0 | 24 | var lastCount; |
michael@0 | 25 | |
michael@0 | 26 | var suspended = false; |
michael@0 | 27 | var resumed = false; |
michael@0 | 28 | var finished = false; |
michael@0 | 29 | |
michael@0 | 30 | var interval; |
michael@0 | 31 | var oldMessageCount; |
michael@0 | 32 | var waitCount = 0; |
michael@0 | 33 | |
michael@0 | 34 | function setCachePref(enabled) { |
michael@0 | 35 | var prefBranch = SpecialPowers.Cc["@mozilla.org/preferences-service;1"] |
michael@0 | 36 | .getService(SpecialPowers.Ci.nsIPrefBranch); |
michael@0 | 37 | if (enabled) { |
michael@0 | 38 | prefBranch.setBoolPref("browser.sessionhistory.cache_subframes", true); |
michael@0 | 39 | } |
michael@0 | 40 | else { |
michael@0 | 41 | try { |
michael@0 | 42 | prefBranch.clearUserPref("browser.sessionhistory.cache_subframes"); |
michael@0 | 43 | } catch (e) { /* Pref didn't exist, meh */ } |
michael@0 | 44 | } |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function finishTest() { |
michael@0 | 48 | if (finished) { |
michael@0 | 49 | return; |
michael@0 | 50 | } |
michael@0 | 51 | finished = true; |
michael@0 | 52 | setCachePref(false); |
michael@0 | 53 | iframe.terminateWorker(); |
michael@0 | 54 | SimpleTest.finish(); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function waitInterval() { |
michael@0 | 58 | if (finished) { |
michael@0 | 59 | return; |
michael@0 | 60 | } |
michael@0 | 61 | is(iframe.location, "about:blank", "Wrong url!"); |
michael@0 | 62 | is(suspended, true, "Not suspended?"); |
michael@0 | 63 | is(resumed, false, "Already resumed?!"); |
michael@0 | 64 | is(lastCount, oldMessageCount, "Received a message while suspended!"); |
michael@0 | 65 | if (++waitCount == 5) { |
michael@0 | 66 | clearInterval(interval); |
michael@0 | 67 | resumed = true; |
michael@0 | 68 | iframe.history.back(); |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function badOnloadCallback() { |
michael@0 | 73 | if (finished) { |
michael@0 | 74 | return; |
michael@0 | 75 | } |
michael@0 | 76 | ok(false, "We don't want suspend_iframe.html to fire a new load event, we want it to come out of the bfcache!"); |
michael@0 | 77 | finishTest(); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | function suspendCallback() { |
michael@0 | 81 | if (finished) { |
michael@0 | 82 | return; |
michael@0 | 83 | } |
michael@0 | 84 | is(iframe.location, "about:blank", "Wrong url!"); |
michael@0 | 85 | is(suspended, false, "Already suspended?"); |
michael@0 | 86 | is(resumed, false, "Already resumed?"); |
michael@0 | 87 | setCachePref(false); |
michael@0 | 88 | suspended = true; |
michael@0 | 89 | var iframeElement = document.getElementById("workerFrame"); |
michael@0 | 90 | iframeElement.onload = badOnloadCallback; |
michael@0 | 91 | oldMessageCount = lastCount; |
michael@0 | 92 | interval = setInterval(waitInterval, 1000); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | function messageCallback(data) { |
michael@0 | 96 | if (finished) { |
michael@0 | 97 | return; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | if (!suspended) { |
michael@0 | 101 | ok(lastCount === undefined || lastCount == data - 1, |
michael@0 | 102 | "Got good data, lastCount = " + lastCount + ", data = " + data); |
michael@0 | 103 | lastCount = data; |
michael@0 | 104 | if (lastCount == 25) { |
michael@0 | 105 | setCachePref(true); |
michael@0 | 106 | iframe.location = "about:blank"; |
michael@0 | 107 | // We want suspend_iframe.html to go into bfcache, so we need to flush |
michael@0 | 108 | // out all pending notifications. Otherwise, if they're flushed too |
michael@0 | 109 | // late, they could kick us out of the bfcache again. |
michael@0 | 110 | iframe.document.body.offsetTop; |
michael@0 | 111 | } |
michael@0 | 112 | return; |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | var newLocation = |
michael@0 | 116 | window.location.toString().replace("test_suspend.html", |
michael@0 | 117 | "suspend_iframe.html"); |
michael@0 | 118 | is(newLocation.indexOf(iframe.location.toString()), 0, "Wrong url!"); |
michael@0 | 119 | is(resumed, true, "Got message before resumed!"); |
michael@0 | 120 | is(lastCount, data - 1, "Missed a message, suspend failed!"); |
michael@0 | 121 | finishTest(); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | function errorCallback(data) { |
michael@0 | 125 | if (finished) { |
michael@0 | 126 | return; |
michael@0 | 127 | } |
michael@0 | 128 | ok(false, "Iframe had an error: '" + data + "'"); |
michael@0 | 129 | finishTest(); |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | function subframeLoaded() { |
michael@0 | 133 | if (finished) { |
michael@0 | 134 | return; |
michael@0 | 135 | } |
michael@0 | 136 | var iframeElement = document.getElementById("workerFrame"); |
michael@0 | 137 | iframeElement.onload = suspendCallback; |
michael@0 | 138 | |
michael@0 | 139 | iframe = iframeElement.contentWindow; |
michael@0 | 140 | ok(iframe, "No iframe?!"); |
michael@0 | 141 | |
michael@0 | 142 | iframe.startWorker(messageCallback, errorCallback); |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | </script> |
michael@0 | 146 | </pre> |
michael@0 | 147 | </body> |
michael@0 | 148 | </html> |