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