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 cd() function</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 cd() function</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 gState; |
michael@0 | 18 | |
michael@0 | 19 | function startTest() |
michael@0 | 20 | { |
michael@0 | 21 | removeEventListener("load", startTest); |
michael@0 | 22 | |
michael@0 | 23 | attachConsole([], onAttach, true); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function onAttach(aState, aResponse) |
michael@0 | 27 | { |
michael@0 | 28 | top.foobarObject = Object.create(null); |
michael@0 | 29 | top.foobarObject.bug609872 = "parent"; |
michael@0 | 30 | |
michael@0 | 31 | window.foobarObject = Object.create(null); |
michael@0 | 32 | window.foobarObject.bug609872 = "child"; |
michael@0 | 33 | |
michael@0 | 34 | gState = aState; |
michael@0 | 35 | |
michael@0 | 36 | let tests = [doCheckParent, doCdIframe, doCheckIframe, doCdParent, |
michael@0 | 37 | doCheckParent2]; |
michael@0 | 38 | runTests(tests, testEnd); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function doCheckParent() |
michael@0 | 42 | { |
michael@0 | 43 | info("check parent window"); |
michael@0 | 44 | gState.client.evaluateJS("window.foobarObject.bug609872", |
michael@0 | 45 | onFooObjectFromParent); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function onFooObjectFromParent(aResponse) |
michael@0 | 49 | { |
michael@0 | 50 | checkObject(aResponse, { |
michael@0 | 51 | from: gState.actor, |
michael@0 | 52 | input: "window.foobarObject.bug609872", |
michael@0 | 53 | result: "parent", |
michael@0 | 54 | }); |
michael@0 | 55 | |
michael@0 | 56 | ok(!aResponse.exception, "no eval exception"); |
michael@0 | 57 | ok(!aResponse.helperResult, "no helper result"); |
michael@0 | 58 | |
michael@0 | 59 | nextTest(); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function doCdIframe() |
michael@0 | 63 | { |
michael@0 | 64 | info("test cd('iframe')"); |
michael@0 | 65 | gState.client.evaluateJS("cd('iframe')", onCdIframe); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function onCdIframe(aResponse) |
michael@0 | 69 | { |
michael@0 | 70 | checkObject(aResponse, { |
michael@0 | 71 | from: gState.actor, |
michael@0 | 72 | input: "cd('iframe')", |
michael@0 | 73 | result: { type: "undefined" }, |
michael@0 | 74 | helperResult: { type: "cd" }, |
michael@0 | 75 | }); |
michael@0 | 76 | |
michael@0 | 77 | ok(!aResponse.exception, "no eval exception"); |
michael@0 | 78 | |
michael@0 | 79 | nextTest(); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | function doCheckIframe() |
michael@0 | 83 | { |
michael@0 | 84 | info("check foobarObject from the iframe"); |
michael@0 | 85 | gState.client.evaluateJS("window.foobarObject.bug609872", |
michael@0 | 86 | onFooObjectFromIframe); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | function onFooObjectFromIframe(aResponse) |
michael@0 | 90 | { |
michael@0 | 91 | checkObject(aResponse, { |
michael@0 | 92 | from: gState.actor, |
michael@0 | 93 | input: "window.foobarObject.bug609872", |
michael@0 | 94 | result: "child", |
michael@0 | 95 | }); |
michael@0 | 96 | |
michael@0 | 97 | ok(!aResponse.exception, "no js eval exception"); |
michael@0 | 98 | ok(!aResponse.helperResult, "no helper result"); |
michael@0 | 99 | |
michael@0 | 100 | nextTest(); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | function doCdParent() |
michael@0 | 104 | { |
michael@0 | 105 | info("test cd() back to parent"); |
michael@0 | 106 | gState.client.evaluateJS("cd()", onCdParent); |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | function onCdParent(aResponse) |
michael@0 | 110 | { |
michael@0 | 111 | checkObject(aResponse, { |
michael@0 | 112 | from: gState.actor, |
michael@0 | 113 | input: "cd()", |
michael@0 | 114 | result: { type: "undefined" }, |
michael@0 | 115 | helperResult: { type: "cd" }, |
michael@0 | 116 | }); |
michael@0 | 117 | |
michael@0 | 118 | ok(!aResponse.exception, "no eval exception"); |
michael@0 | 119 | |
michael@0 | 120 | nextTest(); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | function doCheckParent2() |
michael@0 | 124 | { |
michael@0 | 125 | gState.client.evaluateJS("window.foobarObject.bug609872", |
michael@0 | 126 | onFooObjectFromParent2); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | function onFooObjectFromParent2(aResponse) |
michael@0 | 130 | { |
michael@0 | 131 | checkObject(aResponse, { |
michael@0 | 132 | from: gState.actor, |
michael@0 | 133 | input: "window.foobarObject.bug609872", |
michael@0 | 134 | result: "parent", |
michael@0 | 135 | }); |
michael@0 | 136 | |
michael@0 | 137 | ok(!aResponse.exception, "no eval exception"); |
michael@0 | 138 | ok(!aResponse.helperResult, "no helper result"); |
michael@0 | 139 | |
michael@0 | 140 | nextTest(); |
michael@0 | 141 | } |
michael@0 | 142 | |
michael@0 | 143 | function testEnd() |
michael@0 | 144 | { |
michael@0 | 145 | closeDebugger(gState, function() { |
michael@0 | 146 | gState = null; |
michael@0 | 147 | SimpleTest.finish(); |
michael@0 | 148 | }); |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | addEventListener("load", startTest); |
michael@0 | 152 | </script> |
michael@0 | 153 | </body> |
michael@0 | 154 | </html> |