browser_hwconcurrency_iframes_aboutsrcdoc.js (5482B)
1 /** 2 * This test only tests values in an about:srcdoc document that is created by the iframe, it does not test them on the framer 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 framer and framee and (if needed) on another cross-origin domain 11 * - (B) RFP is exempted on the framer and framee but is not on another (if needed) cross-origin domain 12 * - (C) RFP is exempted on the framer and (if needed) on another cross-origin domain, but not the framee 13 * - (D) RFP is exempted on the framer but not the framee nor another (if needed) cross-origin domain 14 * - (E) RFP is not exempted on the framer nor the framee but (if needed) is exempted on another cross-origin domain 15 * - (F) RFP is not exempted on the framer nor the framee nor another (if needed) cross-origin domain 16 * - (G) RFP is not exempted on the framer but is on the framee and (if needed) on another cross-origin domain 17 * - (H) RFP is not exempted on the framer nor another (if needed) cross-origin domain but is on the framee 18 * 19 */ 20 21 "use strict"; 22 23 const SPOOFED_HW_CONCURRENCY = 24 SpecialPowers.Services.appinfo.OS == "Darwin" ? 8 : 4; 25 26 const DEFAULT_HARDWARE_CONCURRENCY = navigator.hardwareConcurrency; 27 28 // ============================================================================================= 29 // ============================================================================================= 30 31 async function testHWConcurrency(result, expectedResults, extraData) { 32 let testDesc = extraData.testDesc; 33 34 is( 35 result.hardwareConcurrency, 36 expectedResults.hardwareConcurrency, 37 `Checking ${testDesc} navigator.hardwareConcurrency.` 38 ); 39 } 40 41 add_setup(async function () { 42 await SpecialPowers.pushPrefEnv({ 43 set: [ 44 ["privacy.fingerprintingProtection.overrides", "+NavigatorHWConcurrency"], 45 ], 46 }); 47 registerCleanupFunction(async function () { 48 Services.prefs.clearUserPref( 49 "privacy.trackingprotection.allow_list.hasUserInteractedWithETPSettings" 50 ); 51 }); 52 }); 53 54 // The following are convenience objects that allow you to quickly see what is 55 // and is not modified from a logical set of values. 56 // Be sure to always use `let expectedResults = structuredClone(allNotSpoofed)` to do a 57 // deep copy and avoiding corrupting the original 'const' object 58 const allNotSpoofed = { 59 hardwareConcurrency: DEFAULT_HARDWARE_CONCURRENCY, 60 }; 61 const allSpoofed = { 62 hardwareConcurrency: SPOOFED_HW_CONCURRENCY, 63 }; 64 65 const uri = `https://${FRAMER_DOMAIN}/browser/browser/components/resistfingerprinting/test/browser/file_hwconcurrency_aboutsrcdoc_iframer.html`; 66 67 requestLongerTimeout(2); 68 69 let expectedResults = {}; 70 71 expectedResults = structuredClone(allNotSpoofed); 72 add_task(defaultsTest.bind(null, uri, testHWConcurrency, expectedResults)); 73 74 expectedResults = structuredClone(allSpoofed); 75 add_task(simpleRFPTest.bind(null, uri, testHWConcurrency, expectedResults)); 76 77 // Test a private window with RFP enabled in PBMode 78 expectedResults = structuredClone(allSpoofed); 79 add_task(simplePBMRFPTest.bind(null, uri, testHWConcurrency, expectedResults)); 80 81 expectedResults = structuredClone(allSpoofed); 82 add_task(simpleFPPTest.bind(null, uri, testHWConcurrency, expectedResults)); 83 84 // Test a Private Window with FPP Enabled in PBM 85 expectedResults = structuredClone(allSpoofed); 86 add_task(simplePBMFPPTest.bind(null, uri, testHWConcurrency, expectedResults)); 87 88 // (A) RFP is exempted on the framer and framee and (if needed) on another cross-origin domain 89 expectedResults = structuredClone(allNotSpoofed); 90 add_task(testA.bind(null, uri, testHWConcurrency, expectedResults)); 91 92 // (B) RFP is exempted on the framer and framee but is not on another (if needed) cross-origin domain 93 expectedResults = structuredClone(allNotSpoofed); 94 add_task(testB.bind(null, uri, testHWConcurrency, expectedResults)); 95 96 // (C) RFP is exempted on the framer and (if needed) on another cross-origin domain, but not the framee 97 expectedResults = structuredClone(allSpoofed); 98 add_task(testC.bind(null, uri, testHWConcurrency, expectedResults)); 99 100 // (D) RFP is exempted on the framer but not the framee nor another (if needed) cross-origin domain 101 expectedResults = structuredClone(allSpoofed); 102 add_task(testD.bind(null, uri, testHWConcurrency, expectedResults)); 103 104 // (E) RFP is not exempted on the framer nor the framee but (if needed) is exempted on another cross-origin domain 105 expectedResults = structuredClone(allSpoofed); 106 add_task(testE.bind(null, uri, testHWConcurrency, expectedResults)); 107 108 // (F) RFP is not exempted on the framer nor the framee nor another (if needed) cross-origin domain 109 expectedResults = structuredClone(allSpoofed); 110 add_task(testF.bind(null, uri, testHWConcurrency, expectedResults)); 111 112 // (G) RFP is not exempted on the framer but is on the framee and (if needed) on another cross-origin domain 113 expectedResults = structuredClone(allSpoofed); 114 add_task(testG.bind(null, uri, testHWConcurrency, expectedResults)); 115 116 // (H) RFP is not exempted on the framer nor another (if needed) cross-origin domain but is on the framee 117 expectedResults = structuredClone(allSpoofed); 118 add_task(testH.bind(null, uri, testHWConcurrency, expectedResults)); 119 120 // Test RFP Enabled in PBM and FPP enabled in Normal Browsing Mode 121 expectedResults = structuredClone(allNotSpoofed); 122 add_task( 123 RFPPBMFPP_NormalMode_NoProtectionsTest.bind( 124 null, 125 uri, 126 testHWConcurrency, 127 expectedResults 128 ) 129 );