diff --git a/browser/components/resistfingerprinting/test/browser/browser.toml b/browser/components/resistfingerprinting/test/browser/browser.toml
index b58c57d98ded..91ea98a6a550 100644
--- a/browser/components/resistfingerprinting/test/browser/browser.toml
+++ b/browser/components/resistfingerprinting/test/browser/browser.toml
@@ -8,6 +8,7 @@ support-files = [
"file_keyBoardEvent.sjs",
"file_navigator.html",
"file_navigator.worker.js",
+ "file_workerNetInfo.js",
"file_workerPerformance.js",
"head.js",
"file_canvascompare_aboutblank_iframee.html",
@@ -80,8 +81,6 @@ https_first_disabled = true
["browser_canvascompare_popups_data.js"]
-["browser_color_scheme.js"]
-
["browser_cross_origin_isolated_animation_api.js"]
["browser_cross_origin_isolated_performance_api.js"]
@@ -138,6 +137,9 @@ https_first_disabled = true
["browser_navigator_iframes.js"]
https_first_disabled = true
+["browser_netInfo.js"]
+https_first_disabled = true
+
["browser_performanceAPI.js"]
["browser_performanceAPIWorkers.js"]
@@ -158,3 +160,5 @@ https_first_disabled = true
["browser_spoofing_keyboard_event.js"]
["browser_timezone.js"]
+
+["browser_color_scheme.js"]
diff --git a/browser/components/resistfingerprinting/test/browser/browser_navigator.js b/browser/components/resistfingerprinting/test/browser/browser_navigator.js
index f9c2e763639b..d7f8c4ad69f9 100644
--- a/browser/components/resistfingerprinting/test/browser/browser_navigator.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_navigator.js
@@ -346,7 +346,6 @@ add_task(async function setupRFPExemptions() {
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.exemptedDomains", "example.net"],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
],
});
@@ -442,10 +441,7 @@ add_task(async function setupETPToggleExemptions() {
add_task(async function setupResistFingerprinting() {
await SpecialPowers.pushPrefEnv({
- set: [
- ["privacy.resistFingerprinting", true],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
- ],
+ set: [["privacy.resistFingerprinting", true]],
});
let spoofedGeckoTrail = SPOOFED_UA_GECKO_TRAIL[AppConstants.platform];
diff --git a/browser/components/resistfingerprinting/test/browser/browser_netInfo.js b/browser/components/resistfingerprinting/test/browser/browser_netInfo.js
new file mode 100644
index 000000000000..c91caa5bc3f1
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/browser/browser_netInfo.js
@@ -0,0 +1,64 @@
+/**
+ * Bug 1372072 - A test case for check whether network information API has been
+ * spoofed correctly when 'privacy.resistFingerprinting' is true;
+ */
+
+async function testWindow() {
+ // Open a tab to test network information in a content.
+ let tab = await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ TEST_PATH + "file_dummy.html"
+ );
+
+ await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
+ ok("connection" in content.navigator, "navigator.connection should exist");
+
+ is(
+ content.navigator.connection.type,
+ "unknown",
+ "The connection type is spoofed correctly"
+ );
+ });
+
+ BrowserTestUtils.removeTab(tab);
+}
+
+async function testWorker() {
+ // Open a tab to test network information in a worker.
+ let tab = await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ TEST_PATH + "file_dummy.html"
+ );
+
+ await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
+ await new Promise(resolve => {
+ let worker = new content.Worker("file_workerNetInfo.js");
+
+ worker.onmessage = function (e) {
+ if (e.data.type == "status") {
+ ok(e.data.status, e.data.msg);
+ } else if (e.data.type == "finish") {
+ resolve();
+ } else {
+ ok(false, "Unknown message type");
+ resolve();
+ }
+ };
+ worker.postMessage({ type: "runTests" });
+ });
+ });
+
+ BrowserTestUtils.removeTab(tab);
+}
+
+add_task(async function runTest() {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["privacy.resistFingerprinting", true],
+ ["dom.netinfo.enabled", true],
+ ],
+ });
+
+ await testWindow();
+ await testWorker();
+});
diff --git a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js
index 603b7bd2454d..ea22c7fa2013 100644
--- a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js
@@ -34,24 +34,23 @@ add_task(async function test_new_window() {
tab.linkedBrowser,
[{ gMaxAvailWidth, gMaxAvailHeight }],
async function (input) {
- let windowWaived = content.wrappedJSObject.window;
is(
- windowWaived.screen.width,
+ content.screen.width,
input.gMaxAvailWidth,
"The screen.width has a correct rounded value"
);
is(
- windowWaived.screen.height,
+ content.screen.height,
input.gMaxAvailHeight,
"The screen.height has a correct rounded value"
);
is(
- windowWaived.innerWidth,
+ content.innerWidth,
input.gMaxAvailWidth,
"The window.innerWidth has a correct rounded value"
);
is(
- windowWaived.innerHeight,
+ content.innerHeight,
input.gMaxAvailHeight,
"The window.innerHeight has a correct rounded value"
);
diff --git a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_max_inner.js b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_max_inner.js
index 48a408345c97..d7bff8c84f73 100644
--- a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_max_inner.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_max_inner.js
@@ -7,27 +7,23 @@
let targetWidth = Services.prefs.getIntPref("privacy.window.maxInnerWidth");
let targetHeight = Services.prefs.getIntPref("privacy.window.maxInnerHeight");
-OpenTest.run(
- [
- {
- settingWidth: targetWidth + 25,
- settingHeight: targetHeight + 50,
- targetWidth,
- targetHeight,
- },
- {
- settingWidth: 9999,
- settingHeight: 9999,
- targetWidth,
- targetHeight,
- },
- {
- settingWidth: targetWidth - 1,
- settingHeight: targetHeight - 1,
- targetWidth,
- targetHeight,
- },
- ],
- undefined,
- [["privacy.resistFingerprinting.principalCheckEnabled", false]]
-);
+OpenTest.run([
+ {
+ settingWidth: targetWidth + 25,
+ settingHeight: targetHeight + 50,
+ targetWidth,
+ targetHeight,
+ },
+ {
+ settingWidth: 9999,
+ settingHeight: 9999,
+ targetWidth,
+ targetHeight,
+ },
+ {
+ settingWidth: targetWidth - 1,
+ settingHeight: targetHeight - 1,
+ targetWidth,
+ targetHeight,
+ },
+]);
diff --git a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_mid_inner.js b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_mid_inner.js
index 1a459781dfb9..a3a41829e026 100644
--- a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_mid_inner.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_mid_inner.js
@@ -4,27 +4,23 @@
* middle values.
*/
-OpenTest.run(
- [
- {
- settingWidth: 600,
- settingHeight: 600,
- targetWidth: 600,
- targetHeight: 600,
- },
- {
- settingWidth: 599,
- settingHeight: 599,
- targetWidth: 600,
- targetHeight: 600,
- },
- {
- settingWidth: 401,
- settingHeight: 501,
- targetWidth: 600,
- targetHeight: 600,
- },
- ],
- undefined,
- [["privacy.resistFingerprinting.principalCheckEnabled", false]]
-);
+OpenTest.run([
+ {
+ settingWidth: 600,
+ settingHeight: 600,
+ targetWidth: 600,
+ targetHeight: 600,
+ },
+ {
+ settingWidth: 599,
+ settingHeight: 599,
+ targetWidth: 600,
+ targetHeight: 600,
+ },
+ {
+ settingWidth: 401,
+ settingHeight: 501,
+ targetWidth: 600,
+ targetHeight: 600,
+ },
+]);
diff --git a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_min_inner.js b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_min_inner.js
index 95ac7fff6aaa..f016a560ba4e 100644
--- a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_min_inner.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_min_inner.js
@@ -4,21 +4,17 @@
* minimum values.
*/
-OpenTest.run(
- [
- {
- settingWidth: 199,
- settingHeight: 99,
- targetWidth: 200,
- targetHeight: 100,
- },
- {
- settingWidth: 10,
- settingHeight: 10,
- targetWidth: 200,
- targetHeight: 100,
- },
- ],
- undefined,
- [["privacy.resistFingerprinting.principalCheckEnabled", false]]
-);
+OpenTest.run([
+ {
+ settingWidth: 199,
+ settingHeight: 99,
+ targetWidth: 200,
+ targetHeight: 100,
+ },
+ {
+ settingWidth: 10,
+ settingHeight: 10,
+ targetWidth: 200,
+ targetHeight: 100,
+ },
+]);
diff --git a/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js b/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js
index 7dfb3edfc0a6..c070c7485b3b 100644
--- a/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js
@@ -2119,11 +2119,7 @@ function eventConsumer(aEvent) {
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
- set: [
- ["privacy.resistFingerprinting", true],
- // Disable the principal check because synthesizeKey is system privileged.
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
- ],
+ set: [["privacy.resistFingerprinting", true]],
});
});
diff --git a/browser/components/resistfingerprinting/test/mochitest/file_workerNetInfo.js b/browser/components/resistfingerprinting/test/browser/file_workerNetInfo.js
similarity index 100%
rename from browser/components/resistfingerprinting/test/mochitest/file_workerNetInfo.js
rename to browser/components/resistfingerprinting/test/browser/file_workerNetInfo.js
diff --git a/browser/components/resistfingerprinting/test/browser/head.js b/browser/components/resistfingerprinting/test/browser/head.js
index 117a7f426658..8cb63d2b9120 100644
--- a/browser/components/resistfingerprinting/test/browser/head.js
+++ b/browser/components/resistfingerprinting/test/browser/head.js
@@ -555,11 +555,11 @@ async function testWindowSizeSetting(
class RoundedWindowTest {
// testOuter is optional. run() can be invoked with only 1 parameter.
- static run(testCases, testOuter, extraPrefs = []) {
+ static run(testCases, testOuter) {
// "this" is the calling class itself.
// e.g. when invoked by RoundedWindowTest.run(), "this" is "class RoundedWindowTest".
let test = new this(testCases);
- add_task(async () => test.setup(extraPrefs));
+ add_task(async () => test.setup());
add_task(async () => {
if (testOuter == undefined) {
// If testOuter is not given, do tests for both inner and outer.
@@ -575,9 +575,9 @@ class RoundedWindowTest {
this.testCases = testCases;
}
- async setup(extraPrefs) {
+ async setup() {
await SpecialPowers.pushPrefEnv({
- set: [["privacy.resistFingerprinting", true], ...extraPrefs],
+ set: [["privacy.resistFingerprinting", true]],
});
// Calculate the popup window's chrome UI size for tests of outerWidth/Height.
@@ -668,15 +668,7 @@ async function runActualTest(uri, testFunction, expectedResults, extraData) {
browserWin = openedWin.gBrowser;
}
- // This is hacky, but since we added IsJSContextCurrentlyChromePrivileged(),
- // we ended up disabling RFP for this tab because the test suite
- // has the system principal when it opens it. So we disable the
- // principal check for a brief moment.
- await SpecialPowers.pushPrefEnv({
- set: [["privacy.resistFingerprinting.principalCheckEnabled", false]],
- });
let tab = await BrowserTestUtils.openNewForegroundTab(browserWin, uri);
- await SpecialPowers.popPrefEnv();
if ("etp_reload" in extraData) {
ContentBlockingAllowList.add(tab.linkedBrowser);
@@ -710,13 +702,11 @@ async function runActualTest(uri, testFunction, expectedResults, extraData) {
tab.linkedBrowser,
[IFRAME_DOMAIN, CROSS_ORIGIN_DOMAIN, filterExtraData(extraData)],
async function (iframe_domain_, cross_origin_domain_, extraData_) {
- return content.wrappedJSObject.eval(`
- runTheTest(
- ${JSON.stringify(iframe_domain_)},
- ${JSON.stringify(cross_origin_domain_)},
- ${JSON.stringify(extraData_)}
- );
- `);
+ return content.wrappedJSObject.runTheTest(
+ iframe_domain_,
+ cross_origin_domain_,
+ extraData_
+ );
}
);
@@ -731,7 +721,7 @@ async function runActualTest(uri, testFunction, expectedResults, extraData) {
popup_tab.linkedBrowser,
[],
async function () {
- let r = content.wrappedJSObject.eval("give_result()");
+ let r = content.wrappedJSObject.give_result();
return r;
}
);
diff --git a/browser/components/resistfingerprinting/test/mochitest/mochitest.toml b/browser/components/resistfingerprinting/test/mochitest/mochitest.toml
index 3008a462ef85..328ce6eae897 100644
--- a/browser/components/resistfingerprinting/test/mochitest/mochitest.toml
+++ b/browser/components/resistfingerprinting/test/mochitest/mochitest.toml
@@ -4,7 +4,6 @@ tags = "resistfingerprinting"
support-files = [
"file_animation_api.html",
- "file_workerNetInfo.js",
"worker_child.js",
"worker_grandchild.js",
"!/dom/tests/mochitest/geolocation/network_geolocation.sjs",
@@ -19,8 +18,6 @@ support-files = ["decode_error.mp4"]
["test_bug1382499_touch_api.html"]
-["test_bug1885101_screenwindow_sizes.html"]
-
["test_device_sensor_event.html"]
["test_geolocation.html"]
@@ -32,11 +29,10 @@ support-files = ["test_hide_gamepad_info_iframe.html"]
["test_keyboard_event.html"]
-["test_netInfo.html"]
-https_first_disabled = true
-
["test_pointer_event.html"]
support-files = ["../../../../../dom/events/test/pointerevents/mochitest_support_external.js"]
["test_speech_synthesis.html"]
skip-if = ["verify"]
+
+["test_bug1885101_screenwindow_sizes.html"]
diff --git a/browser/components/resistfingerprinting/test/mochitest/test_netInfo.html b/browser/components/resistfingerprinting/test/mochitest/test_netInfo.html
deleted file mode 100644
index ad6799175fd9..000000000000
--- a/browser/components/resistfingerprinting/test/mochitest/test_netInfo.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
diff --git a/browser/components/resistfingerprinting/test/mochitest/test_speech_synthesis.html b/browser/components/resistfingerprinting/test/mochitest/test_speech_synthesis.html
index f64e46d9f4ed..a1778a0a0d43 100644
--- a/browser/components/resistfingerprinting/test/mochitest/test_speech_synthesis.html
+++ b/browser/components/resistfingerprinting/test/mochitest/test_speech_synthesis.html
@@ -21,10 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1333641
isnot(window.speechSynthesis.getVoices().length, 0, "Voices added");
SimpleTest.waitForFocus(() => {
SpecialPowers.pushPrefEnv({"set":
- [
- ["privacy.resistFingerprinting", true],
- ["privacy.resistFingerprinting.principalCheckEnabled", false]
- ],
+ [["privacy.resistFingerprinting", true]],
}, doGetVoicesTest);
}, window);
}, {once: true});
diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp
index 3479a0638f0c..06a45b3b7c9c 100644
--- a/dom/base/ChromeUtils.cpp
+++ b/dom/base/ChromeUtils.cpp
@@ -2367,13 +2367,8 @@ bool ChromeUtils::ShouldResistFingerprinting(
// This global object appears to be the global window, not for individual
// sites so to exempt individual sites (instead of just PBM/Not-PBM windows)
// more work would be needed to get the correct context.
- // We set aSkipChromePrincipalCheck to true because ChromeUtils is only
- // called from chrome code where we are system principal.
- // We only want to check document's properties and not JS context's
- // properties.
return nsRFPService::IsRFPEnabledFor(isPBM, target,
- overriddenFingerprintingSettings,
- /* aSkipChromePrincipalCheck */ true);
+ overriddenFingerprintingSettings);
}
/* static */
diff --git a/toolkit/components/cleardata/tests/unit/test_fingerprinting_protection_state.js b/toolkit/components/cleardata/tests/unit/test_fingerprinting_protection_state.js
index eaa4839263da..39b39326353b 100644
--- a/toolkit/components/cleardata/tests/unit/test_fingerprinting_protection_state.js
+++ b/toolkit/components/cleardata/tests/unit/test_fingerprinting_protection_state.js
@@ -8,10 +8,6 @@ do_get_profile();
add_task(async function test_clear_fingerprinting_protection_state() {
info("Enabling fingerprinting randomization");
Services.prefs.setBoolPref("privacy.resistFingerprinting", true);
- Services.prefs.setBoolPref(
- "privacy.resistFingerprinting.principalCheckEnabled",
- false
- );
let uri = Services.io.newURI("https://example.com");
let principal = Services.scriptSecurityManager.createContentPrincipal(
@@ -163,19 +159,12 @@ add_task(async function test_clear_fingerprinting_protection_state() {
);
Services.prefs.clearUserPref("privacy.resistFingerprinting");
- Services.prefs.clearUserPref(
- "privacy.resistFingerprinting.principalCheckEnabled"
- );
});
add_task(
async function test_clear_fingerprinting_protection_state_by_site_and_pattern() {
info("Enabling fingerprinting randomization");
Services.prefs.setBoolPref("privacy.resistFingerprinting", true);
- Services.prefs.setBoolPref(
- "privacy.resistFingerprinting.principalCheckEnabled",
- false
- );
let uri = Services.io.newURI("https://example.com");
let principal = Services.scriptSecurityManager.createContentPrincipal(
@@ -256,8 +245,5 @@ add_task(
);
Services.prefs.clearUserPref("privacy.resistFingerprinting");
- Services.prefs.clearUserPref(
- "privacy.resistFingerprinting.principalCheckEnabled"
- );
}
);
diff --git a/toolkit/components/resistfingerprinting/nsRFPService.cpp b/toolkit/components/resistfingerprinting/nsRFPService.cpp
index 3f5435c10ad5..56813fef8879 100644
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -313,7 +313,7 @@ bool nsRFPService::IsRFPEnabledFor(
}
#endif
- if (!aSkipChromePrincipalCheck && IsJSContextCurrentlyChromePrivileged()) {
+ if (IsJSContextCurrentlyChromePrivileged()) {
return false;
}
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js
index 78da5b67a2c7..c398d045b692 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js
@@ -424,7 +424,6 @@ async function runTest(enabled) {
["privacy.fingerprintingProtection.pbmode", true],
["privacy.fingerprintingProtection.overrides", RFPOverrides],
["privacy.resistFingerprinting", false],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
],
});
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js
index 9512d4c4188f..37c112175aea 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js
@@ -170,7 +170,6 @@ async function runTest(enabled) {
["privacy.fingerprintingProtection.pbmode", true],
["privacy.fingerprintingProtection.overrides", RFPOverrides],
["privacy.resistFingerprinting", false],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
],
});
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprinting_randomization_key.js b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprinting_randomization_key.js
index f07d018ddec0..fc0adc03fa1e 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprinting_randomization_key.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprinting_randomization_key.js
@@ -213,10 +213,7 @@ add_task(async function test_randomization_disabled_with_rfp_disabled() {
// Test the fingerprinting randomization key generation.
add_task(async function test_generate_randomization_key() {
await SpecialPowers.pushPrefEnv({
- set: [
- ["privacy.resistFingerprinting", true],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
- ],
+ set: [["privacy.resistFingerprinting", true]],
});
for (let testPrivateWin of [true, false]) {
@@ -307,10 +304,7 @@ add_task(async function test_generate_randomization_key() {
// ends.
add_task(async function test_reset_key_after_pbm_session_ends() {
await SpecialPowers.pushPrefEnv({
- set: [
- ["privacy.resistFingerprinting", true],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
- ],
+ set: [["privacy.resistFingerprinting", true]],
});
let privateWin = await BrowserTestUtils.openNewBrowserWindow({
@@ -368,7 +362,6 @@ add_task(async function test_randomization_with_exempted_normal_window() {
["privacy.resistFingerprinting.pbmode", true],
["privacy.fingerprintingProtection", false],
["privacy.fingerprintingProtection.pbmode", false],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
],
});
@@ -433,10 +426,7 @@ add_task(async function test_randomization_with_exempted_normal_window() {
add_task(async function test_reset_random_key_when_clear_site_data() {
// Enable fingerprinting randomization key generation.
await SpecialPowers.pushPrefEnv({
- set: [
- ["privacy.resistFingerprinting", true],
- ["privacy.resistFingerprinting.principalCheckEnabled", false],
- ],
+ set: [["privacy.resistFingerprinting", true]],
});
// Open a tab and get randomization key from the test domain.