browser_hwconcurrency_popups_aboutblank.js (3318B)
1 /** 2 * This test only tests values in an about:blank document that opened in a popup 3 * Because there is no interaction with a third party domain, there's a lot fewer tests 4 * 5 * Covers the following cases: 6 * - RFP is disabled entirely 7 * - RFP is enabled entirely 8 * - FPP is enabled entirely 9 10 * 11 * - (A) RFP is exempted on the popup maker 12 * - (E) RFP is not exempted on the popup maker 13 * 14 */ 15 16 "use strict"; 17 18 const SPOOFED_HW_CONCURRENCY = 19 SpecialPowers.Services.appinfo.OS == "Darwin" ? 8 : 4; 20 21 const DEFAULT_HARDWARE_CONCURRENCY = navigator.hardwareConcurrency; 22 23 // ============================================================================================= 24 // ============================================================================================= 25 26 async function testHWConcurrency(result, expectedResults, extraData) { 27 let testDesc = extraData.testDesc; 28 29 is( 30 result.hardwareConcurrency, 31 expectedResults.hardwareConcurrency, 32 `Checking ${testDesc} navigator.hardwareConcurrency.` 33 ); 34 } 35 36 add_setup(async function () { 37 await SpecialPowers.pushPrefEnv({ 38 set: [ 39 ["privacy.fingerprintingProtection.overrides", "+NavigatorHWConcurrency"], 40 ], 41 }); 42 registerCleanupFunction(async function () { 43 Services.prefs.clearUserPref( 44 "privacy.trackingprotection.allow_list.hasUserInteractedWithETPSettings" 45 ); 46 }); 47 }); 48 49 // The following are convenience objects that allow you to quickly see what is 50 // and is not modified from a logical set of values. 51 // Be sure to always use `let expectedResults = structuredClone(allNotSpoofed)` to do a 52 // deep copy and avoiding corrupting the original 'const' object 53 const allNotSpoofed = { 54 hardwareConcurrency: DEFAULT_HARDWARE_CONCURRENCY, 55 }; 56 const allSpoofed = { 57 hardwareConcurrency: SPOOFED_HW_CONCURRENCY, 58 }; 59 60 const uri = `https://${FRAMER_DOMAIN}/browser/browser/components/resistfingerprinting/test/browser/file_hwconcurrency_aboutblank_popupmaker.html`; 61 62 requestLongerTimeout(2); 63 64 let expectedResults = {}; 65 66 expectedResults = structuredClone(allNotSpoofed); 67 add_task(defaultsTest.bind(null, uri, testHWConcurrency, expectedResults)); 68 69 expectedResults = structuredClone(allSpoofed); 70 add_task(simpleRFPTest.bind(null, uri, testHWConcurrency, expectedResults)); 71 72 // Test a private window with RFP enabled in PBMode 73 expectedResults = structuredClone(allSpoofed); 74 add_task(simplePBMRFPTest.bind(null, uri, testHWConcurrency, expectedResults)); 75 76 expectedResults = structuredClone(allSpoofed); 77 add_task(simpleFPPTest.bind(null, uri, testHWConcurrency, expectedResults)); 78 79 // Test a Private Window with FPP Enabled in PBM 80 expectedResults = structuredClone(allSpoofed); 81 add_task(simplePBMFPPTest.bind(null, uri, testHWConcurrency, expectedResults)); 82 83 // (A) RFP is exempted on the popup maker 84 expectedResults = structuredClone(allNotSpoofed); 85 add_task(testA.bind(null, uri, testHWConcurrency, expectedResults)); 86 87 // (E) RFP is not exempted on the popup maker 88 expectedResults = structuredClone(allSpoofed); 89 add_task(testE.bind(null, uri, testHWConcurrency, expectedResults)); 90 91 // Test RFP Enabled in PBM and FPP enabled in Normal Browsing Mode 92 expectedResults = structuredClone(allNotSpoofed); 93 add_task( 94 RFPPBMFPP_NormalMode_NoProtectionsTest.bind( 95 null, 96 uri, 97 testHWConcurrency, 98 expectedResults 99 ) 100 );