xpcom/tests/unit/test_bug725015.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 const Cc = Components.classes;
michael@0 6 const Ci = Components.interfaces;
michael@0 7
michael@0 8 Components.utils.import("resource://gre/modules/Services.jsm");
michael@0 9
michael@0 10 const manifest = do_get_file('bug725015.manifest');
michael@0 11 const contract = "@bug725015.test.contract";
michael@0 12 const observerTopic = "xpcom-category-entry-added";
michael@0 13 const category = "bug725015-test-category";
michael@0 14 const entry = "bug725015-category-entry";
michael@0 15 const cid = Components.ID("{05070380-6e6e-42ba-aaa5-3289fc55ca5a}");
michael@0 16
michael@0 17 function observe_category(subj, topic, data) {
michael@0 18 try {
michael@0 19 do_check_eq(topic, observerTopic);
michael@0 20 if (data != category)
michael@0 21 return;
michael@0 22
michael@0 23 var thisentry = subj.QueryInterface(Ci.nsISupportsCString).data;
michael@0 24 do_check_eq(thisentry, entry);
michael@0 25
michael@0 26 do_check_eq(Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager).getCategoryEntry(category, entry), contract);
michael@0 27 do_check_true(Cc[contract].equals(cid));
michael@0 28 }
michael@0 29 catch (e) {
michael@0 30 do_throw(e);
michael@0 31 }
michael@0 32 do_test_finished();
michael@0 33 }
michael@0 34
michael@0 35 function run_test() {
michael@0 36 do_test_pending();
michael@0 37 Services.obs.addObserver(observe_category, observerTopic, false);
michael@0 38 Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest);
michael@0 39 }

mercurial