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 | const TEST_PROVIDER_ORIGIN = 'http://example.com'; |
michael@0 | 6 | |
michael@0 | 7 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 8 | |
michael@0 | 9 | function ensureProvider(workerFunction, cb) { |
michael@0 | 10 | let manifest = { |
michael@0 | 11 | origin: TEST_PROVIDER_ORIGIN, |
michael@0 | 12 | name: "Example Provider", |
michael@0 | 13 | workerURL: "http://example.com/browser/toolkit/components/social/test/browser/echo.sjs?" |
michael@0 | 14 | + encodeURI("let run=" + workerFunction.toSource()) + ";run();" |
michael@0 | 15 | }; |
michael@0 | 16 | |
michael@0 | 17 | SocialService.addProvider(manifest, function (p) { |
michael@0 | 18 | cb(p); |
michael@0 | 19 | }); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function test() { |
michael@0 | 23 | waitForExplicitFinish(); |
michael@0 | 24 | |
michael@0 | 25 | let cbPostTest = function(cb) { |
michael@0 | 26 | SocialService.removeProvider(TEST_PROVIDER_ORIGIN, function() {cb()}); |
michael@0 | 27 | }; |
michael@0 | 28 | replaceAlertsService(); |
michael@0 | 29 | registerCleanupFunction(restoreAlertsService); |
michael@0 | 30 | runTests(tests, undefined, cbPostTest); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | let tests = { |
michael@0 | 34 | testNotificationCallback: function(cbnext) { |
michael@0 | 35 | let run = function() { |
michael@0 | 36 | let testPort, apiPort; |
michael@0 | 37 | onconnect = function(e) { |
michael@0 | 38 | let port = e.ports[0]; |
michael@0 | 39 | port.onmessage = function(e) { |
michael@0 | 40 | if (e.data.topic == "social.initialize") { // this is the api port. |
michael@0 | 41 | apiPort = port; |
michael@0 | 42 | } else if (e.data.topic == "test.initialize") { // test suite port. |
michael@0 | 43 | testPort = port; |
michael@0 | 44 | apiPort.postMessage({topic: 'social.notification-create', |
michael@0 | 45 | data: { |
michael@0 | 46 | id: "the id", |
michael@0 | 47 | body: 'test notification', |
michael@0 | 48 | action: 'callback', |
michael@0 | 49 | actionArgs: { data: "something" } |
michael@0 | 50 | } |
michael@0 | 51 | }); |
michael@0 | 52 | } else if (e.data.topic == "social.notification-action") { |
michael@0 | 53 | let data = e.data.data; |
michael@0 | 54 | let ok = data && data.action == "callback" && |
michael@0 | 55 | data.actionArgs && e.data.data.actionArgs.data == "something"; |
michael@0 | 56 | testPort.postMessage({topic: "test.done", data: ok}); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | } |
michael@0 | 60 | } |
michael@0 | 61 | ensureProvider(run, function(provider) { |
michael@0 | 62 | let observer = { |
michael@0 | 63 | observedData: null, |
michael@0 | 64 | observe: function(subject, topic, data) { |
michael@0 | 65 | this.observedData = JSON.parse(data); |
michael@0 | 66 | Services.obs.removeObserver(observer, "social-test:notification-alert"); |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | Services.obs.addObserver(observer, "social-test:notification-alert", false); |
michael@0 | 70 | |
michael@0 | 71 | let port = provider.getWorkerPort(); |
michael@0 | 72 | ok(port, "got port from worker"); |
michael@0 | 73 | port.onmessage = function(e) { |
michael@0 | 74 | if (e.data.topic == "test.done") { |
michael@0 | 75 | ok(e.data.data, "check the test worked"); |
michael@0 | 76 | ok(observer.observedData, "test observer fired"); |
michael@0 | 77 | is(observer.observedData.text, "test notification", "check the alert text is correct"); |
michael@0 | 78 | is(observer.observedData.title, "Example Provider", "check the alert title is correct"); |
michael@0 | 79 | is(observer.observedData.textClickable, true, "check the alert is clickable"); |
michael@0 | 80 | port.close(); |
michael@0 | 81 | cbnext(); |
michael@0 | 82 | } |
michael@0 | 83 | } |
michael@0 | 84 | port.postMessage({topic: "test.initialize"}); |
michael@0 | 85 | }); |
michael@0 | 86 | } |
michael@0 | 87 | }; |