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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /* See https://bugzilla.mozilla.org/show_bug.cgi?id=898559 */ |
michael@0 | 6 | |
michael@0 | 7 | function run_test() |
michael@0 | 8 | { |
michael@0 | 9 | let sandbox = Components.utils.Sandbox("http://www.blah.com", { |
michael@0 | 10 | metadata: "test metadata" |
michael@0 | 11 | }); |
michael@0 | 12 | |
michael@0 | 13 | do_check_eq(Components.utils.getSandboxMetadata(sandbox), "test metadata"); |
michael@0 | 14 | |
michael@0 | 15 | let sandbox = Components.utils.Sandbox("http://www.blah.com", { |
michael@0 | 16 | metadata: { foopy: { bar: 2 }, baz: "hi" } |
michael@0 | 17 | }); |
michael@0 | 18 | |
michael@0 | 19 | let metadata = Components.utils.getSandboxMetadata(sandbox); |
michael@0 | 20 | do_check_eq(metadata.baz, "hi"); |
michael@0 | 21 | do_check_eq(metadata.foopy.bar, 2); |
michael@0 | 22 | metadata.baz = "foo"; |
michael@0 | 23 | |
michael@0 | 24 | metadata = Components.utils.getSandboxMetadata(sandbox); |
michael@0 | 25 | do_check_eq(metadata.baz, "foo"); |
michael@0 | 26 | |
michael@0 | 27 | metadata = { foo: "bar" }; |
michael@0 | 28 | Components.utils.setSandboxMetadata(sandbox, metadata); |
michael@0 | 29 | metadata.foo = "baz"; |
michael@0 | 30 | metadata = Components.utils.getSandboxMetadata(sandbox); |
michael@0 | 31 | do_check_eq(metadata.foo, "bar"); |
michael@0 | 32 | |
michael@0 | 33 | let thrown = false; |
michael@0 | 34 | let reflector = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] |
michael@0 | 35 | .createInstance(Components.interfaces.nsIXMLHttpRequest); |
michael@0 | 36 | |
michael@0 | 37 | try { |
michael@0 | 38 | Components.utils.setSandboxMetadata(sandbox, { foo: reflector }); |
michael@0 | 39 | } catch(e) { |
michael@0 | 40 | thrown = true; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | do_check_eq(thrown, true); |
michael@0 | 44 | |
michael@0 | 45 | sandbox = Components.utils.Sandbox(this, { |
michael@0 | 46 | metadata: { foopy: { bar: 2 }, baz: "hi" } |
michael@0 | 47 | }); |
michael@0 | 48 | |
michael@0 | 49 | let inner = Components.utils.evalInSandbox("Components.utils.Sandbox('http://www.blah.com')", sandbox); |
michael@0 | 50 | |
michael@0 | 51 | metadata = Components.utils.getSandboxMetadata(inner); |
michael@0 | 52 | do_check_eq(metadata.baz, "hi"); |
michael@0 | 53 | do_check_eq(metadata.foopy.bar, 2); |
michael@0 | 54 | metadata.baz = "foo"; |
michael@0 | 55 | } |
michael@0 | 56 |