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 lang="en"> |
michael@0 | 3 | <head> |
michael@0 | 4 | <meta charset="utf8"> |
michael@0 | 5 | <title>Test for the Console API</title> |
michael@0 | 6 | <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <script type="text/javascript;version=1.8" src="common.js"></script> |
michael@0 | 8 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 9 | - http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <p>Test for the Console API</p> |
michael@0 | 13 | |
michael@0 | 14 | <script class="testbody" type="text/javascript;version=1.8"> |
michael@0 | 15 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 16 | |
michael@0 | 17 | let expectedConsoleCalls = []; |
michael@0 | 18 | |
michael@0 | 19 | function doConsoleCalls(aState) |
michael@0 | 20 | { |
michael@0 | 21 | let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 2)).join("a"); |
michael@0 | 22 | |
michael@0 | 23 | top.console.log("foobarBaz-log", undefined); |
michael@0 | 24 | top.console.info("foobarBaz-info", null); |
michael@0 | 25 | top.console.warn("foobarBaz-warn", top.document.documentElement); |
michael@0 | 26 | top.console.debug(null); |
michael@0 | 27 | top.console.trace(); |
michael@0 | 28 | top.console.dir(top.document, top.location); |
michael@0 | 29 | top.console.log("foo", longString); |
michael@0 | 30 | |
michael@0 | 31 | expectedConsoleCalls = [ |
michael@0 | 32 | { |
michael@0 | 33 | level: "log", |
michael@0 | 34 | filename: /test_consoleapi/, |
michael@0 | 35 | functionName: "doConsoleCalls", |
michael@0 | 36 | timeStamp: /^\d+$/, |
michael@0 | 37 | arguments: ["foobarBaz-log", { type: "undefined" }], |
michael@0 | 38 | }, |
michael@0 | 39 | { |
michael@0 | 40 | level: "info", |
michael@0 | 41 | filename: /test_consoleapi/, |
michael@0 | 42 | functionName: "doConsoleCalls", |
michael@0 | 43 | timeStamp: /^\d+$/, |
michael@0 | 44 | arguments: ["foobarBaz-info", { type: "null" }], |
michael@0 | 45 | }, |
michael@0 | 46 | { |
michael@0 | 47 | level: "warn", |
michael@0 | 48 | filename: /test_consoleapi/, |
michael@0 | 49 | functionName: "doConsoleCalls", |
michael@0 | 50 | timeStamp: /^\d+$/, |
michael@0 | 51 | arguments: ["foobarBaz-warn", { type: "object", actor: /[a-z]/ }], |
michael@0 | 52 | }, |
michael@0 | 53 | { |
michael@0 | 54 | level: "debug", |
michael@0 | 55 | filename: /test_consoleapi/, |
michael@0 | 56 | functionName: "doConsoleCalls", |
michael@0 | 57 | timeStamp: /^\d+$/, |
michael@0 | 58 | arguments: [{ type: "null" }], |
michael@0 | 59 | }, |
michael@0 | 60 | { |
michael@0 | 61 | level: "trace", |
michael@0 | 62 | filename: /test_consoleapi/, |
michael@0 | 63 | functionName: "doConsoleCalls", |
michael@0 | 64 | timeStamp: /^\d+$/, |
michael@0 | 65 | stacktrace: [ |
michael@0 | 66 | { |
michael@0 | 67 | filename: /test_consoleapi/, |
michael@0 | 68 | functionName: "doConsoleCalls", |
michael@0 | 69 | }, |
michael@0 | 70 | { |
michael@0 | 71 | filename: /test_consoleapi/, |
michael@0 | 72 | functionName: "onAttach", |
michael@0 | 73 | }, |
michael@0 | 74 | ], |
michael@0 | 75 | }, |
michael@0 | 76 | { |
michael@0 | 77 | level: "dir", |
michael@0 | 78 | filename: /test_consoleapi/, |
michael@0 | 79 | functionName: "doConsoleCalls", |
michael@0 | 80 | timeStamp: /^\d+$/, |
michael@0 | 81 | arguments: [ |
michael@0 | 82 | { |
michael@0 | 83 | type: "object", |
michael@0 | 84 | actor: /[a-z]/, |
michael@0 | 85 | class: "XULDocument", |
michael@0 | 86 | }, |
michael@0 | 87 | { |
michael@0 | 88 | type: "object", |
michael@0 | 89 | actor: /[a-z]/, |
michael@0 | 90 | class: "Location", |
michael@0 | 91 | } |
michael@0 | 92 | ], |
michael@0 | 93 | }, |
michael@0 | 94 | { |
michael@0 | 95 | level: "log", |
michael@0 | 96 | filename: /test_consoleapi/, |
michael@0 | 97 | functionName: "doConsoleCalls", |
michael@0 | 98 | timeStamp: /^\d+$/, |
michael@0 | 99 | arguments: [ |
michael@0 | 100 | "foo", |
michael@0 | 101 | { |
michael@0 | 102 | type: "longString", |
michael@0 | 103 | initial: longString.substring(0, |
michael@0 | 104 | DebuggerServer.LONG_STRING_INITIAL_LENGTH), |
michael@0 | 105 | length: longString.length, |
michael@0 | 106 | actor: /[a-z]/, |
michael@0 | 107 | }, |
michael@0 | 108 | ], |
michael@0 | 109 | }, |
michael@0 | 110 | ]; |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | function startTest() |
michael@0 | 114 | { |
michael@0 | 115 | removeEventListener("load", startTest); |
michael@0 | 116 | |
michael@0 | 117 | attachConsole(["ConsoleAPI"], onAttach, true); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | function onAttach(aState, aResponse) |
michael@0 | 121 | { |
michael@0 | 122 | onConsoleAPICall = onConsoleAPICall.bind(null, aState); |
michael@0 | 123 | aState.dbgClient.addListener("consoleAPICall", onConsoleAPICall); |
michael@0 | 124 | doConsoleCalls(aState.actor); |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | let consoleCalls = []; |
michael@0 | 128 | |
michael@0 | 129 | function onConsoleAPICall(aState, aType, aPacket) |
michael@0 | 130 | { |
michael@0 | 131 | info("received message level: " + aPacket.message.level); |
michael@0 | 132 | is(aPacket.from, aState.actor, "console API call actor"); |
michael@0 | 133 | |
michael@0 | 134 | consoleCalls.push(aPacket.message); |
michael@0 | 135 | if (consoleCalls.length != expectedConsoleCalls.length) { |
michael@0 | 136 | return; |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | aState.dbgClient.removeListener("consoleAPICall", onConsoleAPICall); |
michael@0 | 140 | |
michael@0 | 141 | expectedConsoleCalls.forEach(function(aMessage, aIndex) { |
michael@0 | 142 | info("checking received console call #" + aIndex); |
michael@0 | 143 | checkConsoleAPICall(consoleCalls[aIndex], expectedConsoleCalls[aIndex]); |
michael@0 | 144 | }); |
michael@0 | 145 | |
michael@0 | 146 | |
michael@0 | 147 | consoleCalls = []; |
michael@0 | 148 | |
michael@0 | 149 | closeDebugger(aState, function() { |
michael@0 | 150 | SimpleTest.finish(); |
michael@0 | 151 | }); |
michael@0 | 152 | } |
michael@0 | 153 | |
michael@0 | 154 | addEventListener("load", startTest); |
michael@0 | 155 | </script> |
michael@0 | 156 | </body> |
michael@0 | 157 | </html> |