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 | /** |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | const INITIAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/begin.html"; |
michael@0 | 7 | const FINAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/final.html"; |
michael@0 | 8 | |
michael@0 | 9 | let gTab = gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 10 | |
michael@0 | 11 | /** |
michael@0 | 12 | * One-time observer callback. |
michael@0 | 13 | */ |
michael@0 | 14 | function waitForObserve(name, callback) |
michael@0 | 15 | { |
michael@0 | 16 | let observer = { |
michael@0 | 17 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), |
michael@0 | 18 | observe: function(subject, topic, data) |
michael@0 | 19 | { |
michael@0 | 20 | Services.obs.removeObserver(observer, name); |
michael@0 | 21 | callback(subject, topic, data); |
michael@0 | 22 | } |
michael@0 | 23 | }; |
michael@0 | 24 | |
michael@0 | 25 | Services.obs.addObserver(observer, name, false); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * One-time DOMContentLoaded callback. |
michael@0 | 30 | */ |
michael@0 | 31 | function waitForLoad(callback) |
michael@0 | 32 | { |
michael@0 | 33 | gTab.linkedBrowser.addEventListener("load", function() |
michael@0 | 34 | { |
michael@0 | 35 | gTab.linkedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 36 | callback(); |
michael@0 | 37 | }, true); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function test() |
michael@0 | 41 | { |
michael@0 | 42 | waitForExplicitFinish(); |
michael@0 | 43 | |
michael@0 | 44 | Services.prefs.setBoolPref("places.history.enabled", false); |
michael@0 | 45 | |
michael@0 | 46 | waitForObserve("uri-visit-saved", function(subject, topic, data) |
michael@0 | 47 | { |
michael@0 | 48 | let uri = subject.QueryInterface(Ci.nsIURI); |
michael@0 | 49 | is(uri.spec, FINAL_URL, "received expected visit"); |
michael@0 | 50 | if (uri.spec != FINAL_URL) |
michael@0 | 51 | return; |
michael@0 | 52 | gBrowser.removeCurrentTab(); |
michael@0 | 53 | promiseClearHistory().then(finish); |
michael@0 | 54 | }); |
michael@0 | 55 | |
michael@0 | 56 | Services.prefs.setBoolPref("places.history.enabled", false); |
michael@0 | 57 | content.location.href = INITIAL_URL; |
michael@0 | 58 | waitForLoad(function() |
michael@0 | 59 | { |
michael@0 | 60 | try { |
michael@0 | 61 | Services.prefs.clearUserPref("places.history.enabled"); |
michael@0 | 62 | } catch(ex) {} |
michael@0 | 63 | content.location.href = FINAL_URL; |
michael@0 | 64 | }); |
michael@0 | 65 | } |