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 getIcons() and getIconURLBySize() on engine with multiple icons. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | "use strict"; |
michael@0 | 9 | |
michael@0 | 10 | const Ci = Components.interfaces; |
michael@0 | 11 | const Cu = Components.utils; |
michael@0 | 12 | |
michael@0 | 13 | Cu.import("resource://testing-common/httpd.js"); |
michael@0 | 14 | |
michael@0 | 15 | function test_multiIcon() { |
michael@0 | 16 | let engine = Services.search.getEngineByName("IconsTest"); |
michael@0 | 17 | do_check_neq(engine, null); |
michael@0 | 18 | |
michael@0 | 19 | do_print("Running tests on IconsTest engine"); |
michael@0 | 20 | |
michael@0 | 21 | do_print("The default should be the 16x16 icon"); |
michael@0 | 22 | do_check_true(engine.iconURI.spec.contains("ico16")); |
michael@0 | 23 | |
michael@0 | 24 | do_check_true(engine.getIconURLBySize(32,32).contains("ico32")); |
michael@0 | 25 | do_check_true(engine.getIconURLBySize(74,74).contains("ico74")); |
michael@0 | 26 | |
michael@0 | 27 | do_print("Invalid dimensions should return null."); |
michael@0 | 28 | do_check_null(engine.getIconURLBySize(50,50)); |
michael@0 | 29 | |
michael@0 | 30 | let allIcons = engine.getIcons(); |
michael@0 | 31 | |
michael@0 | 32 | do_print("Check that allIcons contains expected icon sizes"); |
michael@0 | 33 | do_check_eq(allIcons.length, 3); |
michael@0 | 34 | let expectedWidths = [16, 32, 74]; |
michael@0 | 35 | do_check_true(allIcons.every((item) => { |
michael@0 | 36 | let width = item.width; |
michael@0 | 37 | do_check_neq(expectedWidths.indexOf(width), -1); |
michael@0 | 38 | do_check_eq(width, item.height); |
michael@0 | 39 | |
michael@0 | 40 | let icon = item.url.split(",").pop(); |
michael@0 | 41 | do_check_eq(icon, "ico" + width); |
michael@0 | 42 | |
michael@0 | 43 | return true; |
michael@0 | 44 | })); |
michael@0 | 45 | |
michael@0 | 46 | do_test_finished(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function run_test() { |
michael@0 | 50 | removeMetadata(); |
michael@0 | 51 | updateAppInfo(); |
michael@0 | 52 | |
michael@0 | 53 | let httpServer = new HttpServer(); |
michael@0 | 54 | httpServer.start(4444); |
michael@0 | 55 | httpServer.registerDirectory("/", do_get_cwd()); |
michael@0 | 56 | |
michael@0 | 57 | do_register_cleanup(function cleanup() { |
michael@0 | 58 | httpServer.stop(function() {}); |
michael@0 | 59 | }); |
michael@0 | 60 | |
michael@0 | 61 | do_test_pending(); |
michael@0 | 62 | |
michael@0 | 63 | let observer = function(aSubject, aTopic, aData) { |
michael@0 | 64 | if (aData == "engine-loaded") { |
michael@0 | 65 | test_multiIcon(); |
michael@0 | 66 | } |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | Services.obs.addObserver(observer, "browser-search-engine-modified", false); |
michael@0 | 70 | |
michael@0 | 71 | do_print("Adding engine with multiple images"); |
michael@0 | 72 | Services.search.addEngine("http://localhost:4444/data/engineImages.xml", |
michael@0 | 73 | Ci.nsISearchEngine.DATA_XML, null, false); |
michael@0 | 74 | |
michael@0 | 75 | do_timeout(12000, function() { |
michael@0 | 76 | do_throw("Timeout"); |
michael@0 | 77 | }); |
michael@0 | 78 | } |