browser_hwconcurrency_popups_data_noopener.js (3776B)
1 /** 2 * This test only tests values in a data document that is opened in a popup with noopener 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_data_popupmaker.html?submode=noopener`; 61 const await_uri = loadedURL => loadedURL.startsWith("data:"); 62 63 requestLongerTimeout(2); 64 65 let extraData = { 66 noopener: true, 67 await_uri, 68 }; 69 70 let expectedResults = {}; 71 72 expectedResults = structuredClone(allNotSpoofed); 73 add_task( 74 defaultsTest.bind(null, uri, testHWConcurrency, expectedResults, extraData) 75 ); 76 77 expectedResults = structuredClone(allSpoofed); 78 add_task( 79 simpleRFPTest.bind(null, uri, testHWConcurrency, expectedResults, extraData) 80 ); 81 82 // Test a private window with RFP enabled in PBMode 83 expectedResults = structuredClone(allSpoofed); 84 add_task( 85 simplePBMRFPTest.bind( 86 null, 87 uri, 88 testHWConcurrency, 89 expectedResults, 90 extraData 91 ) 92 ); 93 94 expectedResults = structuredClone(allSpoofed); 95 add_task( 96 simpleFPPTest.bind(null, uri, testHWConcurrency, expectedResults, extraData) 97 ); 98 99 // Test a Private Window with FPP Enabled in PBM 100 expectedResults = structuredClone(allSpoofed); 101 add_task( 102 simplePBMFPPTest.bind( 103 null, 104 uri, 105 testHWConcurrency, 106 expectedResults, 107 extraData 108 ) 109 ); 110 111 // (A) RFP is exempted on the popup maker 112 // Ordinarily, RFP would be exempted, however because the opener relationship is severed 113 // there is nothing to grant it an exemption, so it is not exempted. 114 expectedResults = structuredClone(allSpoofed); 115 add_task(testA.bind(null, uri, testHWConcurrency, expectedResults, extraData)); 116 117 // (E) RFP is not exempted on the popup maker 118 expectedResults = structuredClone(allSpoofed); 119 add_task(testE.bind(null, uri, testHWConcurrency, expectedResults, extraData)); 120 121 // Test RFP Enabled in PBM and FPP enabled in Normal Browsing Mode 122 expectedResults = structuredClone(allNotSpoofed); 123 add_task( 124 RFPPBMFPP_NormalMode_NoProtectionsTest.bind( 125 null, 126 uri, 127 testHWConcurrency, 128 expectedResults, 129 extraData 130 ) 131 );