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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | "use strict"; |
michael@0 | 5 | |
michael@0 | 6 | const Ci = Components.interfaces; |
michael@0 | 7 | |
michael@0 | 8 | Components.utils.import("resource://testing-common/httpd.js"); |
michael@0 | 9 | |
michael@0 | 10 | let gTestLog = []; |
michael@0 | 11 | |
michael@0 | 12 | /** |
michael@0 | 13 | * The order of notifications expected for this test is: |
michael@0 | 14 | * - engine-changed (while we're installing the engine, we modify it, which notifies - bug 606886) |
michael@0 | 15 | * - engine-added (engine was added to the store by the search service) |
michael@0 | 16 | * -> our search observer is called, which sets: |
michael@0 | 17 | * - .defaultEngine, triggering engine-default |
michael@0 | 18 | * - .currentEngine, triggering engine-current (after bug 493051 - for now the search service sets this after engine-added) |
michael@0 | 19 | * ...and then schedules a removal |
michael@0 | 20 | * - engine-loaded (the search service's observer is garanteed to fire first, which is what causes engine-added to fire) |
michael@0 | 21 | * - engine-removed (due to the removal schedule above) |
michael@0 | 22 | */ |
michael@0 | 23 | let expectedLog = [ |
michael@0 | 24 | "engine-changed", // XXX bug 606886 |
michael@0 | 25 | "engine-added", |
michael@0 | 26 | "engine-default", |
michael@0 | 27 | "engine-current", |
michael@0 | 28 | "engine-loaded", |
michael@0 | 29 | "engine-removed" |
michael@0 | 30 | ]; |
michael@0 | 31 | |
michael@0 | 32 | function search_observer(subject, topic, data) { |
michael@0 | 33 | let engine = subject.QueryInterface(Ci.nsISearchEngine); |
michael@0 | 34 | gTestLog.push(data + " for " + engine.name); |
michael@0 | 35 | |
michael@0 | 36 | do_print("Observer: " + data + " for " + engine.name); |
michael@0 | 37 | |
michael@0 | 38 | switch (data) { |
michael@0 | 39 | case "engine-added": |
michael@0 | 40 | let retrievedEngine = Services.search.getEngineByName("Test search engine"); |
michael@0 | 41 | do_check_eq(engine, retrievedEngine); |
michael@0 | 42 | Services.search.defaultEngine = engine; |
michael@0 | 43 | Services.search.currentEngine = engine; |
michael@0 | 44 | do_execute_soon(function () { |
michael@0 | 45 | Services.search.removeEngine(engine); |
michael@0 | 46 | }); |
michael@0 | 47 | break; |
michael@0 | 48 | case "engine-removed": |
michael@0 | 49 | let engineNameOutput = " for Test search engine"; |
michael@0 | 50 | expectedLog = expectedLog.map(logLine => logLine + engineNameOutput); |
michael@0 | 51 | do_print("expectedLog:\n" + expectedLog.join("\n")) |
michael@0 | 52 | do_print("gTestLog:\n" + gTestLog.join("\n")) |
michael@0 | 53 | for (let i = 0; i < expectedLog.length; i++) { |
michael@0 | 54 | do_check_eq(gTestLog[i], expectedLog[i]); |
michael@0 | 55 | } |
michael@0 | 56 | do_check_eq(gTestLog.length, expectedLog.length); |
michael@0 | 57 | do_test_finished(); |
michael@0 | 58 | break; |
michael@0 | 59 | } |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function run_test() { |
michael@0 | 63 | removeMetadata(); |
michael@0 | 64 | updateAppInfo(); |
michael@0 | 65 | |
michael@0 | 66 | let httpServer = new HttpServer(); |
michael@0 | 67 | httpServer.start(-1); |
michael@0 | 68 | httpServer.registerDirectory("/", do_get_cwd()); |
michael@0 | 69 | |
michael@0 | 70 | do_register_cleanup(function cleanup() { |
michael@0 | 71 | httpServer.stop(function() {}); |
michael@0 | 72 | Services.obs.removeObserver(search_observer, "browser-search-engine-modified"); |
michael@0 | 73 | }); |
michael@0 | 74 | |
michael@0 | 75 | do_test_pending(); |
michael@0 | 76 | |
michael@0 | 77 | Services.obs.addObserver(search_observer, "browser-search-engine-modified", false); |
michael@0 | 78 | |
michael@0 | 79 | Services.search.addEngine("http://localhost:" + |
michael@0 | 80 | httpServer.identity.primaryPort + |
michael@0 | 81 | "/data/engine.xml", |
michael@0 | 82 | Ci.nsISearchEngine.DATA_XML, |
michael@0 | 83 | null, false); |
michael@0 | 84 | } |