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 that xpinstall.[whitelist|blacklist].add preferences are emptied when |
michael@0 | 6 | // converted into permissions. |
michael@0 | 7 | |
michael@0 | 8 | const PREF_XPI_WHITELIST_PERMISSIONS = "xpinstall.whitelist.add"; |
michael@0 | 9 | const PREF_XPI_BLACKLIST_PERMISSIONS = "xpinstall.blacklist.add"; |
michael@0 | 10 | |
michael@0 | 11 | function do_check_permission_prefs(preferences) { |
michael@0 | 12 | // Check preferences were emptied |
michael@0 | 13 | for (let pref of preferences) { |
michael@0 | 14 | try { |
michael@0 | 15 | do_check_eq(Services.prefs.getCharPref(pref), ""); |
michael@0 | 16 | } |
michael@0 | 17 | catch (e) { |
michael@0 | 18 | // Successfully emptied |
michael@0 | 19 | } |
michael@0 | 20 | } |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function clear_imported_preferences_cache() { |
michael@0 | 24 | let scope = Components.utils.import("resource://gre/modules/PermissionsUtils.jsm", {}); |
michael@0 | 25 | scope.gImportedPrefBranches.clear(); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function run_test() { |
michael@0 | 29 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); |
michael@0 | 30 | |
michael@0 | 31 | // Create own preferences to test |
michael@0 | 32 | Services.prefs.setCharPref("xpinstall.whitelist.add.EMPTY", ""); |
michael@0 | 33 | Services.prefs.setCharPref("xpinstall.whitelist.add.TEST", "whitelist.example.com"); |
michael@0 | 34 | Services.prefs.setCharPref("xpinstall.blacklist.add.EMPTY", ""); |
michael@0 | 35 | Services.prefs.setCharPref("xpinstall.blacklist.add.TEST", "blacklist.example.com"); |
michael@0 | 36 | |
michael@0 | 37 | // Get list of preferences to check |
michael@0 | 38 | var whitelistPreferences = Services.prefs.getChildList(PREF_XPI_WHITELIST_PERMISSIONS, {}); |
michael@0 | 39 | var blacklistPreferences = Services.prefs.getChildList(PREF_XPI_BLACKLIST_PERMISSIONS, {}); |
michael@0 | 40 | var preferences = whitelistPreferences.concat(blacklistPreferences); |
michael@0 | 41 | |
michael@0 | 42 | startupManager(); |
michael@0 | 43 | |
michael@0 | 44 | // Permissions are imported lazily - act as thought we're checking an install, |
michael@0 | 45 | // to trigger on-deman importing of the permissions. |
michael@0 | 46 | let url = Services.io.newURI("http://example.com/file.xpi", null, null); |
michael@0 | 47 | AddonManager.isInstallAllowed("application/x-xpinstall", url); |
michael@0 | 48 | do_check_permission_prefs(preferences); |
michael@0 | 49 | |
michael@0 | 50 | |
michael@0 | 51 | // Import can also be triggerred by an observer notification by any other area |
michael@0 | 52 | // of code, such as a permissions management UI. |
michael@0 | 53 | |
michael@0 | 54 | // First, request to flush all permissions |
michael@0 | 55 | clear_imported_preferences_cache(); |
michael@0 | 56 | Services.prefs.setCharPref("xpinstall.whitelist.add.TEST2", "whitelist2.example.com"); |
michael@0 | 57 | Services.obs.notifyObservers(null, "flush-pending-permissions", "install"); |
michael@0 | 58 | do_check_permission_prefs(preferences); |
michael@0 | 59 | |
michael@0 | 60 | // Then, request to flush just install permissions |
michael@0 | 61 | clear_imported_preferences_cache(); |
michael@0 | 62 | Services.prefs.setCharPref("xpinstall.whitelist.add.TEST3", "whitelist3.example.com"); |
michael@0 | 63 | Services.obs.notifyObservers(null, "flush-pending-permissions", ""); |
michael@0 | 64 | do_check_permission_prefs(preferences); |
michael@0 | 65 | |
michael@0 | 66 | // And a request to flush some other permissions sholdn't flush install permissions |
michael@0 | 67 | clear_imported_preferences_cache(); |
michael@0 | 68 | Services.prefs.setCharPref("xpinstall.whitelist.add.TEST4", "whitelist4.example.com"); |
michael@0 | 69 | Services.obs.notifyObservers(null, "flush-pending-permissions", "lolcats"); |
michael@0 | 70 | do_check_eq(Services.prefs.getCharPref("xpinstall.whitelist.add.TEST4"), "whitelist4.example.com"); |
michael@0 | 71 | } |