Commits:
-
cb394e8a
by Beatriz Rizental at 2026-11-26T17:42:36+01:00
Bug 2078400 - Also disable HTTPS-First in private browsing for https_first_disabled tests. r=florian
Differential Revision: https://phabricator.services.mozilla.com/D330913
-
bb0db042
by Beatriz Rizental at 2026-11-26T17:42:36+01:00
fixup! BB 45120: Add tests for Base Browser
1. Set private.resistFingerprinting=false in the RFP test manifests.
These are upstream tests and expect this to be false. In order to
avoid having to deal with this issue test-by-test we do it in the
manifest instead.
2. Add the base-browser tag to browser/components/resistfingerprinting
mochitests. This makes them run on the Nightly CI.
3. Disable any tests that do not make sense for base-browser.
-
99f33fe1
by Beatriz Rizental at 2026-11-26T17:42:36+01:00
fixup! BB 45120: Add tests for Base Browser
Handle final preference and environment assumptions that
are true upstream, but not true downstream.
-
75ab052a
by Beatriz Rizental at 2026-11-26T17:42:36+01:00
Bug 2089752 - Refresh the RTP caller type of JS sandboxes when RFP prefs change. r=timhuang,mccr8
Sandbox realms cache their RTP caller type when they are created, so it
went stale if the fingerprinting protection prefs changed afterwards, and
Date.now() and friends in the sandbox kept using the old timer precision.
Differential Revision: https://phabricator.services.mozilla.com/D340217
-
f4ed7999
by Beatriz Rizental at 2026-11-26T17:42:36+01:00
fixup! BB 44045: Disable ML features.
Avoid loading EngineProcess.sys.mjs at startup.
SmartWindowTelemetry, the ONNX runtime availability probe and
MonitorAgent all load the ml component, which is excluded from the
build, and crash the browser on startup.
-
62b59add
by Beatriz Rizental at 2026-11-26T17:42:36+01:00
fixup! BB 45120: Add tests for Base Browser
1. Re-enable browser_navigator_iframes.js. Third-party storage is
rejected, so the SharedWorker constructor in the third-party iframe
throws a SecurityError. Catch it and skip the worker checks instead of
hanging.
2. Re-enable the browser_roundedWindow_open_*_inner.js tests by setting
browser.link.open_newwindow.restriction=2 for them, so window.open
creates sized popup windows instead of tabs.
21 changed files:
Changes:
browser/components/aiwindow/ui/aiwindow.manifest
|
1
|
1
|
category browser-first-window-ready moz-src:///browser/components/aiwindow/ui/modules/AIWindow.sys.mjs AIWindow.onFirstWindowReady
|
|
2
|
|
-category browser-idle-startup moz-src:///browser/components/aiwindow/models/agents/MonitorAgent.sys.mjs MonitorAgent.init
|
|
|
2
|
+# MonitorAgent depends on the ml component, which is excluded. tor-browser#44045.
|
|
3
|
3
|
category browser-quit-application-granted moz-src:///browser/components/aiwindow/ui/modules/AIWindow.sys.mjs AIWindow.uninit
|
|
4
|
|
-category browser-quit-application-granted moz-src:///browser/components/aiwindow/models/agents/MonitorAgent.sys.mjs MonitorAgent.uninit
|
|
5
|
4
|
category browser-window-delayed-startup moz-src:///browser/components/aiwindow/ui/modules/AIWindow.sys.mjs AIWindow.init
|
|
6
|
5
|
category browser-window-unload moz-src:///browser/components/aiwindow/ui/modules/AIWindow.sys.mjs AIWindow.unloadWindow |
browser/components/aiwindow/ui/modules/AIWindow.sys.mjs
| ... |
... |
@@ -210,10 +210,8 @@ export const AIWindow = { |
|
210
|
210
|
ChromeUtils.defineLazyGetter(AIWindow, "chatStore", () => lazy.ChatStore);
|
|
211
|
211
|
Services.obs.addObserver(this, lazy.ONLOGOUT_NOTIFICATION);
|
|
212
|
212
|
Services.obs.addObserver(this, "tabstrip-orientation-change");
|
|
213
|
|
- Services.obs.addObserver(this, "browser-region-updated");
|
|
214
|
|
- Services.prefs.addObserver(PREF_AGENT_SUPPORTED_REGIONS, this);
|
|
215
|
|
- lazy.SmartWindowTelemetry.init();
|
|
216
|
213
|
if (this.isAIWindowEnabled()) {
|
|
|
214
|
+ lazy.SmartWindowTelemetry.init();
|
|
217
|
215
|
// Depends on the ml component, which tor-browser#44045 excludes from
|
|
218
|
216
|
// the build, so only touch it when AI Window is actually enabled.
|
|
219
|
217
|
lazy.getAllModelsData(); // loads model data into cache for about:preferences
|
browser/components/resistfingerprinting/test/browser/browser.toml
|
1
|
1
|
[DEFAULT]
|
|
2
|
|
-tags = "resistfingerprinting"
|
|
|
2
|
+# These tests are written for Firefox, where RFP is disabled by default.
|
|
|
3
|
+prefs = ["privacy.resistFingerprinting=false"]
|
|
|
4
|
+tags = "base-browser resistfingerprinting"
|
|
3
|
5
|
support-files = [
|
|
4
|
6
|
"coop_header.sjs",
|
|
5
|
7
|
"file_dummy.html",
|
| ... |
... |
@@ -61,6 +63,7 @@ support-files = [ |
|
61
|
63
|
|
|
62
|
64
|
["browser_bug1975753_site_specific_zoom_level.js"]
|
|
63
|
65
|
https_first_disabled = true
|
|
|
66
|
+disabled = "With browser.privatebrowsing.autostart all tabs are private, so the zoom is stored in the private content pref store, which deleteDataFromHost does not clear. Not an issue for us: the private store is memory-only and is wiped on New Identity and restart"
|
|
64
|
67
|
|
|
65
|
68
|
["browser_canvas_iframes.js"]
|
|
66
|
69
|
skip-if = [
|
| ... |
... |
@@ -158,6 +161,7 @@ https_first_disabled = true |
|
158
|
161
|
|
|
159
|
162
|
["browser_reduceTimePrecision_iframes.js"]
|
|
160
|
163
|
https_first_disabled = true
|
|
|
164
|
+disabled = "Third-party cookies and storage are rejected (network.cookie.cookieBehavior is 1 in 001-base-profile.js), so the third-party iframe cannot create a SharedWorker and the test hangs"
|
|
161
|
165
|
|
|
162
|
166
|
["browser_roundedWindow_dialogWindow.js"]
|
|
163
|
167
|
|
browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js
| ... |
... |
@@ -375,6 +375,8 @@ async function test_findbar(aWindow) { |
|
375
|
375
|
add_setup(async function () {
|
|
376
|
376
|
await SpecialPowers.pushPrefEnv({
|
|
377
|
377
|
set: [
|
|
|
378
|
+ // In Tor Browser, letterboxing is only active when RFP is enabled.
|
|
|
379
|
+ ["privacy.resistFingerprinting", true],
|
|
378
|
380
|
["privacy.resistFingerprinting.letterboxing", true],
|
|
379
|
381
|
["privacy.resistFingerprinting.letterboxing.testing", true],
|
|
380
|
382
|
],
|
browser/components/resistfingerprinting/test/browser/browser_hwconcurrency_popups_noopener.js
| ... |
... |
@@ -123,8 +123,13 @@ add_task(testE.bind(null, uri, testHWConcurrency, expectedResults, extraData)); |
|
123
|
123
|
// (G) RFP is not exempted on the maker but is on the popup
|
|
124
|
124
|
// Ordinarily, RFP would not be exempted, however because the opener relationship is severed
|
|
125
|
125
|
// it is safe to exempt the popup
|
|
126
|
|
-expectedResults = structuredClone(allNotSpoofed);
|
|
127
|
|
-add_task(testG.bind(null, uri, testHWConcurrency, expectedResults, extraData));
|
|
|
126
|
+//
|
|
|
127
|
+// Disabled: with first-party isolation, the popup inherits the opener's
|
|
|
128
|
+// (non-exempted) cookie jar settings. Base Browser doesn't support RFP
|
|
|
129
|
+// exemptions anyway.
|
|
|
130
|
+//
|
|
|
131
|
+// expectedResults = structuredClone(allNotSpoofed);
|
|
|
132
|
+// add_task(testG.bind(null, uri, testHWConcurrency, expectedResults, extraData));
|
|
128
|
133
|
|
|
129
|
134
|
// Test RFP Enabled in PBM and FPP enabled in Normal Browsing Mode
|
|
130
|
135
|
expectedResults = structuredClone(allNotSpoofed);
|
browser/components/resistfingerprinting/test/browser/browser_navigator.js
| ... |
... |
@@ -347,6 +347,12 @@ async function testWorkerNavigator() { |
|
347
|
347
|
}
|
|
348
|
348
|
|
|
349
|
349
|
add_task(async function setupDefaultUserAgent() {
|
|
|
350
|
+ if (PERMANENT_PRIVATE_BROWSING) {
|
|
|
351
|
+ // Emulate a normal window, where FPP is disabled by default.
|
|
|
352
|
+ await SpecialPowers.pushPrefEnv({
|
|
|
353
|
+ set: [["privacy.fingerprintingProtection.pbmode", false]],
|
|
|
354
|
+ });
|
|
|
355
|
+ }
|
|
350
|
356
|
let defaultUserAgent = `Mozilla/5.0 (${
|
|
351
|
357
|
DEFAULT_UA_OS[AppConstants.platform]
|
|
352
|
358
|
}; rv:${appVersion}.0) Gecko/${
|
| ... |
... |
@@ -368,6 +374,10 @@ add_task(async function setupDefaultUserAgent() { |
|
368
|
374
|
await testUserAgentHeader();
|
|
369
|
375
|
|
|
370
|
376
|
await testWorkerNavigator();
|
|
|
377
|
+
|
|
|
378
|
+ if (PERMANENT_PRIVATE_BROWSING) {
|
|
|
379
|
+ await SpecialPowers.popPrefEnv();
|
|
|
380
|
+ }
|
|
371
|
381
|
});
|
|
372
|
382
|
|
|
373
|
383
|
add_task(async function setupRFPExemptions() {
|
browser/components/resistfingerprinting/test/browser/browser_navigator_iframes.js
| ... |
... |
@@ -228,6 +228,12 @@ async function testNavigator(result, expectedResults, extraData) { |
|
228
|
228
|
"Navigator.vendorSub reports correct constant value."
|
|
229
|
229
|
);
|
|
230
|
230
|
|
|
|
231
|
+ // Third-party iframes cannot create a SharedWorker in Base Browser.
|
|
|
232
|
+ // Skip all the worker checks.
|
|
|
233
|
+ if (AppConstants.BASE_BROWSER_VERSION) {
|
|
|
234
|
+ return;
|
|
|
235
|
+ }
|
|
|
236
|
+
|
|
231
|
237
|
is(
|
|
232
|
238
|
result.worker_appVersion,
|
|
233
|
239
|
expectedResults.appVersion,
|
browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_max_inner.js
| ... |
... |
@@ -4,6 +4,12 @@ |
|
4
|
4
|
* maximum values.
|
|
5
|
5
|
*/
|
|
6
|
6
|
|
|
|
7
|
+add_setup(async () => {
|
|
|
8
|
+ await SpecialPowers.pushPrefEnv({
|
|
|
9
|
+ set: [["browser.link.open_newwindow.restriction", 2]],
|
|
|
10
|
+ });
|
|
|
11
|
+});
|
|
|
12
|
+
|
|
7
|
13
|
let targetWidth = Services.prefs.getIntPref("privacy.window.maxInnerWidth");
|
|
8
|
14
|
let targetHeight = Services.prefs.getIntPref("privacy.window.maxInnerHeight");
|
|
9
|
15
|
|
browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_mid_inner.js
| ... |
... |
@@ -4,6 +4,12 @@ |
|
4
|
4
|
* middle values.
|
|
5
|
5
|
*/
|
|
6
|
6
|
|
|
|
7
|
+add_setup(async () => {
|
|
|
8
|
+ await SpecialPowers.pushPrefEnv({
|
|
|
9
|
+ set: [["browser.link.open_newwindow.restriction", 2]],
|
|
|
10
|
+ });
|
|
|
11
|
+});
|
|
|
12
|
+
|
|
7
|
13
|
OpenTest.run([
|
|
8
|
14
|
{
|
|
9
|
15
|
settingWidth: 600,
|
browser/components/resistfingerprinting/test/browser/browser_roundedWindow_open_min_inner.js
| ... |
... |
@@ -4,6 +4,12 @@ |
|
4
|
4
|
* minimum values.
|
|
5
|
5
|
*/
|
|
6
|
6
|
|
|
|
7
|
+add_setup(async () => {
|
|
|
8
|
+ await SpecialPowers.pushPrefEnv({
|
|
|
9
|
+ set: [["browser.link.open_newwindow.restriction", 2]],
|
|
|
10
|
+ });
|
|
|
11
|
+});
|
|
|
12
|
+
|
|
7
|
13
|
OpenTest.run([
|
|
8
|
14
|
{
|
|
9
|
15
|
settingWidth: 199,
|
browser/components/resistfingerprinting/test/browser/file_navigator_iframee.html
| ... |
... |
@@ -25,20 +25,32 @@ window.addEventListener("message", async function listener(event) { |
|
25
|
25
|
result.hardwareConcurrency = navigator.hardwareConcurrency;
|
|
26
|
26
|
result.userAgentHTTPHeader = "unknown";
|
|
27
|
27
|
|
|
28
|
|
- let worker = new SharedWorker("file_navigator_iframe_worker.sjs");
|
|
29
|
|
- let worker_result = await new Promise(resolve => {
|
|
30
|
|
- worker.port.onmessage = function(e) {
|
|
31
|
|
- resolve(e.data);
|
|
32
|
|
- };
|
|
33
|
|
- });
|
|
|
28
|
+ let worker = null;
|
|
|
29
|
+ try {
|
|
|
30
|
+ worker = new SharedWorker("file_navigator_iframe_worker.sjs");
|
|
|
31
|
+ } catch (e) {
|
|
|
32
|
+ // Base Browser rejects third-party storage, so SharedWorker throws a
|
|
|
33
|
+ // SecurityError here.
|
|
|
34
|
+ if (e.name != "SecurityError") {
|
|
|
35
|
+ throw e;
|
|
|
36
|
+ }
|
|
|
37
|
+ }
|
|
|
38
|
+
|
|
|
39
|
+ if (worker) {
|
|
|
40
|
+ let worker_result = await new Promise(resolve => {
|
|
|
41
|
+ worker.port.onmessage = function(e) {
|
|
|
42
|
+ resolve(e.data);
|
|
|
43
|
+ };
|
|
|
44
|
+ });
|
|
34
|
45
|
|
|
35
|
|
- result.worker_appCodeName = worker_result.appCodeName;
|
|
36
|
|
- result.worker_appName = worker_result.appName;
|
|
37
|
|
- result.worker_appVersion = worker_result.appVersion;
|
|
38
|
|
- result.worker_platform = worker_result.platform;
|
|
39
|
|
- result.worker_userAgent = worker_result.userAgent;
|
|
40
|
|
- result.worker_product = worker_result.product;
|
|
41
|
|
- result.worker_hardwareConcurrency = worker_result.hardwareConcurrency;
|
|
|
46
|
+ result.worker_appCodeName = worker_result.appCodeName;
|
|
|
47
|
+ result.worker_appName = worker_result.appName;
|
|
|
48
|
+ result.worker_appVersion = worker_result.appVersion;
|
|
|
49
|
+ result.worker_platform = worker_result.platform;
|
|
|
50
|
+ result.worker_userAgent = worker_result.userAgent;
|
|
|
51
|
+ result.worker_product = worker_result.product;
|
|
|
52
|
+ result.worker_hardwareConcurrency = worker_result.hardwareConcurrency;
|
|
|
53
|
+ }
|
|
42
|
54
|
|
|
43
|
55
|
var one = fetch("file_navigator_header.sjs?")
|
|
44
|
56
|
.then((response) => { return response.text(); })
|
browser/components/resistfingerprinting/test/browser/head.js
| ... |
... |
@@ -13,6 +13,12 @@ const TEST_PATH = |
|
13
|
13
|
"http://example.net/browser/browser/" +
|
|
14
|
14
|
"components/resistfingerprinting/test/browser/";
|
|
15
|
15
|
|
|
|
16
|
+// When set, every window is private, so tests can't open normal windows.
|
|
|
17
|
+const PERMANENT_PRIVATE_BROWSING = Services.prefs.getBoolPref(
|
|
|
18
|
+ "browser.privatebrowsing.autostart",
|
|
|
19
|
+ false
|
|
|
20
|
+);
|
|
|
21
|
+
|
|
16
|
22
|
const PERFORMANCE_TIMINGS = [
|
|
17
|
23
|
"navigationStart",
|
|
18
|
24
|
"unloadEventStart",
|
| ... |
... |
@@ -211,6 +217,14 @@ let setupAndRunCrossOriginIsolatedTest = async function ( |
|
211
|
217
|
if (options.openPrivateWindow === undefined) {
|
|
212
|
218
|
options.openPrivateWindow = false;
|
|
213
|
219
|
}
|
|
|
220
|
+ if (
|
|
|
221
|
+ PERMANENT_PRIVATE_BROWSING &&
|
|
|
222
|
+ options.resistFingerprintingPBMOnly &&
|
|
|
223
|
+ !options.openPrivateWindow
|
|
|
224
|
+ ) {
|
|
|
225
|
+ info("Skipping, there are no normal windows in permanent private browsing");
|
|
|
226
|
+ return;
|
|
|
227
|
+ }
|
|
214
|
228
|
if (options.shouldBeRounded === undefined) {
|
|
215
|
229
|
options.shouldBeRounded = true;
|
|
216
|
230
|
}
|
| ... |
... |
@@ -679,7 +693,8 @@ async function runActualTest(uri, testFunction, expectedResults, extraData) { |
|
679
|
693
|
if ("noopener" in extraData) {
|
|
680
|
694
|
var popupTabPromise = BrowserTestUtils.waitForNewTab(
|
|
681
|
695
|
browserWin,
|
|
682
|
|
- extraData.await_uri
|
|
|
696
|
+ extraData.await_uri,
|
|
|
697
|
+ true
|
|
683
|
698
|
);
|
|
684
|
699
|
}
|
|
685
|
700
|
|
| ... |
... |
@@ -747,15 +762,21 @@ async function defaultsTest( |
|
747
|
762
|
}
|
|
748
|
763
|
extraData.testDesc = extraData.testDesc || "default";
|
|
749
|
764
|
expectedResults.shouldRFPApply = false;
|
|
750
|
|
- if (extraPrefs != undefined) {
|
|
751
|
|
- await SpecialPowers.pushPrefEnv({
|
|
752
|
|
- set: extraPrefs,
|
|
753
|
|
- });
|
|
|
765
|
+ let prefs = extraPrefs || [];
|
|
|
766
|
+ // In permanent private browsing we can't open a normal window, so we fake
|
|
|
767
|
+ // one. The *.pbmode prefs are the only way being private affects whether
|
|
|
768
|
+ // RFP/FPP apply, so with them off this window is protected exactly like a
|
|
|
769
|
+ // normal one would be. They go last so they win over any value the test passed.
|
|
|
770
|
+ if (PERMANENT_PRIVATE_BROWSING && !extraData.private_window) {
|
|
|
771
|
+ prefs = [
|
|
|
772
|
+ ...prefs,
|
|
|
773
|
+ ["privacy.resistFingerprinting.pbmode", false],
|
|
|
774
|
+ ["privacy.fingerprintingProtection.pbmode", false],
|
|
|
775
|
+ ];
|
|
754
|
776
|
}
|
|
|
777
|
+ await SpecialPowers.pushPrefEnv({ set: prefs });
|
|
755
|
778
|
await runActualTest(uri, testFunction, expectedResults, extraData);
|
|
756
|
|
- if (extraPrefs != undefined) {
|
|
757
|
|
- await SpecialPowers.popPrefEnv();
|
|
758
|
|
- }
|
|
|
779
|
+ await SpecialPowers.popPrefEnv();
|
|
759
|
780
|
}
|
|
760
|
781
|
|
|
761
|
782
|
async function defaultsPBMTest(
|
| ... |
... |
@@ -879,6 +900,10 @@ async function RFPPBMFPP_NormalMode_NoProtectionsTest( |
|
879
|
900
|
extraData,
|
|
880
|
901
|
extraPrefs
|
|
881
|
902
|
) {
|
|
|
903
|
+ if (PERMANENT_PRIVATE_BROWSING) {
|
|
|
904
|
+ info("Skipping, there are no normal windows in permanent private browsing");
|
|
|
905
|
+ return;
|
|
|
906
|
+ }
|
|
882
|
907
|
if (extraData == undefined) {
|
|
883
|
908
|
extraData = {};
|
|
884
|
909
|
}
|
| ... |
... |
@@ -908,6 +933,10 @@ async function RFPPBMFPP_NormalMode_ProtectionsTest( |
|
908
|
933
|
extraData,
|
|
909
|
934
|
extraPrefs
|
|
910
|
935
|
) {
|
|
|
936
|
+ if (PERMANENT_PRIVATE_BROWSING) {
|
|
|
937
|
+ info("Skipping, there are no normal windows in permanent private browsing");
|
|
|
938
|
+ return;
|
|
|
939
|
+ }
|
|
911
|
940
|
if (extraData == undefined) {
|
|
912
|
941
|
extraData = {};
|
|
913
|
942
|
}
|
browser/components/resistfingerprinting/test/mochitest/mochitest.toml
|
1
|
1
|
[DEFAULT]
|
|
|
2
|
+# These tests are written for Firefox, where RFP is disabled by default.
|
|
|
3
|
+prefs = ["privacy.resistFingerprinting=false"]
|
|
2
|
4
|
skip-if = [
|
|
3
|
5
|
"os == 'android'", # bug 1730213
|
|
4
|
6
|
"os == 'linux' && os_version == '24.04' && arch == 'x86_64' && display == 'x11' && ccov",
|
|
5
|
7
|
]
|
|
6
|
|
-tags = "resistfingerprinting"
|
|
|
8
|
+tags = "base-browser resistfingerprinting"
|
|
7
|
9
|
|
|
8
|
10
|
support-files = [
|
|
9
|
11
|
"file_animation_api.html",
|
| ... |
... |
@@ -33,6 +35,7 @@ skip-if = [ |
|
33
|
35
|
|
|
34
|
36
|
["test_geolocation.html"]
|
|
35
|
37
|
scheme = "https"
|
|
|
38
|
+disabled = "Geolocation is disabled in 001-base-profile.js"
|
|
36
|
39
|
|
|
37
|
40
|
["test_hide_gamepad_info.html"]
|
|
38
|
41
|
scheme = "https"
|
dom/base/nsContentUtils.cpp
| ... |
... |
@@ -1191,7 +1191,7 @@ static constexpr nsLiteralCString kRfpPrefs[] = { |
|
1191
|
1191
|
"privacy.baselineFingerprintingProtection.overrides"_ns,
|
|
1192
|
1192
|
};
|
|
1193
|
1193
|
|
|
1194
|
|
-static void RecomputeResistFingerprintingAllDocs(const char*, void*) {
|
|
|
1194
|
+static void OnResistFingerprintingPrefChanged(const char*, void*) {
|
|
1195
|
1195
|
AutoTArray<RefPtr<Document>, 64> allDocuments;
|
|
1196
|
1196
|
Document::GetAllInProcessDocuments(allDocuments);
|
|
1197
|
1197
|
for (auto& doc : allDocuments) {
|
| ... |
... |
@@ -1203,6 +1203,10 @@ static void RecomputeResistFingerprintingAllDocs(const char*, void*) { |
|
1203
|
1203
|
MediaFeatureChangePropagation::JustThisDocument);
|
|
1204
|
1204
|
}
|
|
1205
|
1205
|
}
|
|
|
1206
|
+ // Sandboxes are not tied to a document, so the loop above doesn't reach
|
|
|
1207
|
+ // them. Their realms cache the RTP caller type at creation and must be
|
|
|
1208
|
+ // refreshed explicitly.
|
|
|
1209
|
+ xpc::RefreshSandboxesRTPCallerType();
|
|
1206
|
1210
|
}
|
|
1207
|
1211
|
|
|
1208
|
1212
|
// static
|
| ... |
... |
@@ -1290,7 +1294,7 @@ nsresult nsContentUtils::Init() { |
|
1290
|
1294
|
uio.forget(&sUserInteractionObserver);
|
|
1291
|
1295
|
|
|
1292
|
1296
|
for (const auto& pref : kRfpPrefs) {
|
|
1293
|
|
- Preferences::RegisterCallback(RecomputeResistFingerprintingAllDocs, pref);
|
|
|
1297
|
+ Preferences::RegisterCallback(OnResistFingerprintingPrefChanged, pref);
|
|
1294
|
1298
|
}
|
|
1295
|
1299
|
|
|
1296
|
1300
|
mozilla::dom::ReportDeliver::Initialize();
|
| ... |
... |
@@ -2452,7 +2456,7 @@ void nsContentUtils::Shutdown() { |
|
2452
|
2456
|
}
|
|
2453
|
2457
|
|
|
2454
|
2458
|
for (const auto& pref : kRfpPrefs) {
|
|
2455
|
|
- Preferences::UnregisterCallback(RecomputeResistFingerprintingAllDocs, pref);
|
|
|
2459
|
+ Preferences::UnregisterCallback(OnResistFingerprintingPrefChanged, pref);
|
|
2456
|
2460
|
}
|
|
2457
|
2461
|
|
|
2458
|
2462
|
TextControlState::Shutdown();
|
js/xpconnect/src/Sandbox.cpp
| ... |
... |
@@ -2365,9 +2365,18 @@ nsresult xpc::SetSandboxMetadata(JSContext* cx, HandleObject sandbox, |
|
2365
|
2365
|
return NS_OK;
|
|
2366
|
2366
|
}
|
|
2367
|
2367
|
|
|
|
2368
|
+static mozilla::LinkedList<SandboxPrivate>& LiveSandboxes() {
|
|
|
2369
|
+ MOZ_ASSERT(NS_IsMainThread());
|
|
|
2370
|
+ // Intentionally never destroyed: sandboxes can outlive static destructors.
|
|
|
2371
|
+ static auto* sLiveSandboxes = new mozilla::LinkedList<SandboxPrivate>();
|
|
|
2372
|
+ return *sLiveSandboxes;
|
|
|
2373
|
+}
|
|
|
2374
|
+
|
|
2368
|
2375
|
SandboxPrivate::SandboxPrivate(nsIPrincipal* principal)
|
|
2369
|
2376
|
: mPrincipal(principal),
|
|
2370
|
|
- mCookieJarSettings(mozilla::net::CookieJarSettings::Create(mPrincipal)) {}
|
|
|
2377
|
+ mCookieJarSettings(mozilla::net::CookieJarSettings::Create(mPrincipal)) {
|
|
|
2378
|
+ LiveSandboxes().insertBack(this);
|
|
|
2379
|
+}
|
|
2371
|
2380
|
|
|
2372
|
2381
|
SandboxPrivate::~SandboxPrivate() = default;
|
|
2373
|
2382
|
|
| ... |
... |
@@ -2380,6 +2389,17 @@ already_AddRefed<nsPIDOMWindowInner> SandboxPrivate::GetAssociatedWindow() { |
|
2380
|
2389
|
return window.forget();
|
|
2381
|
2390
|
}
|
|
2382
|
2391
|
|
|
|
2392
|
+/* static */
|
|
|
2393
|
+void SandboxPrivate::RefreshAllRTPCallerTypes() {
|
|
|
2394
|
+ for (SandboxPrivate* sbp : LiveSandboxes()) {
|
|
|
2395
|
+ sbp->RefreshRTPCallerType();
|
|
|
2396
|
+ }
|
|
|
2397
|
+}
|
|
|
2398
|
+
|
|
|
2399
|
+void xpc::RefreshSandboxesRTPCallerType() {
|
|
|
2400
|
+ SandboxPrivate::RefreshAllRTPCallerTypes();
|
|
|
2401
|
+}
|
|
|
2402
|
+
|
|
2383
|
2403
|
ModuleLoaderBase* SandboxPrivate::GetModuleLoader(JSContext* aCx) {
|
|
2384
|
2404
|
if (mModuleLoader) {
|
|
2385
|
2405
|
return mModuleLoader;
|
js/xpconnect/src/SandboxPrivate.h
| ... |
... |
@@ -5,6 +5,7 @@ |
|
5
|
5
|
#ifndef SANDBOXPRIVATE_H_
|
|
6
|
6
|
#define SANDBOXPRIVATE_H_
|
|
7
|
7
|
|
|
|
8
|
+#include "mozilla/LinkedList.h"
|
|
8
|
9
|
#include "mozilla/net/CookieJarSettings.h"
|
|
9
|
10
|
#include "mozilla/SchedulerGroup.h"
|
|
10
|
11
|
#include "mozilla/StaticPrefs_dom.h"
|
| ... |
... |
@@ -29,7 +30,8 @@ class SandboxPrivate final : public nsIGlobalObject, |
|
29
|
30
|
public nsIScriptObjectPrincipal,
|
|
30
|
31
|
public nsSupportsWeakReference,
|
|
31
|
32
|
public mozilla::SupportsWeakPtr,
|
|
32
|
|
- public nsWrapperCache {
|
|
|
33
|
+ public nsWrapperCache,
|
|
|
34
|
+ public mozilla::LinkedListElement<SandboxPrivate> {
|
|
33
|
35
|
public:
|
|
34
|
36
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
35
|
37
|
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS_AMBIGUOUS(SandboxPrivate,
|
| ... |
... |
@@ -46,11 +48,23 @@ class SandboxPrivate final : public nsIGlobalObject, |
|
46
|
48
|
static_cast<nsIScriptObjectPrincipal*>(sbp.forget().take());
|
|
47
|
49
|
JS::SetObjectISupports(global, sop);
|
|
48
|
50
|
|
|
|
51
|
+ GetPrivate(global)->RefreshRTPCallerType();
|
|
|
52
|
+ }
|
|
|
53
|
+
|
|
|
54
|
+ void RefreshRTPCallerType() {
|
|
|
55
|
+ JSObject* global = GetWrapperPreserveColor();
|
|
|
56
|
+ if (!global) {
|
|
|
57
|
+ return;
|
|
|
58
|
+ }
|
|
49
|
59
|
JS::SetRealmReduceTimerPrecisionCallerType(
|
|
50
|
60
|
js::GetNonCCWObjectRealm(global),
|
|
51
|
|
- RTPCallerTypeToToken(GetPrivate(global)->GetRTPCallerType()));
|
|
|
61
|
+ RTPCallerTypeToToken(GetRTPCallerType()));
|
|
52
|
62
|
}
|
|
53
|
63
|
|
|
|
64
|
+ // Refreshes the realm RTP caller type of every live sandbox, so that it
|
|
|
65
|
+ // stays in sync with GetRTPCallerType() when the RFP prefs change.
|
|
|
66
|
+ static void RefreshAllRTPCallerTypes();
|
|
|
67
|
+
|
|
54
|
68
|
static SandboxPrivate* GetPrivate(JSObject* obj) {
|
|
55
|
69
|
// The type used to cast to void needs to match the one in Create.
|
|
56
|
70
|
nsIScriptObjectPrincipal* sop =
|
| ... |
... |
@@ -89,7 +103,12 @@ class SandboxPrivate final : public nsIGlobalObject, |
|
89
|
103
|
mCookieJarSettings);
|
|
90
|
104
|
}
|
|
91
|
105
|
|
|
92
|
|
- void ForgetGlobalObject(JSObject* obj) { ClearWrapper(obj); }
|
|
|
106
|
+ void ForgetGlobalObject(JSObject* obj) {
|
|
|
107
|
+ ClearWrapper(obj);
|
|
|
108
|
+ if (isInList()) {
|
|
|
109
|
+ remove();
|
|
|
110
|
+ }
|
|
|
111
|
+ }
|
|
93
|
112
|
|
|
94
|
113
|
nsISerialEventTarget* SerialEventTarget() const final {
|
|
95
|
114
|
return mozilla::GetMainThreadSerialEventTarget();
|
js/xpconnect/src/xpcpublic.h
| ... |
... |
@@ -427,6 +427,10 @@ class XPCStringConvert { |
|
427
|
427
|
|
|
428
|
428
|
namespace xpc {
|
|
429
|
429
|
|
|
|
430
|
+// Recomputes the realm RTP caller type of every live JS sandbox. Called when
|
|
|
431
|
+// the fingerprinting protection prefs change.
|
|
|
432
|
+void RefreshSandboxesRTPCallerType();
|
|
|
433
|
+
|
|
430
|
434
|
// If these functions return false, then an exception will be set on cx.
|
|
431
|
435
|
bool Base64Encode(JSContext* cx, JS::Handle<JS::Value> val,
|
|
432
|
436
|
JS::MutableHandle<JS::Value> out);
|
testing/mochitest/browser-test.js
| ... |
... |
@@ -1680,7 +1680,10 @@ Tester.prototype = { |
|
1680
|
1680
|
// dom.security.https_first to false for the duration of the test.
|
|
1681
|
1681
|
if (currentTest.https_first_disabled) {
|
|
1682
|
1682
|
window.SpecialPowers.pushPrefEnv({
|
|
1683
|
|
- set: [["dom.security.https_first", false]],
|
|
|
1683
|
+ set: [
|
|
|
1684
|
+ ["dom.security.https_first", false],
|
|
|
1685
|
+ ["dom.security.https_first_pbm", false],
|
|
|
1686
|
+ ],
|
|
1684
|
1687
|
});
|
|
1685
|
1688
|
}
|
|
1686
|
1689
|
|
testing/mochitest/tests/SimpleTest/TestRunner.js
| ... |
... |
@@ -594,7 +594,10 @@ async function _runNextTest() { |
|
594
|
594
|
}
|
|
595
|
595
|
if (TestRunner._urls[TestRunner._currentTest].test.https_first_disabled) {
|
|
596
|
596
|
await SpecialPowers.pushPrefEnv({
|
|
597
|
|
- set: [["dom.security.https_first", false]],
|
|
|
597
|
+ set: [
|
|
|
598
|
+ ["dom.security.https_first", false],
|
|
|
599
|
+ ["dom.security.https_first_pbm", false],
|
|
|
600
|
+ ],
|
|
598
|
601
|
});
|
|
599
|
602
|
}
|
|
600
|
603
|
TestRunner._makeIframe(url, 0);
|
toolkit/components/resistfingerprinting/tests/xpcshell/test_sandbox_reduce_timer_precision.js
|
|
1
|
+/* Any copyright is dedicated to the Public Domain.
|
|
|
2
|
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
3
|
+
|
|
|
4
|
+"use strict";
|
|
|
5
|
+
|
|
|
6
|
+// Sandboxes compute their reduce timer precision caller type when they are
|
|
|
7
|
+// created. Make sure it is refreshed when the RFP prefs change afterwards.
|
|
|
8
|
+
|
|
|
9
|
+const PRECISION_MS = 100;
|
|
|
10
|
+
|
|
|
11
|
+function sandboxTimeIsRounded(sandbox) {
|
|
|
12
|
+ const values = [];
|
|
|
13
|
+ let last = -1;
|
|
|
14
|
+ while (values.length < 5) {
|
|
|
15
|
+ const now = Cu.evalInSandbox("Date.now()", sandbox);
|
|
|
16
|
+ if (now !== last) {
|
|
|
17
|
+ values.push(now);
|
|
|
18
|
+ last = now;
|
|
|
19
|
+ }
|
|
|
20
|
+ }
|
|
|
21
|
+ return values.every(v => v % PRECISION_MS === 0);
|
|
|
22
|
+}
|
|
|
23
|
+
|
|
|
24
|
+add_setup(() => {
|
|
|
25
|
+ Services.prefs.setBoolPref("privacy.reduceTimerPrecision", false);
|
|
|
26
|
+ Services.prefs.setIntPref(
|
|
|
27
|
+ "privacy.resistFingerprinting.reduceTimerPrecision.microseconds",
|
|
|
28
|
+ PRECISION_MS * 1000
|
|
|
29
|
+ );
|
|
|
30
|
+ Services.prefs.setBoolPref("privacy.resistFingerprinting.pbmode", false);
|
|
|
31
|
+ registerCleanupFunction(() => {
|
|
|
32
|
+ Services.prefs.clearUserPref("privacy.reduceTimerPrecision");
|
|
|
33
|
+ Services.prefs.clearUserPref(
|
|
|
34
|
+ "privacy.resistFingerprinting.reduceTimerPrecision.microseconds"
|
|
|
35
|
+ );
|
|
|
36
|
+ Services.prefs.clearUserPref("privacy.resistFingerprinting.pbmode");
|
|
|
37
|
+ Services.prefs.clearUserPref("privacy.resistFingerprinting");
|
|
|
38
|
+ });
|
|
|
39
|
+});
|
|
|
40
|
+
|
|
|
41
|
+add_task(function test_enable_rfp_after_sandbox_creation() {
|
|
|
42
|
+ Services.prefs.setBoolPref("privacy.resistFingerprinting", false);
|
|
|
43
|
+ const sandbox = Cu.Sandbox("https://example.com");
|
|
|
44
|
+ Assert.ok(
|
|
|
45
|
+ !sandboxTimeIsRounded(sandbox),
|
|
|
46
|
+ "Sandbox time is not rounded without RFP"
|
|
|
47
|
+ );
|
|
|
48
|
+
|
|
|
49
|
+ Services.prefs.setBoolPref("privacy.resistFingerprinting", true);
|
|
|
50
|
+ Assert.ok(
|
|
|
51
|
+ sandboxTimeIsRounded(sandbox),
|
|
|
52
|
+ "Sandbox time is rounded after enabling RFP"
|
|
|
53
|
+ );
|
|
|
54
|
+});
|
|
|
55
|
+
|
|
|
56
|
+add_task(function test_disable_rfp_after_sandbox_creation() {
|
|
|
57
|
+ Services.prefs.setBoolPref("privacy.resistFingerprinting", true);
|
|
|
58
|
+ const sandbox = Cu.Sandbox("https://example.com");
|
|
|
59
|
+ Assert.ok(sandboxTimeIsRounded(sandbox), "Sandbox time is rounded with RFP");
|
|
|
60
|
+
|
|
|
61
|
+ Services.prefs.setBoolPref("privacy.resistFingerprinting", false);
|
|
|
62
|
+ Assert.ok(
|
|
|
63
|
+ !sandboxTimeIsRounded(sandbox),
|
|
|
64
|
+ "Sandbox time is not rounded after disabling RFP"
|
|
|
65
|
+ );
|
|
|
66
|
+}); |
toolkit/components/resistfingerprinting/tests/xpcshell/xpcshell.toml
| ... |
... |
@@ -8,3 +8,5 @@ prefs = [ |
|
8
|
8
|
run-if = [
|
|
9
|
9
|
"os == 'android'",
|
|
10
|
10
|
]
|
|
|
11
|
+
|
|
|
12
|
+["test_sandbox_reduce_timer_precision.js"] |
|