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 | /* |
michael@0 | 5 | * Tests getResultDomain API. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | "use strict"; |
michael@0 | 9 | |
michael@0 | 10 | const Ci = Components.interfaces; |
michael@0 | 11 | |
michael@0 | 12 | Components.utils.import("resource://testing-common/httpd.js"); |
michael@0 | 13 | |
michael@0 | 14 | let waitForEngines = new Set([ "Test search engine", |
michael@0 | 15 | "A second test engine", |
michael@0 | 16 | "bacon" ]); |
michael@0 | 17 | |
michael@0 | 18 | function promiseEnginesAdded() { |
michael@0 | 19 | let deferred = Promise.defer(); |
michael@0 | 20 | |
michael@0 | 21 | let observe = function observe(aSubject, aTopic, aData) { |
michael@0 | 22 | let engine = aSubject.QueryInterface(Ci.nsISearchEngine); |
michael@0 | 23 | do_print("Observer: " + aData + " for " + engine.name); |
michael@0 | 24 | if (aData != "engine-added") { |
michael@0 | 25 | return; |
michael@0 | 26 | } |
michael@0 | 27 | waitForEngines.delete(engine.name); |
michael@0 | 28 | if (waitForEngines.size > 0) { |
michael@0 | 29 | return; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | let engine1 = Services.search.getEngineByName("Test search engine"); |
michael@0 | 33 | do_check_eq(engine1.getResultDomain(), "google.com"); |
michael@0 | 34 | do_check_eq(engine1.getResultDomain("text/html"), "google.com"); |
michael@0 | 35 | do_check_eq(engine1.getResultDomain("application/x-moz-default-purpose"), |
michael@0 | 36 | "purpose.google.com"); |
michael@0 | 37 | do_check_eq(engine1.getResultDomain("fake-response-type"), ""); |
michael@0 | 38 | let engine2 = Services.search.getEngineByName("A second test engine"); |
michael@0 | 39 | do_check_eq(engine2.getResultDomain(), "duckduckgo.com"); |
michael@0 | 40 | let engine3 = Services.search.getEngineByName("bacon"); |
michael@0 | 41 | do_check_eq(engine3.getResultDomain(), "bacon.moz"); |
michael@0 | 42 | deferred.resolve(); |
michael@0 | 43 | }; |
michael@0 | 44 | |
michael@0 | 45 | Services.obs.addObserver(observe, "browser-search-engine-modified", false); |
michael@0 | 46 | do_register_cleanup(function cleanup() { |
michael@0 | 47 | Services.obs.removeObserver(observe, "browser-search-engine-modified"); |
michael@0 | 48 | }); |
michael@0 | 49 | |
michael@0 | 50 | return deferred.promise; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function run_test() { |
michael@0 | 54 | removeMetadata(); |
michael@0 | 55 | updateAppInfo(); |
michael@0 | 56 | |
michael@0 | 57 | run_next_test(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | add_task(function* check_resultDomain() { |
michael@0 | 61 | let httpServer = new HttpServer(); |
michael@0 | 62 | httpServer.start(-1); |
michael@0 | 63 | httpServer.registerDirectory("/", do_get_cwd()); |
michael@0 | 64 | let baseUrl = "http://localhost:" + httpServer.identity.primaryPort; |
michael@0 | 65 | do_register_cleanup(function cleanup() { |
michael@0 | 66 | httpServer.stop(function() {}); |
michael@0 | 67 | }); |
michael@0 | 68 | |
michael@0 | 69 | let promise = promiseEnginesAdded(); |
michael@0 | 70 | Services.search.addEngine(baseUrl + "/data/engine.xml", |
michael@0 | 71 | Ci.nsISearchEngine.DATA_XML, |
michael@0 | 72 | null, false); |
michael@0 | 73 | Services.search.addEngine(baseUrl + "/data/engine2.xml", |
michael@0 | 74 | Ci.nsISearchEngine.DATA_XML, |
michael@0 | 75 | null, false); |
michael@0 | 76 | Services.search.addEngineWithDetails("bacon", "", "bacon", "Search Bacon", |
michael@0 | 77 | "GET", "http://www.bacon.moz/?search={searchTerms}"); |
michael@0 | 78 | yield promise; |
michael@0 | 79 | }); |