test_migrateCookieLifetimePref.js (3209B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 /* 5 Tests that 6 - the migration code runs, 7 - the sanitize on shutdown prefs for profiles with the network.cookie.lifetimePolicy enabled are set to true, 8 - the previous settings for clearOnShutdown prefs will not be applied due to sanitizeOnShutdown being disabled 9 - the network.cookie.lifetimePolicy is disabled afterwards. 10 */ 11 add_task(async function migrateSanitizationPrefsClearCleaningPrefs() { 12 // Former network.cookie.lifetimePolicy values ACCEPT_SESSION/ACCEPT_NORMALLY are not available anymore 13 // 2 = ACCEPT_SESSION 14 Services.prefs.setIntPref("network.cookie.lifetimePolicy", 2); 15 Services.prefs.setBoolPref("privacy.sanitize.sanitizeOnShutdown", false); 16 Services.prefs.setBoolPref("privacy.clearOnShutdown.cache", false); 17 Services.prefs.setBoolPref("privacy.clearOnShutdown.cookies", false); 18 Services.prefs.setBoolPref("privacy.clearOnShutdown.offlineApps", false); 19 Services.prefs.setBoolPref("privacy.clearOnShutdown.downloads", true); 20 Services.prefs.setBoolPref("privacy.clearOnShutdown.sessions", true); 21 22 // Set the new clear on shutdown prefs 23 Services.prefs.setBoolPref( 24 "privacy.clearOnShutdown_v2.cookiesAndStorage", 25 false 26 ); 27 Services.prefs.setBoolPref("privacy.clearOnShutdown_v2.cache", false); 28 Services.prefs.setBoolPref( 29 "privacy.clearOnShutdown_v2.browsingHistoryAndDownloads", 30 true 31 ); 32 33 // The migration code is called in cookieService::Init 34 Services.cookies; 35 36 // Former network.cookie.lifetimePolicy values ACCEPT_SESSION/ACCEPT_NORMALLY are not available anymore 37 // 0 = ACCEPT_NORMALLY 38 Assert.equal( 39 Services.prefs.getIntPref("network.cookie.lifetimePolicy", 0), 40 0, 41 "Cookie lifetime policy is off" 42 ); 43 44 Assert.ok( 45 Services.prefs.getBoolPref("privacy.sanitize.sanitizeOnShutdown"), 46 "Sanitize on shutdown is set" 47 ); 48 49 Assert.ok( 50 Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies"), 51 "Clearing cookies on shutdown is selected" 52 ); 53 54 Assert.ok( 55 Services.prefs.getBoolPref("privacy.clearOnShutdown.cache"), 56 "Clearing cache on shutdown is still selected" 57 ); 58 59 Assert.ok( 60 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cache"), 61 "Clearing cache on shutdown (v2) is still selected" 62 ); 63 64 Assert.ok( 65 Services.prefs.getBoolPref("privacy.clearOnShutdown.offlineApps"), 66 "Clearing offline apps on shutdown is selected" 67 ); 68 69 Assert.ok( 70 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"), 71 "Clearing cookies and storage (v2) on shutdown is selected" 72 ); 73 74 Assert.ok( 75 !Services.prefs.getBoolPref("privacy.clearOnShutdown.downloads"), 76 "Clearing downloads on shutdown is not set anymore" 77 ); 78 79 Assert.ok( 80 !Services.prefs.getBoolPref( 81 "privacy.clearOnShutdown_v2.browsingHistoryAndDownloads" 82 ), 83 "Clearing browsing history and downloads (v2) on shutdown is not set anymore" 84 ); 85 86 Assert.ok( 87 !Services.prefs.getBoolPref("privacy.clearOnShutdown.sessions"), 88 "Clearing active logins on shutdown is not set anymore" 89 ); 90 91 Services.prefs.resetPrefs(); 92 93 delete Services.cookies; 94 });