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