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 | // Test startup and restart when no add-ons are installed |
michael@0 | 6 | // bug 944006 |
michael@0 | 7 | |
michael@0 | 8 | Components.utils.import("resource://gre/modules/Promise.jsm"); |
michael@0 | 9 | |
michael@0 | 10 | // Load XPI Provider to get schema version ID |
michael@0 | 11 | let XPIScope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm"); |
michael@0 | 12 | const DB_SCHEMA = XPIScope.DB_SCHEMA; |
michael@0 | 13 | |
michael@0 | 14 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); |
michael@0 | 15 | |
michael@0 | 16 | function run_test() { |
michael@0 | 17 | // Kick off the task-based tests... |
michael@0 | 18 | run_next_test(); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | // Test for a preference to either exist with a specified value, or not exist at all |
michael@0 | 22 | function checkPending() { |
michael@0 | 23 | try { |
michael@0 | 24 | do_check_false(Services.prefs.getBoolPref("extensions.pendingOperations")); |
michael@0 | 25 | } |
michael@0 | 26 | catch (e) { |
michael@0 | 27 | // OK |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function checkString(aPref, aValue) { |
michael@0 | 32 | try { |
michael@0 | 33 | do_check_eq(Services.prefs.getCharPref(aPref), aValue) |
michael@0 | 34 | } |
michael@0 | 35 | catch (e) { |
michael@0 | 36 | //OK |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | // Make sure all our extension state is empty/nonexistent |
michael@0 | 41 | function check_empty_state() { |
michael@0 | 42 | do_check_false(gExtensionsJSON.exists()); |
michael@0 | 43 | do_check_false(gExtensionsINI.exists()); |
michael@0 | 44 | |
michael@0 | 45 | do_check_eq(Services.prefs.getIntPref("extensions.databaseSchema"), DB_SCHEMA); |
michael@0 | 46 | |
michael@0 | 47 | checkString("extensions.bootstrappedAddons", "{}"); |
michael@0 | 48 | checkString("extensions.installCache", "[]"); |
michael@0 | 49 | checkPending(); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | // After first run with no add-ons, we expect: |
michael@0 | 53 | // no extensions.json is created |
michael@0 | 54 | // no extensions.ini |
michael@0 | 55 | // database schema version preference is set |
michael@0 | 56 | // bootstrap add-ons preference is not found |
michael@0 | 57 | // add-on directory state preference is an empty array |
michael@0 | 58 | // no pending operations |
michael@0 | 59 | add_task(function first_run() { |
michael@0 | 60 | startupManager(); |
michael@0 | 61 | check_empty_state(); |
michael@0 | 62 | yield true; |
michael@0 | 63 | }); |
michael@0 | 64 | |
michael@0 | 65 | // Now do something that causes a DB load, and re-check |
michael@0 | 66 | function trigger_db_load() { |
michael@0 | 67 | let addonDefer = Promise.defer(); |
michael@0 | 68 | AddonManager.getAddonsByTypes(['extension'], addonDefer.resolve); |
michael@0 | 69 | let addonList = yield addonDefer.promise; |
michael@0 | 70 | |
michael@0 | 71 | do_check_eq(addonList.length, 0); |
michael@0 | 72 | check_empty_state(); |
michael@0 | 73 | |
michael@0 | 74 | yield true; |
michael@0 | 75 | }; |
michael@0 | 76 | add_task(trigger_db_load); |
michael@0 | 77 | |
michael@0 | 78 | // Now restart the manager and check again |
michael@0 | 79 | add_task(function restart_and_recheck() { |
michael@0 | 80 | restartManager(); |
michael@0 | 81 | check_empty_state(); |
michael@0 | 82 | yield true; |
michael@0 | 83 | }); |
michael@0 | 84 | |
michael@0 | 85 | // and reload the DB again |
michael@0 | 86 | add_task(trigger_db_load); |
michael@0 | 87 | |
michael@0 | 88 | // When we start up with no DB and an old database schema, we should update the |
michael@0 | 89 | // schema number but not create a database |
michael@0 | 90 | add_task(function upgrade_schema_version() { |
michael@0 | 91 | shutdownManager(); |
michael@0 | 92 | Services.prefs.setIntPref("extensions.databaseSchema", 1); |
michael@0 | 93 | |
michael@0 | 94 | startupManager(); |
michael@0 | 95 | do_check_eq(Services.prefs.getIntPref("extensions.databaseSchema"), DB_SCHEMA); |
michael@0 | 96 | check_empty_state(); |
michael@0 | 97 | }); |
michael@0 | 98 |