browser_statePartitioning_strings.js (2619B)
1 "use strict"; 2 3 /* Any copyright is dedicated to the Public Domain. 4 * http://creativecommons.org/publicdomain/zero/1.0/ */ 5 6 const CB_STRICT_FEATURES_PREF = "browser.contentblocking.features.strict"; 7 const CB_STRICT_FEATURES_VALUE = 8 "tp,tpPrivate,cookieBehavior5,cryptoTP,fp,stp,lvl2"; 9 const FPI_PREF = "privacy.firstparty.isolate"; 10 const COOKIE_BEHAVIOR_PREF = "network.cookie.cookieBehavior"; 11 const COOKIE_BEHAVIOR_VALUE = 5; 12 13 async function testStrings() { 14 await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true }); 15 16 let doc = gBrowser.contentDocument; 17 18 // Check the cookie blocking info strings 19 let elts = doc.querySelectorAll( 20 ".extra-information-label.cross-site-cookies-option" 21 ); 22 for (let elt of elts) { 23 ok(!elt.hidden, "The new cross-site cookies info label is visible"); 24 } 25 26 // Check the learn more strings 27 elts = doc.querySelectorAll(".content-blocking-warning-description"); 28 for (let elt of elts) { 29 let id = doc.l10n.getAttributes(elt).id; 30 is( 31 id, 32 "content-blocking-and-isolating-etp-warning-description-4", 33 "The correct warning description string is in use" 34 ); 35 } 36 37 // Check the cookie blocking mode menu option string 38 let elt = doc.querySelector("#isolateCookiesSocialMedia"); 39 let id = doc.l10n.getAttributes(elt).id; 40 is( 41 id, 42 "sitedata-option-block-cross-site-cookies2", 43 "The correct string is in use for the cookie blocking option" 44 ); 45 46 // Check the FPI warning is hidden with FPI off 47 let warningElt = doc.getElementById("fpiIncompatibilityWarning"); 48 is(warningElt.hidden, true, "The FPI warning is hidden"); 49 50 gBrowser.removeCurrentTab(); 51 52 // Check the FPI warning is shown only if MVP UI is enabled when FPI is on 53 await SpecialPowers.pushPrefEnv({ set: [[FPI_PREF, true]] }); 54 await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true }); 55 doc = gBrowser.contentDocument; 56 warningElt = doc.getElementById("fpiIncompatibilityWarning"); 57 ok(!warningElt.hidden, `The FPI warning is visible`); 58 await SpecialPowers.popPrefEnv(); 59 60 gBrowser.removeCurrentTab(); 61 } 62 63 add_task(async function runTests() { 64 await SpecialPowers.pushPrefEnv({ 65 set: [ 66 [CB_STRICT_FEATURES_PREF, CB_STRICT_FEATURES_VALUE], 67 [FPI_PREF, false], 68 ], 69 }); 70 let defaults = Services.prefs.getDefaultBranch(""); 71 let originalCookieBehavior = defaults.getIntPref(COOKIE_BEHAVIOR_PREF); 72 defaults.setIntPref(COOKIE_BEHAVIOR_PREF, COOKIE_BEHAVIOR_VALUE); 73 registerCleanupFunction(() => { 74 defaults.setIntPref(COOKIE_BEHAVIOR_PREF, originalCookieBehavior); 75 }); 76 77 await testStrings(); 78 });