summaryrefslogtreecommitdiffstats
path: root/toolkit/components/resistfingerprinting/tests/browser
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /toolkit/components/resistfingerprinting/tests/browser
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/resistfingerprinting/tests/browser')
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser.toml2
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_canvas_fingerprinter_telemetry.js2
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js2
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js2
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js60
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingWebCompat.js2
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_font_fingerprinter_telemetry.js2
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_fpiServiceWorkers_fingerprinting.js2
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_serviceWorker_fingerprinting_webcompat.js4
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/browser_usercharacteristics.js51
-rw-r--r--toolkit/components/resistfingerprinting/tests/browser/head.js2
11 files changed, 121 insertions, 10 deletions
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser.toml b/toolkit/components/resistfingerprinting/tests/browser/browser.toml
index 213d6d4287..527e39ad89 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser.toml
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser.toml
@@ -31,3 +31,5 @@ support-files = [
support-files = ["file_pdf.pdf"]
["browser_serviceWorker_fingerprinting_webcompat.js"]
+
+["browser_usercharacteristics.js"]
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_fingerprinter_telemetry.js b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_fingerprinter_telemetry.js
index d2a33a4347..1098d91138 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_fingerprinter_telemetry.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_fingerprinter_telemetry.js
@@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
"use strict";
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js
index 8b4be78d53..e526f7fff1 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js
@@ -1,6 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/**
* Bug 1816189 - Testing canvas randomization on canvas data extraction.
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 dd7c292fa4..723d7382f8 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js
@@ -1,6 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
const emptyPage =
getRootDirectory(gTestPath).replace(
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js
index 29c7c9170b..ac4722fd84 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js
@@ -1,6 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
"use strict";
@@ -20,6 +20,18 @@ const TARGET_CanvasRandomization = 0x000000100;
const TARGET_WindowOuterSize = 0x002000000;
const TARGET_Gamepad = 0x00800000;
+const TEST_PAGE =
+ getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "https://example.com"
+ ) + "empty.html";
+
+const TEST_ANOTHER_PAGE =
+ getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "https://example.net"
+ ) + "empty.html";
+
// A helper function to filter high 32 bits.
function extractLow32Bits(value) {
return value & 0xffffffff;
@@ -404,3 +416,49 @@ add_task(async function test_pref_override_remote_settings() {
db.clear();
});
+
+// Bug 1873682 - Verify that a third-party beacon request won't hit the
+// assertion in nsRFPService::GetOverriddenFingerprintingSettingsForChannel().
+add_task(async function test_beacon_request() {
+ // Open an empty page.
+ let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE);
+
+ await SpecialPowers.spawn(
+ tab.linkedBrowser,
+ [TEST_ANOTHER_PAGE],
+ async url => {
+ // Create a third-party iframe
+ let ifr = content.document.createElement("iframe");
+
+ await new content.Promise(resolve => {
+ ifr.onload = resolve;
+ content.document.body.appendChild(ifr);
+ ifr.src = url;
+ });
+
+ await SpecialPowers.spawn(ifr, [url], url => {
+ // Sending the beacon request right before the tab navigates away.
+ content.addEventListener("unload", _ => {
+ let value = ["text"];
+ let blob = new Blob(value, {
+ type: "application/x-www-form-urlencoded",
+ });
+ content.navigator.sendBeacon(url, blob);
+ });
+ });
+
+ // Navigate the tab to another page.
+ content.location = url;
+ }
+ );
+
+ await BrowserTestUtils.browserLoaded(
+ tab.linkedBrowser,
+ false,
+ TEST_ANOTHER_PAGE
+ );
+
+ ok(true, "Successfully navigates away.");
+
+ BrowserTestUtils.removeTab(tab);
+});
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingWebCompat.js b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingWebCompat.js
index 1a882fc63d..62335b2fe7 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingWebCompat.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingWebCompat.js
@@ -1,6 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
"use strict";
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_font_fingerprinter_telemetry.js b/toolkit/components/resistfingerprinting/tests/browser/browser_font_fingerprinter_telemetry.js
index 2231197eed..0cccf0c5f3 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_font_fingerprinter_telemetry.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_font_fingerprinter_telemetry.js
@@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
"use strict";
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_fpiServiceWorkers_fingerprinting.js b/toolkit/components/resistfingerprinting/tests/browser/browser_fpiServiceWorkers_fingerprinting.js
index 64279ae442..aaa40a7928 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_fpiServiceWorkers_fingerprinting.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_fpiServiceWorkers_fingerprinting.js
@@ -68,7 +68,7 @@ runTestInFirstAndThirdPartyContexts(
},
async _ => {
await new Promise(resolve => {
- Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
+ Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
resolve()
);
});
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_serviceWorker_fingerprinting_webcompat.js b/toolkit/components/resistfingerprinting/tests/browser/browser_serviceWorker_fingerprinting_webcompat.js
index a9bab38e61..eb1ab8d795 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/browser_serviceWorker_fingerprinting_webcompat.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_serviceWorker_fingerprinting_webcompat.js
@@ -59,7 +59,7 @@ runTestInFirstAndThirdPartyContexts(
async _ => {
await new Promise(resolve => {
- Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
+ Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
resolve()
);
});
@@ -142,7 +142,7 @@ runTestInFirstAndThirdPartyContexts(
async _ => {
await new Promise(resolve => {
- Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
+ Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
resolve()
);
});
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_usercharacteristics.js b/toolkit/components/resistfingerprinting/tests/browser/browser_usercharacteristics.js
new file mode 100644
index 0000000000..9896948311
--- /dev/null
+++ b/toolkit/components/resistfingerprinting/tests/browser/browser_usercharacteristics.js
@@ -0,0 +1,51 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+const emptyPage =
+ getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "https://example.com"
+ ) + "empty.html";
+
+function promiseObserverNotification() {
+ return TestUtils.topicObserved(
+ "user-characteristics-populating-data-done",
+ _ => {
+ var submitted = false;
+ GleanPings.userCharacteristics.testBeforeNextSubmit(_ => {
+ submitted = true;
+
+ // Did we assign a value we got out of about:fingerprinting?
+ // For now, we are sticking the test value in a random telemetry
+ // metric, but once we have a real metric, we'll update this
+ Assert.equal(
+ "Hello World",
+ Glean.characteristics.timezone.testGetValue()
+ );
+ });
+ GleanPings.userCharacteristics.submit();
+
+ return submitted;
+ }
+ );
+}
+
+add_task(async function run_test() {
+ info("Starting test...");
+
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url: emptyPage },
+ async function tabTask(_) {
+ let promise = promiseObserverNotification();
+
+ Services.obs.notifyObservers(
+ null,
+ "user-characteristics-testing-please-populate-data"
+ );
+
+ let submitted = await promise;
+ Assert.ok(submitted);
+ }
+ );
+});
diff --git a/toolkit/components/resistfingerprinting/tests/browser/head.js b/toolkit/components/resistfingerprinting/tests/browser/head.js
index 9d8ec19956..e2fddaecc6 100644
--- a/toolkit/components/resistfingerprinting/tests/browser/head.js
+++ b/toolkit/components/resistfingerprinting/tests/browser/head.js
@@ -54,7 +54,7 @@ function countDifferencesInArrayBuffers(buffer1, buffer2) {
function promiseObserver(topic) {
return new Promise(resolve => {
- let obs = (aSubject, aTopic, aData) => {
+ let obs = (aSubject, aTopic) => {
Services.obs.removeObserver(obs, aTopic);
resolve(aSubject);
};