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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for OOP DeviceStorage</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | |
michael@0 | 10 | <script type="application/javascript;version=1.7"> |
michael@0 | 11 | "use strict"; |
michael@0 | 12 | |
michael@0 | 13 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 14 | |
michael@0 | 15 | function iframeScriptFirst() { |
michael@0 | 16 | content.wrappedJSObject.RunSet.reloadAndRunAll({ |
michael@0 | 17 | preventDefault: function() { }, |
michael@0 | 18 | __exposedProps__: { preventDefault: 'r' } |
michael@0 | 19 | }); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function iframeScriptSecond() { |
michael@0 | 23 | let TestRunner = content.wrappedJSObject.TestRunner; |
michael@0 | 24 | |
michael@0 | 25 | let oldComplete = TestRunner.onComplete; |
michael@0 | 26 | |
michael@0 | 27 | TestRunner.onComplete = function() { |
michael@0 | 28 | TestRunner.onComplete = oldComplete; |
michael@0 | 29 | |
michael@0 | 30 | sendAsyncMessage("test:DeviceStorage:ipcTestComplete", { |
michael@0 | 31 | result: JSON.stringify(TestRunner._failedTests) |
michael@0 | 32 | }); |
michael@0 | 33 | |
michael@0 | 34 | if (oldComplete) { |
michael@0 | 35 | oldComplete(); |
michael@0 | 36 | } |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | let oldLog = TestRunner.log; |
michael@0 | 40 | TestRunner.log = function(msg) { |
michael@0 | 41 | sendAsyncMessage("test:DeviceStorage:ipcTestMessage", { msg: msg }); |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | let regex = /^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL|TEST-DEBUG-INFO) \| ([^\|]+) \|(.*)/; |
michael@0 | 46 | |
michael@0 | 47 | function onTestMessage(data) { |
michael@0 | 48 | let message = SpecialPowers.wrap(data).json.msg; |
michael@0 | 49 | let match = regex.exec(message); |
michael@0 | 50 | if (match) { |
michael@0 | 51 | let state = match[1]; |
michael@0 | 52 | let details = match[2] + " | " + match[3]; |
michael@0 | 53 | |
michael@0 | 54 | switch (state) { |
michael@0 | 55 | case "TEST-PASS": |
michael@0 | 56 | case "TEST-KNOWN-FAIL": |
michael@0 | 57 | ok(true, details); |
michael@0 | 58 | break; |
michael@0 | 59 | |
michael@0 | 60 | case "TEST-UNEXPECTED-FAIL": |
michael@0 | 61 | case "TEST-UNEXPECTED-PASS": |
michael@0 | 62 | ok(false, details); |
michael@0 | 63 | break; |
michael@0 | 64 | |
michael@0 | 65 | case "TEST-DEBUG-INFO": |
michael@0 | 66 | default: |
michael@0 | 67 | info(details); |
michael@0 | 68 | } |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function onTestComplete() { |
michael@0 | 73 | let comp = SpecialPowers.wrap(SpecialPowers.Components); |
michael@0 | 74 | let mm = SpecialPowers.getBrowserFrameMessageManager(iframe); |
michael@0 | 75 | let spObserver = comp.classes["@mozilla.org/special-powers-observer;1"] |
michael@0 | 76 | .getService(comp.interfaces.nsIMessageListener); |
michael@0 | 77 | |
michael@0 | 78 | mm.removeMessageListener("SPPrefService", spObserver); |
michael@0 | 79 | mm.removeMessageListener("SPProcessCrashService", spObserver); |
michael@0 | 80 | mm.removeMessageListener("SPPingService", spObserver); |
michael@0 | 81 | mm.removeMessageListener("SpecialPowers.Quit", spObserver); |
michael@0 | 82 | mm.removeMessageListener("SPPermissionManager", spObserver); |
michael@0 | 83 | |
michael@0 | 84 | mm.removeMessageListener("test:DeviceStorage:ipcTestMessage", onTestMessage); |
michael@0 | 85 | mm.removeMessageListener("test:DeviceStorage:ipcTestComplete", onTestComplete); |
michael@0 | 86 | |
michael@0 | 87 | SimpleTest.executeSoon(function () { SimpleTest.finish(); }); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | function runTests() { |
michael@0 | 91 | let iframe = document.createElement("iframe"); |
michael@0 | 92 | SpecialPowers.wrap(iframe).mozbrowser = true; |
michael@0 | 93 | iframe.id = "iframe"; |
michael@0 | 94 | iframe.style.width = "100%"; |
michael@0 | 95 | iframe.style.height = "1000px"; |
michael@0 | 96 | |
michael@0 | 97 | function iframeLoadSecond() { |
michael@0 | 98 | ok(true, "Got second iframe load event."); |
michael@0 | 99 | iframe.removeEventListener("mozbrowserloadend", iframeLoadSecond); |
michael@0 | 100 | let mm = SpecialPowers.getBrowserFrameMessageManager(iframe); |
michael@0 | 101 | mm.loadFrameScript("data:,(" + iframeScriptSecond.toString() + ")();", |
michael@0 | 102 | false); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | function iframeLoadFirst() { |
michael@0 | 106 | ok(true, "Got first iframe load event."); |
michael@0 | 107 | iframe.removeEventListener("mozbrowserloadend", iframeLoadFirst); |
michael@0 | 108 | iframe.addEventListener("mozbrowserloadend", iframeLoadSecond); |
michael@0 | 109 | |
michael@0 | 110 | let mm = SpecialPowers.getBrowserFrameMessageManager(iframe); |
michael@0 | 111 | |
michael@0 | 112 | let comp = SpecialPowers.wrap(SpecialPowers.Components); |
michael@0 | 113 | |
michael@0 | 114 | let spObserver = |
michael@0 | 115 | comp.classes["@mozilla.org/special-powers-observer;1"] |
michael@0 | 116 | .getService(comp.interfaces.nsIMessageListener); |
michael@0 | 117 | |
michael@0 | 118 | mm.addMessageListener("SPPrefService", spObserver); |
michael@0 | 119 | mm.addMessageListener("SPProcessCrashService", spObserver); |
michael@0 | 120 | mm.addMessageListener("SPPingService", spObserver); |
michael@0 | 121 | mm.addMessageListener("SpecialPowers.Quit", spObserver); |
michael@0 | 122 | mm.addMessageListener("SPPermissionManager", spObserver); |
michael@0 | 123 | |
michael@0 | 124 | mm.addMessageListener("test:DeviceStorage:ipcTestMessage", onTestMessage); |
michael@0 | 125 | mm.addMessageListener("test:DeviceStorage:ipcTestComplete", onTestComplete); |
michael@0 | 126 | |
michael@0 | 127 | let specialPowersBase = "chrome://specialpowers/content/"; |
michael@0 | 128 | mm.loadFrameScript(specialPowersBase + "MozillaLogger.js", false); |
michael@0 | 129 | mm.loadFrameScript(specialPowersBase + "specialpowersAPI.js", false); |
michael@0 | 130 | mm.loadFrameScript(specialPowersBase + "specialpowers.js", false); |
michael@0 | 131 | |
michael@0 | 132 | mm.loadFrameScript("data:,(" + iframeScriptFirst.toString() + ")();", false); |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | iframe.addEventListener("mozbrowserloadend", iframeLoadFirst); |
michael@0 | 136 | |
michael@0 | 137 | // Strip this filename and one directory level and then add "/test". |
michael@0 | 138 | let href = window.location.href; |
michael@0 | 139 | href = href.substring(0, href.lastIndexOf('/')); |
michael@0 | 140 | href = href.substring(0, href.lastIndexOf('/')); |
michael@0 | 141 | iframe.src = href + "/test?consoleLevel=INFO"; |
michael@0 | 142 | |
michael@0 | 143 | document.body.appendChild(iframe); |
michael@0 | 144 | } |
michael@0 | 145 | |
michael@0 | 146 | addEventListener("load", function() { |
michael@0 | 147 | |
michael@0 | 148 | SpecialPowers.addPermission("browser", true, document); |
michael@0 | 149 | SpecialPowers.pushPrefEnv({ |
michael@0 | 150 | "set": [ |
michael@0 | 151 | |
michael@0 | 152 | ["device.storage.enabled", true], |
michael@0 | 153 | ["device.storage.testing", true], |
michael@0 | 154 | ["device.storage.prompt.testing", true], |
michael@0 | 155 | |
michael@0 | 156 | // TODO: remove this as part of bug 820712 |
michael@0 | 157 | ["network.disable.ipc.security", true], |
michael@0 | 158 | |
michael@0 | 159 | ["dom.ipc.browser_frames.oop_by_default", true], |
michael@0 | 160 | ["dom.mozBrowserFramesEnabled", true], |
michael@0 | 161 | ["browser.pagethumbnails.capturing_disabled", true] |
michael@0 | 162 | ] |
michael@0 | 163 | }, runTests); |
michael@0 | 164 | }); |
michael@0 | 165 | |
michael@0 | 166 | </script> |
michael@0 | 167 | </body> |
michael@0 | 168 | </html> |