Backed out 33 changesets (bug 1778510) for causing build bustages at nsIGlobalObject.h. CLOSED TREE

Backed out changeset f2a53c9e497c
Backed out changeset 59350ca6f3f2 (bug 1778510)
Backed out changeset abbba7e72b57 (bug 1778510)
Backed out changeset 6cf7473afae8 (bug 1778510)
Backed out changeset 74fb5fed93ea (bug 1778510)
Backed out changeset 5b5dc70cdd0a (bug 1778510)
Backed out changeset ff93191cafd2 (bug 1778510)
Backed out changeset 39cc006b610c (bug 1778510)
Backed out changeset dfaef3ad17a9 (bug 1778510)
Backed out changeset 8fbabeb8244b (bug 1778510)
Backed out changeset 45051b62e3f1 (bug 1778510)
Backed out changeset 86c0923fd81f (bug 1778510)
Backed out changeset a49c0f69d519 (bug 1778510)
Backed out changeset cfad733d4aaf (bug 1778510)
Backed out changeset df6d0fe89d5b (bug 1778510)
Backed out changeset 704db76eab17 (bug 1778510)
Backed out changeset 0651c128e369 (bug 1778510)
Backed out changeset 1e650de647c0 (bug 1778510)
Backed out changeset fa15a3572741 (bug 1778510)
Backed out changeset 4ceffd409eae (bug 1778510)
Backed out changeset 47db43142c62 (bug 1778510)
Backed out changeset ebb21153aaac (bug 1778510)
Backed out changeset a87eaaec3f9c (bug 1778510)
Backed out changeset 43ad5ee21f79 (bug 1778510)
Backed out changeset 5f20af8e1263 (bug 1778510)
Backed out changeset b78576875db0 (bug 1778510)
Backed out changeset d801fdeac90b (bug 1778510)
Backed out changeset 5af032c628c0 (bug 1778510)
Backed out changeset 86aa59de11b4 (bug 1778510)
Backed out changeset 58642357a19c (bug 1778510)
Backed out changeset c575e824e291 (bug 1778510)
Backed out changeset 32a358de4843 (bug 1778510)
Backed out changeset 40e0708c01e7 (bug 1778510)
This commit is contained in:
Butkovits Atila 2022-11-28 23:14:52 +02:00
Родитель bfcf8f3747
Коммит cb853b7f77
75 изменённых файлов: 875 добавлений и 1753 удалений

Просмотреть файл

@ -1,6 +1,7 @@
[DEFAULT]
tags = resistfingerprinting
support-files =
browser_navigator_header.sjs
coop_header.sjs
file_dummy.html
file_keyBoardEvent.sjs
@ -9,18 +10,11 @@ support-files =
file_workerNetInfo.js
file_workerPerformance.js
head.js
file_navigator_header.sjs
file_navigator_iframer.html
file_navigator_iframee.html
file_navigator_iframe_worker.sjs
file_reduceTimePrecision_iframer.html
file_reduceTimePrecision_iframee.html
file_reduceTimePrecision_iframe_worker.sjs
file_animationapi_iframer.html
file_animationapi_iframee.html
[browser_block_mozAddonManager.js]
[browser_animationapi_iframes.js]
[browser_cross_origin_isolated_animation_api.js]
[browser_cross_origin_isolated_performance_api.js]
[browser_cross_origin_isolated_reduce_time_precision.js]
@ -42,8 +36,6 @@ skip-if =
https_first_disabled = true
[browser_performanceAPI.js]
[browser_performanceAPIWorkers.js]
[browser_reduceTimePrecision_iframes.js]
https_first_disabled = true
[browser_roundedWindow_dialogWindow.js]
[browser_roundedWindow_newWindow.js]
[browser_roundedWindow_open_max_inner.js]

Просмотреть файл

@ -1,263 +0,0 @@
/**
* This test only tests values in the iframe, it does not test them on the framer
*
* Covers the following cases:
* - RFP is disabled entirely
* - RFP is enabled entirely
* - (A) RFP is exempted on the framer and framee
* - (B) RFP is exempted on the framer and framee
* - (C) RFP is exempted on the framer but not the framee
* - (D) RFP is exempted on the framer but not the framee
* - (E) RFP is not exempted on the framer nor the framee
* - (F) RFP is not exempted on the framer nor the framee
*
* - (G) RFP is not exempted on the framer but is on the framee
* - (H) RFP is not exempted on the framer but is on the framee
*/
"use strict";
requestLongerTimeout(3);
ChromeUtils.defineModuleGetter(
this,
"AppConstants",
"resource://gre/modules/AppConstants.jsm"
);
// =============================================================================================
// =============================================================================================
async function testTimePrecision(results, expectedResults, extraData) {
let testDesc = extraData.testDesc;
let precision = undefined;
if (!expectedResults.shouldRFPApply) {
precision = extraData.Unconditional_Precision;
} else {
precision = extraData.RFP_Precision;
}
for (let result of results) {
if ("error" in result) {
ok(false, result.error);
continue;
}
let isRounded = isTimeValueRounded(result.value, precision);
ok(
isRounded,
"Test: " +
testDesc +
" - '" +
"'" +
result.name +
"' should be rounded to nearest " +
precision +
" ms; saw " +
result.value
);
}
}
const RFP_TIME_ATOM_MS = 16.667;
const framer_domain = "example.com";
const iframe_domain = "example.org";
const cross_origin_domain = "example.net";
const uri = `https://${framer_domain}/browser/browser/components/resistfingerprinting/test/browser/file_animationapi_iframer.html`;
// The first three variables are defined here; and then set for test banks below.
let extraData = {};
let extraPrefs = {};
let precision = 100;
let expectedResults = {}; // In this test, we don't have explicit expected values, but rather we expect them to be rounded
// ========================================================================================================================
// Create a function that defines all the tests
function addAllTests(extraData_, extraPrefs_) {
add_task(
partial(
defaultsTest,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
add_task(
partial(
simpleRFPTest,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (A) RFP is exempted on the framer and framee and each contacts an exempted cross-origin resource
add_task(
partial(
testA,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (B) RFP is exempted on the framer and framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testB,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (C) RFP is exempted on the framer but not the framee and each contacts an exempted cross-origin resource
add_task(
partial(
testC,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (D) RFP is exempted on the framer but not the framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testD,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (E) RFP is not exempted on the framer nor the framee and each contacts an exempted cross-origin resource
add_task(
partial(
testE,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (F) RFP is not exempted on the framer nor the framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testF,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (G) RFP is not exempted on the framer but is on the framee and each contacts an exempted cross-origin resource
add_task(
partial(
testG,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (H) RFP is not exempted on the framer but is on the framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testH,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
}
// ========================================================================================================================
// First we run through all the tests with RTP's precision set to 100 ms and 133 ms.
// Animation does _not_ obey RTP's timestamp, instead it falls back to the unconditional
// rounding which is 20 microseconds.
extraData = {
RFP_Precision: 100,
Unconditional_Precision: 0.02,
};
extraPrefs = [
[
"privacy.resistFingerprinting.reduceTimerPrecision.microseconds",
extraData.RFP_Precision * 1000,
],
["dom.animations-api.timelines.enabled", true],
];
addAllTests(extraData, extraPrefs);
extraData = {
RFP_Precision: 133,
Unconditional_Precision: 0.02,
};
extraPrefs = [
[
"privacy.resistFingerprinting.reduceTimerPrecision.microseconds",
extraData.RFP_Precision * 1000,
],
["dom.animations-api.timelines.enabled", true],
];
addAllTests(extraData, extraPrefs);
// ========================================================================================================================
// Then we run through all the tests with the precision set to its normal value.
// This will mean that in some cases we expect RFP to apply and in some we don't.
extraData = {
RFP_Precision: RFP_TIME_ATOM_MS,
Unconditional_Precision: 0.02,
};
extraPrefs = [["dom.animations-api.timelines.enabled", true]];
addAllTests(extraData, extraPrefs);

Просмотреть файл

@ -153,7 +153,7 @@ const SPOOFED_UA_GECKO_TRAIL = {
async function testUserAgentHeader() {
const BASE =
"http://mochi.test:8888/browser/browser/components/resistfingerprinting/test/browser/";
const TEST_TARGET_URL = `${BASE}file_navigator_header.sjs?`;
const TEST_TARGET_URL = `${BASE}browser_navigator_header.sjs?`;
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
TEST_TARGET_URL

Просмотреть файл

@ -170,8 +170,8 @@ const DEFAULT_HARDWARE_CONCURRENCY = navigator.hardwareConcurrency;
// =============================================================================================
// =============================================================================================
async function testNavigator(result, expectedResults, extraData) {
let testDesc = extraData.testDesc;
async function testNavigator(result, expectedResults) {
let testDesc = expectedResults.testDesc;
is(
result.appVersion,
@ -345,138 +345,372 @@ const iframe_domain = "example.org";
const cross_origin_domain = "example.net";
const uri = `https://${framer_domain}/browser/browser/components/resistfingerprinting/test/browser/file_navigator_iframer.html`;
requestLongerTimeout(2);
add_task(async function defaultsTest() {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = {};
let expectedResults = JSON.parse(JSON.stringify(allNotSpoofed));
expectedResults.testDesc = "default";
expectedResults = JSON.parse(JSON.stringify(allNotSpoofed));
add_task(
partial(
defaultsTest,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
testNavigator(result, expectedResults);
}
);
});
expectedResults = JSON.parse(JSON.stringify(allSpoofed));
add_task(
partial(
simpleRFPTest,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function simpleRFPTest() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.resistFingerprinting", true]],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.testDesc = "simple RFP enabled";
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (A) RFP is exempted on the framer and framee and each contacts an exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allNotSpoofed));
add_task(
partial(
testA,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testA() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.com, example.org, example.net",
],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allNotSpoofed));
expectedResults.testDesc = "test (A)";
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (B) RFP is exempted on the framer and framee and each contacts a non-exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allNotSpoofed));
add_task(
partial(
testB,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testB() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.com, example.org",
],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allNotSpoofed));
expectedResults.testDesc = "test (B)";
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (C) RFP is exempted on the framer but not the framee and each contacts an exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.framer_crossOrigin_userAgentHTTPHeader = defaultUserAgent;
expectedResults.framee_crossOrigin_userAgentHTTPHeader = spoofedUserAgentHeader;
add_task(
partial(
testC,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testC() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.com, example.net",
],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.testDesc = "test (C)";
expectedResults.framer_crossOrigin_userAgentHTTPHeader = defaultUserAgent;
expectedResults.framee_crossOrigin_userAgentHTTPHeader = spoofedUserAgentHeader;
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (D) RFP is exempted on the framer but not the framee and each contacts a non-exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.framer_crossOrigin_userAgentHTTPHeader = defaultUserAgent;
expectedResults.framee_crossOrigin_userAgentHTTPHeader = spoofedUserAgentHeader;
add_task(
partial(
testD,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testD() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", "example.com"],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.testDesc = "test (D)";
expectedResults.framer_crossOrigin_userAgentHTTPHeader = defaultUserAgent;
expectedResults.framee_crossOrigin_userAgentHTTPHeader = spoofedUserAgentHeader;
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (E) RFP is not exempted on the framer nor the framee and each contacts an exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allSpoofed));
add_task(
partial(
testE,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testE() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", "example.net"],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.testDesc = "test (E)";
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (F) RFP is not exempted on the framer nor the framee and each contacts a non-exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allSpoofed));
add_task(
partial(
testF,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testF() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", ""],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.testDesc = "test (F)";
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (G) RFP is not exempted on the framer but is on the framee and each contacts an exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allSpoofed));
add_task(
partial(
testG,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testG() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.org, example.net",
],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.testDesc = "test (G)";
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});
// (H) RFP is not exempted on the framer but is on the framee and each contacts a non-exempted cross-origin resource
expectedResults = JSON.parse(JSON.stringify(allSpoofed));
add_task(
partial(
testH,
uri,
iframe_domain,
cross_origin_domain,
testNavigator,
expectedResults
)
);
add_task(async function testH() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", "example.org"],
],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain],
async function(iframe_domain_, cross_origin_domain_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_
);
}
);
let expectedResults = JSON.parse(JSON.stringify(allSpoofed));
expectedResults.testDesc = "test (H)";
testNavigator(result, expectedResults);
}
);
await SpecialPowers.popPrefEnv();
});

Просмотреть файл

@ -1,270 +0,0 @@
/**
* This test only tests values in the iframe, it does not test them on the framer
*
* Covers the following cases:
* - RFP is disabled entirely
* - RFP is enabled entirely
* - (A) RFP is exempted on the framer and framee
* - (B) RFP is exempted on the framer and framee
* - (C) RFP is exempted on the framer but not the framee
* - (D) RFP is exempted on the framer but not the framee
* - (E) RFP is not exempted on the framer nor the framee
* - (F) RFP is not exempted on the framer nor the framee
*
* - (G) RFP is not exempted on the framer but is on the framee
* - (H) RFP is not exempted on the framer but is on the framee
*/
"use strict";
requestLongerTimeout(3);
ChromeUtils.defineModuleGetter(
this,
"AppConstants",
"resource://gre/modules/AppConstants.jsm"
);
// =============================================================================================
// =============================================================================================
async function testTimePrecision(results, expectedResults, extraData) {
let testDesc = extraData.testDesc;
let precision = undefined;
if (!expectedResults.shouldRFPApply) {
precision = extraData.RTP_Precision;
} else {
precision = extraData.RFP_Precision;
}
for (let result of results) {
let isRounded = isTimeValueRounded(result.value, precision);
ok(
isRounded,
"Test: " +
testDesc +
" - '" +
"'" +
result.name +
"' should be rounded to nearest " +
precision +
" ms; saw " +
result.value
);
}
}
const RFP_TIME_ATOM_MS = 16.667;
const framer_domain = "example.com";
const iframe_domain = "example.org";
const cross_origin_domain = "example.net";
const uri = `https://${framer_domain}/browser/browser/components/resistfingerprinting/test/browser/file_reduceTimePrecision_iframer.html`;
// The first three variables are defined here; and then set for test banks below.
let extraData = {};
let extraPrefs = {};
let precision = 100;
let expectedResults = {}; // In this test, we don't have explicit expected values, but rather we expect them to be rounded
// ========================================================================================================================
// Create a function that defines all the tests
function addAllTests(extraData_, extraPrefs_) {
add_task(
partial(
defaultsTest,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
add_task(
partial(
simpleRFPTest,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (A) RFP is exempted on the framer and framee and each contacts an exempted cross-origin resource
add_task(
partial(
testA,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (B) RFP is exempted on the framer and framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testB,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (C) RFP is exempted on the framer but not the framee and each contacts an exempted cross-origin resource
add_task(
partial(
testC,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (D) RFP is exempted on the framer but not the framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testD,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (E) RFP is not exempted on the framer nor the framee and each contacts an exempted cross-origin resource
add_task(
partial(
testE,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (F) RFP is not exempted on the framer nor the framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testF,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (G) RFP is not exempted on the framer but is on the framee and each contacts an exempted cross-origin resource
add_task(
partial(
testG,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
// (H) RFP is not exempted on the framer but is on the framee and each contacts a non-exempted cross-origin resource
add_task(
partial(
testH,
uri,
iframe_domain,
cross_origin_domain,
testTimePrecision,
expectedResults,
extraData_,
extraPrefs_
)
);
}
// ========================================================================================================================
// First we run through all the tests with RTP's precision set to 100 ms and 133 ms.
// Because 100ms and 133ms are >= RFP's precision of 100ms, _all_ tests results should
// be rounded.
precision = 100;
extraData = {
RFP_Precision: precision,
RTP_Precision: precision,
};
extraPrefs = [
[
"privacy.resistFingerprinting.reduceTimerPrecision.microseconds",
precision * 1000,
],
];
addAllTests(extraData, extraPrefs);
precision = 133;
extraData = {
RFP_Precision: precision,
RTP_Precision: precision,
};
extraPrefs = [
[
"privacy.resistFingerprinting.reduceTimerPrecision.microseconds",
precision * 1000,
],
];
addAllTests(extraData, extraPrefs);
// ========================================================================================================================
// Then we run through all the tests with the precision set to its normal value.
// This will mean that in some cases we expect RFP to apply and in some we don't.
precision = RFP_TIME_ATOM_MS;
extraData = {
RFP_Precision: precision,
RTP_Precision: 1,
};
extraPrefs = [];
addAllTests(extraData, extraPrefs);
// ========================================================================================================================
// Finally we run through all the tests with the precision set to an unusual value
// This will mean that in some cases we expect RFP to apply and in some we don't.
precision = RFP_TIME_ATOM_MS;
extraData = {
RFP_Precision: RFP_TIME_ATOM_MS,
RTP_Precision: 7,
};
extraPrefs = [
["privacy.resistFingerprinting.reduceTimerPrecision.microseconds", 7 * 1000],
];
addAllTests(extraData, extraPrefs);

Просмотреть файл

@ -1,85 +0,0 @@
<!DOCTYPE html>
<head>
<meta charset="utf8">
<script>
function waitForCondition(aCond, aCallback, aErrorMsg) {
var tries = 0;
var interval = setInterval(() => {
if (tries >= 30) {
result.push({
'error': `Exceeded 30 tries waiting for animation`
})
clearInterval(interval);
parent.postMessage(result, "*");
return;
}
var conditionPassed;
try {
conditionPassed = aCond();
} catch (e) {
result.push({
'error': `${e}\n${e.stack}`
})
clearInterval(interval);
parent.postMessage(result, "*")
return;
}
if (conditionPassed) {
clearInterval(interval);
aCallback();
}
tries++;
}, 100);
}
window.onload = async () => {
parent.postMessage("ready", "*");
}
var result = [];
window.addEventListener("message", async function listener(event) {
if (event.data[0] == "gimme") {
const testDiv = document.getElementById("testDiv");
const animation = testDiv.animate({ opacity: [0, 1] }, 100000);
animation.play();
waitForCondition(
() => animation.currentTime > 100,
() => {
result.push({
'name': 'animation.startTime',
'value': animation.startTime
});
result.push({
'name': 'animation.currentTime',
'value': animation.currentTime
});
result.push({
'name': 'animation.timeline.currentTime',
'value': animation.timeline.currentTime
});
if (document.timeline) {
result.push({
'name': 'document.timeline.currentTime',
'value': document.timeline.currentTime
});
}
parent.postMessage(result, "*")
},
"animation failed to start");
}
});
</script>
</head>
<body>
<div id="testDiv">test</div>
</body>
</html>

Просмотреть файл

@ -1,41 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function waitForMessage(aMsg, aOrigin) {
return new Promise(resolve => {
window.addEventListener("message", function listener(event) {
if (event.data == "ready" && event.origin == aOrigin) {
window.removeEventListener("message", listener);
resolve();
}
});
});
}
async function runTheTest(iframe_domain, cross_origin_domain, extraData) {
const iframes = document.querySelectorAll("iframe");
iframes[0].src = `https://${iframe_domain}/browser/browser/components/resistfingerprinting/test/browser/file_animationapi_iframee.html`;
await waitForMessage("ready", `https://${iframe_domain}`);
const promiseForRFPTest = new Promise(resolve => {
window.addEventListener("message", event => {
if(event.origin != `https://${iframe_domain}`) {
throw new Error(`origin should be ${iframe_domain}`);
}
resolve(event.data);
}, { once: true });
});
iframes[0].contentWindow.postMessage({0: "gimme", 1: cross_origin_domain}, "*");
var result = await promiseForRFPTest;
return result;
}
</script>
</head>
<body>
<iframe width=100></iframe>
</body>
</html>

Просмотреть файл

@ -40,13 +40,13 @@ window.addEventListener("message", async function listener(event) {
result.worker_product = worker_result.product;
result.worker_hardwareConcurrency = worker_result.hardwareConcurrency;
var one = fetch("file_navigator_header.sjs?")
var one = fetch("browser_navigator_header.sjs?")
.then((response) => { return response.text(); })
.then((content) => {
result.userAgentHTTPHeader = content;
});
var two = fetch(`https://${cross_origin_domain}/browser/browser/components/resistfingerprinting/test/browser/file_navigator_header.sjs?`)
var two = fetch(`https://${cross_origin_domain}/browser/browser/components/resistfingerprinting/test/browser/browser_navigator_header.sjs?`)
.then((response) => { return response.text(); })
.then((content) => {
result.framee_crossOrigin_userAgentHTTPHeader = content;

Просмотреть файл

@ -1,6 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<!--
Tests that an exempted iframe embedded in a non-exempted first party domain is not exempted.
-->
<meta charset="utf-8">
<title></title>
<script>
@ -31,7 +34,7 @@ async function runTheTest(iframe_domain, cross_origin_domain) {
iframes[0].contentWindow.postMessage({0: "gimme", 1: cross_origin_domain}, "*");
var result = await promiseForRFPTest;
await fetch(`https://${cross_origin_domain}/browser/browser/components/resistfingerprinting/test/browser/file_navigator_header.sjs?`)
await fetch(`https://${cross_origin_domain}/browser/browser/components/resistfingerprinting/test/browser/browser_navigator_header.sjs?`)
.then((response) => { return response.text(); })
.then((content) => {
result.framer_crossOrigin_userAgentHTTPHeader = content;

Просмотреть файл

@ -1,34 +0,0 @@
"use strict";
function handleRequest(request, response) {
response.setHeader("Content-Type", "application/javascript");
let content = `onconnect = function(e) {
let port = e.ports[0];
let navigatorObj = self.navigator;
let result = [];
// Known ways to generate time stamps, in milliseconds
const timeStampCodes = [
'performance.now()',
'new Date().getTime()',
'new Event("").timeStamp',
'new File([], "").lastModified',
];
for (let timeStampCode of timeStampCodes) {
let timeStamp = eval(timeStampCode);
result.push({
'name': 'worker ' + timeStampCode,
'value': timeStamp
});
}
port.postMessage(result);
port.start();
};`;
response.write(content);
}

Просмотреть файл

@ -1,52 +0,0 @@
<!DOCTYPE html>
<meta charset="utf8">
<script>
window.onload = async () => {
parent.postMessage("ready", "*");
}
window.addEventListener("message", async function listener(event) {
if (event.data[0] == "gimme") {
var result = [];
// Prepare for test of AudioContext.currentTime
// eslint-disable-next-line
let audioContext = new AudioContext();
// Known ways to generate time stamps, in milliseconds
const timeStampCodes = [
"performance.now()",
"new Date().getTime()",
"new Event(\"\").timeStamp",
"new File([], \"\").lastModified",
];
// These are measured in seconds, so we need to scale them up
var timeStampCodesDOM = timeStampCodes.concat([
"audioContext.currentTime * 1000",
]);
for (let timeStampCode of timeStampCodesDOM) {
// eslint-disable-next-line no-eval
let timeStamp = eval(timeStampCode);
result.push({
'name': timeStampCode,
'value': timeStamp
});
}
let worker = new SharedWorker("file_reduceTimePrecision_iframe_worker.sjs");
let worker_result = await new Promise(resolve => {
worker.port.onmessage = function(e) {
resolve(e.data);
};
});
for (let item of worker_result) {
result.push(item);
}
parent.postMessage(result, "*")
}
});
</script>

Просмотреть файл

@ -1,41 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function waitForMessage(aMsg, aOrigin) {
return new Promise(resolve => {
window.addEventListener("message", function listener(event) {
if (event.data == "ready" && event.origin == aOrigin) {
window.removeEventListener("message", listener);
resolve();
}
});
});
}
async function runTheTest(iframe_domain, cross_origin_domain, extraData) {
const iframes = document.querySelectorAll("iframe");
iframes[0].src = `https://${iframe_domain}/browser/browser/components/resistfingerprinting/test/browser/file_reduceTimePrecision_iframee.html`;
await waitForMessage("ready", `https://${iframe_domain}`);
const promiseForRFPTest = new Promise(resolve => {
window.addEventListener("message", event => {
if(event.origin != `https://${iframe_domain}`) {
throw new Error(`origin should be ${iframe_domain}`);
}
resolve(event.data);
}, { once: true });
});
iframes[0].contentWindow.postMessage({0: "gimme", 1: cross_origin_domain}, "*");
var result = await promiseForRFPTest;
return result;
}
</script>
</head>
<body>
<iframe width=100></iframe>
</body>
</html>

Просмотреть файл

@ -585,391 +585,3 @@ class OpenTest extends RoundedWindowTest {
);
}
}
// ============================================================
const partial = (func, ...args) => (...rest) => func(...args, ...rest);
async function runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
) {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: uri,
},
async function(browser) {
let result = await SpecialPowers.spawn(
browser,
[iframe_domain, cross_origin_domain, extraData],
async function(iframe_domain_, cross_origin_domain_, extraData_) {
return content.wrappedJSObject.runTheTest(
iframe_domain_,
cross_origin_domain_,
extraData_
);
}
);
testFunction(result, expectedResults, extraData);
}
);
}
async function defaultsTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "default";
expectedResults.shouldRFPApply = false;
if (extraPrefs != undefined) {
await SpecialPowers.pushPrefEnv({
set: extraPrefs,
});
}
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
if (extraPrefs != undefined) {
await SpecialPowers.popPrefEnv();
}
}
async function simpleRFPTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "simple RFP enabled";
expectedResults.shouldRFPApply = true;
await SpecialPowers.pushPrefEnv({
set: [["privacy.resistFingerprinting", true]].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (A) RFP is exempted on the framer and framee and each contacts an exempted cross-origin resource
async function testA(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (A)";
expectedResults.shouldRFPApply = false;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.com, example.org, example.net",
],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (B) RFP is exempted on the framer and framee and each contacts a non-exempted cross-origin resource
async function testB(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (B)";
expectedResults.shouldRFPApply = false;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.com, example.org",
],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (C) RFP is exempted on the framer but not the framee and each contacts an exempted cross-origin resource
async function testC(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (C)";
expectedResults.shouldRFPApply = true;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.com, example.net",
],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (D) RFP is exempted on the framer but not the framee and each contacts a non-exempted cross-origin resource
async function testD(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (D)";
expectedResults.shouldRFPApply = true;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", "example.com"],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (E) RFP is not exempted on the framer nor the framee and each contacts an exempted cross-origin resource
async function testE(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (E)";
expectedResults.shouldRFPApply = true;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", "example.net"],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (F) RFP is not exempted on the framer nor the framee and each contacts a non-exempted cross-origin resource
async function testF(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (F)";
expectedResults.shouldRFPApply = true;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", ""],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (G) RFP is not exempted on the framer but is on the framee and each contacts an exempted cross-origin resource
async function testG(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (G)";
expectedResults.shouldRFPApply = true;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
[
"privacy.resistFingerprinting.exemptedDomains",
"example.org, example.net",
],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}
// (H) RFP is not exempted on the framer but is on the framee and each contacts a non-exempted cross-origin resource
async function testH(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData,
extraPrefs
) {
if (extraData == undefined) {
extraData = {};
}
extraData.testDesc = "test (H)";
expectedResults.shouldRFPApply = true;
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.resistFingerprinting.testGranularityMask", 4],
["privacy.resistFingerprinting.exemptedDomains", "example.org"],
].concat(extraPrefs || []),
});
await runActualTest(
uri,
iframe_domain,
cross_origin_domain,
testFunction,
expectedResults,
extraData
);
await SpecialPowers.popPrefEnv();
}

Просмотреть файл

@ -13,6 +13,7 @@ support-files =
[test_geolocation.html]
scheme = https
fail-if = xorigin
[test_reduce_time_precision.html]
[test_hide_gamepad_info.html]
scheme = https
support-files = test_hide_gamepad_info_iframe.html

Просмотреть файл

@ -0,0 +1,208 @@
<!DOCTYPE HTML>
<html>
<!--
Tor bug
https://trac.torproject.org/projects/tor/ticket/1517
-->
<head>
<meta charset="utf-8">
<title>Test for Tor Bug 1517 and Mozilla Bug 1424341</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://trac.torproject.org/projects/tor/ticket/1517">Tor Bug 1517</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1424341">Mozilla Bug 1424341</a>
<!-- The main testing script -->
<script type="application/javascript">
SimpleTest.requestFlakyTimeout("testing JS time-based fingerprinting");
// Prepare for test of AudioContext.currentTime
let audioContext = new AudioContext();
// Known ways to generate time stamps, in milliseconds
const timeStampCodes = [
"performance.now()",
"new Date().getTime()",
"new Event(\"\").timeStamp",
"new File([], \"\").lastModified",
];
// These are measured in seconds, so we need to scale them up
var timeStampCodesDOM = timeStampCodes.concat([
"audioContext.currentTime * 1000",
]);
// From browser/components/resistfingerprinting/test/browser/head.js:
function isTimeValueRounded(x, expectedPrecision) {
const nearestExpected = Math.round(x / expectedPrecision) * expectedPrecision;
// First we do the perfectly normal check that should work just fine
if (x === nearestExpected)
return true;
// When we're diving by non-whole numbers, we may not get perfect
// multiplication/division because of floating points.
// When dealing with ms since epoch, a double's precision is on the order
// of 1/5 of a microsecond, so we use a value a little higher than that as
// our epsilon.
// To be clear, this error is introduced in our re-calculation of 'rounded'
// above in JavaScript.
const error = Math.abs(x - nearestExpected);
if (Math.abs(error) < .0005) {
return true;
}
// Then we handle the case where you're sub-millisecond and the timer is not
// We check that the timer is not sub-millisecond by assuming it is not if it
// returns an even number of milliseconds
if (Math.round(expectedPrecision) != expectedPrecision && Math.round(x) == x) {
let acceptableIntRounding = false;
acceptableIntRounding |= (Math.floor(nearestExpected) == x);
acceptableIntRounding |= (Math.ceil(nearestExpected) == x);
if (acceptableIntRounding) {
return true;
}
}
ok(false, "Looming Test Failure, Additional Debugging Info: Expected Precision: " + expectedPrecision + " Measured Value: " + x +
" Nearest Expected Vaue: " + nearestExpected + " Error: " + error);
return false;
}
// ================================================================================================
// ================================================================================================
async function checkWorker(worker, prefname, expectedPrecision) {
// The child worker will send the results back.
let checkWorkerTimeStamps = () => new Promise(function(resolve) {
let onMessage = function(event) {
worker.removeEventListener("message", onMessage);
let timeStamps = event.data;
for (let i = 0; i < timeStampCodes.length; i++) {
let timeStamp = timeStamps[i];
ok(isTimeValueRounded(timeStamp, expectedPrecision),
"pref: " + prefname + " - '" +
"'" + timeStampCodes[i] +
"' should be rounded to nearest " + expectedPrecision + " ms in workers; saw " +
timeStamp);
}
resolve();
};
worker.addEventListener("message", onMessage);
});
// Send the codes to its child worker.
worker.postMessage(timeStampCodes);
// First, check the child's results.
await checkWorkerTimeStamps();
// Then, check the grandchild's results.
await checkWorkerTimeStamps();
worker.terminate();
}
async function testWorker(resistFingerprinting, reduceTimerPrecision, expectedPrecision) {
let prefname = "";
prefname += resistFingerprinting ? "privacy.resistFingerprinting " : "";
prefname += reduceTimerPrecision ? "privacy.reduceTimerPrecision " : "";
// Create one worker before setting the pref, and one after, in order to
// check that the resolution is updated whether or not the worker was
// already started
let worker1 = new Worker("worker_child.js");
await SpecialPowers.pushPrefEnv({
"set": [["privacy.resistFingerprinting", resistFingerprinting],
["privacy.reduceTimerPrecision", reduceTimerPrecision],
["privacy.resistFingerprinting.reduceTimerPrecision.microseconds", expectedPrecision * 1000],
]});
// No matter what we set the precision to, if we're in ResistFingerprinting mode
// we use the larger of the precision pref and the RFP time-atom constant
if (resistFingerprinting) {
const RFP_TIME_ATOM_MS = 16.667;
expectedPrecision = Math.max(RFP_TIME_ATOM_MS, expectedPrecision);
}
let worker2 = new Worker("worker_child.js");
// Allow ~550 ms to elapse, so we can get non-zero
// time values for all elements.
await new Promise(resolve => window.setTimeout(resolve, 550));
await checkWorker(worker1, prefname, expectedPrecision);
await checkWorker(worker2, prefname, expectedPrecision);
}
add_task(async function testWorkerRFP() {
await testWorker(true, false, 100);
await testWorker(true, false, 13);
await testWorker(true, false, .13);
});
add_task(async function testWorkerRTP() {
await testWorker(false, true, 100);
await testWorker(false, true, 13);
await testWorker(false, true, .13);
});
// ================================================================================================
// ================================================================================================
async function testDOM(resistFingerprinting, reduceTimerPrecision, expectedPrecision) {
let prefname = "";
prefname += resistFingerprinting ? "privacy.resistFingerprinting " : "";
prefname += reduceTimerPrecision ? "privacy.reduceTimerPrecision " : "";
await SpecialPowers.pushPrefEnv({
"set": [["privacy.resistFingerprinting", resistFingerprinting],
["privacy.reduceTimerPrecision", reduceTimerPrecision],
["privacy.resistFingerprinting.reduceTimerPrecision.microseconds", expectedPrecision * 1000],
]});
// No matter what we set the precision to, if we're in ResistFingerprinting mode
// we use the larger of the precision pref and the constant RFP time-atom
if (resistFingerprinting) {
const RFP_TIME_ATOM_MS = 16.667;
expectedPrecision = Math.max(RFP_TIME_ATOM_MS, expectedPrecision);
}
// Loop through each timeStampCode, evaluate it,
// and check if it is rounded
for (let timeStampCode of timeStampCodesDOM) {
let timeStamp = eval(timeStampCode);
// Audio Contexts increment in intervals of (minimum) 5.4ms, so we don't
// clamp/jitter if the timer precision is les than that.
// (Technically on MBPs they increment in intervals of 2.6 but this is
// non-standard and will eventually be changed. We don't cover this situation
// because we don't really support arbitrary Timer Precision, especially in
// the 2.6 - 5.4ms interval.)
if (timeStampCode.includes("audioContext") && expectedPrecision < 5.4)
continue;
ok(isTimeValueRounded(timeStamp, expectedPrecision),
"pref: " + prefname + " - '" +
"'" + timeStampCode +
"' should be rounded to nearest " +
expectedPrecision + " ms; saw " +
timeStamp);
}
}
add_task(async function testDOMRFP() {
await testDOM(true, true, 100);
await testDOM(true, false, 13);
await testDOM(true, false, .13);
});
add_task(async function testDOMRTP() {
await testDOM(false, true, 100);
await testDOM(false, true, 13);
await testDOM(false, true, .13);
});
</script>
</body>
</html>

Просмотреть файл

@ -83,9 +83,7 @@ class MOZ_RAII AutoMutationBatchForAnimation {
// ---------------------------------------------------------------------------
Animation::Animation(nsIGlobalObject* aGlobal)
: DOMEventTargetHelper(aGlobal),
mAnimationIndex(sNextAnimationIndex++),
mRTPCallerType(aGlobal->RTPCallerType()) {}
: DOMEventTargetHelper(aGlobal), mAnimationIndex(sNextAnimationIndex++) {}
Animation::~Animation() = default;
@ -142,14 +140,14 @@ already_AddRefed<Animation> Animation::Constructor(
const GlobalObject& aGlobal, AnimationEffect* aEffect,
const Optional<AnimationTimeline*>& aTimeline, ErrorResult& aRv) {
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
RefPtr<Animation> animation = new Animation(global);
AnimationTimeline* timeline;
Document* document =
AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
if (aTimeline.WasPassed()) {
timeline = aTimeline.Value();
} else {
Document* document =
AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
if (!document) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
@ -157,7 +155,6 @@ already_AddRefed<Animation> Animation::Constructor(
timeline = document->Timeline();
}
RefPtr<Animation> animation = new Animation(global);
animation->SetTimelineNoUpdate(timeline);
animation->SetEffectNoUpdate(aEffect);
@ -875,7 +872,7 @@ void Animation::CommitStyles(ErrorResult& aRv) {
// ---------------------------------------------------------------------------
Nullable<double> Animation::GetStartTimeAsDouble() const {
return AnimationUtils::TimeDurationToDouble(mStartTime, mRTPCallerType);
return AnimationUtils::TimeDurationToDouble(mStartTime);
}
void Animation::SetStartTimeAsDouble(const Nullable<double>& aStartTime) {
@ -883,8 +880,7 @@ void Animation::SetStartTimeAsDouble(const Nullable<double>& aStartTime) {
}
Nullable<double> Animation::GetCurrentTimeAsDouble() const {
return AnimationUtils::TimeDurationToDouble(GetCurrentTimeAsDuration(),
mRTPCallerType);
return AnimationUtils::TimeDurationToDouble(GetCurrentTimeAsDuration());
}
void Animation::SetCurrentTimeAsDouble(const Nullable<double>& aCurrentTime,

Просмотреть файл

@ -11,7 +11,6 @@
#include "nsCycleCollectionParticipant.h"
#include "mozilla/AnimationPerformanceWarning.h"
#include "mozilla/Attributes.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/EffectCompositor.h" // For EffectCompositor::CascadeLevel
#include "mozilla/LinkedList.h"
@ -676,9 +675,6 @@ class Animation : public DOMEventTargetHelper,
bool mResetCurrentTimeOnResume = false;
// Whether the Animation is System, ResistFingerprinting, or neither
RTPCallerType mRTPCallerType;
private:
// The id for this animaiton on the compositor.
uint64_t mIdOnCompositor = 0;

Просмотреть файл

@ -35,9 +35,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AnimationEffect)
NS_INTERFACE_MAP_END
AnimationEffect::AnimationEffect(Document* aDocument, TimingParams&& aTiming)
: mDocument(aDocument), mTiming(std::move(aTiming)) {
mRTPCallerType = mDocument->GetScopeObject()->RTPCallerType();
}
: mDocument(aDocument), mTiming(std::move(aTiming)) {}
AnimationEffect::~AnimationEffect() = default;
@ -318,8 +316,7 @@ void AnimationEffect::GetComputedTimingAsDict(
aRetVal.mFill = computedTiming.mFill;
aRetVal.mActiveDuration = computedTiming.mActiveDuration.ToMilliseconds();
aRetVal.mEndTime = computedTiming.mEndTime.ToMilliseconds();
aRetVal.mLocalTime =
AnimationUtils::TimeDurationToDouble(currentTime, mRTPCallerType);
aRetVal.mLocalTime = AnimationUtils::TimeDurationToDouble(currentTime);
aRetVal.mProgress = computedTiming.mProgress;
if (!aRetVal.mProgress.IsNull()) {

Просмотреть файл

@ -106,9 +106,6 @@ class AnimationEffect : public nsISupports, public nsWrapperCache {
RefPtr<Animation> mAnimation;
TimingParams mTiming;
Maybe<TimingParams> mNormalizedTiming;
// Whether the Animation is System, ResistFingerprinting, or neither
enum RTPCallerType mRTPCallerType;
};
} // namespace dom

Просмотреть файл

@ -25,9 +25,7 @@ class ScrollTimeline;
class AnimationTimeline : public nsISupports, public nsWrapperCache {
public:
explicit AnimationTimeline(nsIGlobalObject* aWindow,
RTPCallerType aRTPCallerType)
: mWindow(aWindow), mRTPCallerType(aRTPCallerType) {
explicit AnimationTimeline(nsIGlobalObject* aWindow) : mWindow(aWindow) {
MOZ_ASSERT(mWindow);
}
@ -50,8 +48,7 @@ class AnimationTimeline : public nsISupports, public nsWrapperCache {
// Wrapper functions for AnimationTimeline DOM methods when called from
// script.
Nullable<double> GetCurrentTimeAsDouble() const {
return AnimationUtils::TimeDurationToDouble(GetCurrentTimeAsDuration(),
mRTPCallerType);
return AnimationUtils::TimeDurationToDouble(GetCurrentTimeAsDuration());
}
TimeStamp GetCurrentTimeAsTimeStamp() const {
@ -108,8 +105,6 @@ class AnimationTimeline : public nsISupports, public nsWrapperCache {
virtual bool IsMonotonicallyIncreasing() const = 0;
RTPCallerType RTPCallerType() const { return mRTPCallerType; }
virtual bool IsScrollTimeline() const { return false; }
virtual const ScrollTimeline* AsScrollTimeline() const { return nullptr; }
@ -134,9 +129,6 @@ class AnimationTimeline : public nsISupports, public nsWrapperCache {
typedef nsTHashSet<nsRefPtrHashKey<dom::Animation>> AnimationSet;
AnimationSet mAnimations;
LinkedList<dom::Animation> mAnimationOrder;
// Whether the Timeline is System, ResistFingerprinting, or neither
enum RTPCallerType mRTPCallerType;
};
} // namespace mozilla::dom

Просмотреть файл

@ -31,7 +31,7 @@ class AnimationUtils {
using Document = dom::Document;
static dom::Nullable<double> TimeDurationToDouble(
const dom::Nullable<TimeDuration>& aTime, RTPCallerType aRTPCallerType) {
const dom::Nullable<TimeDuration>& aTime) {
dom::Nullable<double> result;
if (!aTime.IsNull()) {
@ -40,7 +40,7 @@ class AnimationUtils {
// only clamping for RFP mode. RFP mode gives a much lower time precision,
// so we accept the security leak here for now
result.SetValue(nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(
aTime.Value().ToMilliseconds(), 0, aRTPCallerType));
aTime.Value().ToMilliseconds(), 0));
}
return result;

Просмотреть файл

@ -227,8 +227,8 @@ void CSSAnimation::QueueEvents(const StickyTimeDuration& aActiveTime) {
// That is to say, whenever elapsedTime goes negative (because an
// animation restarts, something rewinds the animation, or otherwise)
// a new random value for the mix-in must be generated.
elapsedTime = nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(
elapsedTime, 0, mRTPCallerType);
elapsedTime =
nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(elapsedTime, 0);
}
events.AppendElement(
AnimationEventInfo(mAnimationName, mOwningElement.Target(), aMessage,

Просмотреть файл

@ -116,8 +116,8 @@ void CSSTransition::QueueEvents(const StickyTimeDuration& aActiveTime) {
// That is to say, whenever elapsedTime goes negative (because an
// animation restarts, something rewinds the animation, or otherwise)
// a new random value for the mix-in must be generated.
elapsedTime = nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(
elapsedTime, 0, mRTPCallerType);
elapsedTime =
nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(elapsedTime, 0);
}
events.AppendElement(AnimationEventInfo(
TransitionProperty(), mOwningElement.Target(), aMessage, elapsedTime,

Просмотреть файл

@ -42,8 +42,7 @@ NS_IMPL_RELEASE_INHERITED(DocumentTimeline, AnimationTimeline)
DocumentTimeline::DocumentTimeline(Document* aDocument,
const TimeDuration& aOriginTime)
: AnimationTimeline(aDocument->GetParentObject(),
aDocument->GetScopeObject()->RTPCallerType()),
: AnimationTimeline(aDocument->GetParentObject()),
mDocument(aDocument),
mIsObservingRefreshDriver(false),
mOriginTime(aOriginTime) {

Просмотреть файл

@ -43,8 +43,7 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(ScrollTimeline,
ScrollTimeline::ScrollTimeline(Document* aDocument, const Scroller& aScroller,
StyleScrollAxis aAxis)
: AnimationTimeline(aDocument->GetParentObject(),
aDocument->GetScopeObject()->RTPCallerType()),
: AnimationTimeline(aDocument->GetParentObject()),
mDocument(aDocument),
mSource(aScroller),
mAxis(aAxis) {

Просмотреть файл

@ -1629,9 +1629,7 @@ bool nsGlobalWindowInner::ShouldResistFingerprinting() const {
if (mDoc) {
return mDoc->ShouldResistFingerprinting();
}
return nsContentUtils::ShouldResistFingerprinting(
"If we do not have a document then we do not have any context"
"to make an informed RFP choice, so we fall back to the global pref");
return nsIScriptGlobalObject::ShouldResistFingerprinting();
}
OriginTrials nsGlobalWindowInner::Trials() const {

Просмотреть файл

@ -1670,9 +1670,7 @@ bool nsGlobalWindowOuter::ShouldResistFingerprinting() const {
if (mDoc) {
return mDoc->ShouldResistFingerprinting();
}
return nsContentUtils::ShouldResistFingerprinting(
"If we do not have a document then we do not have any context"
"to make an informed RFP choice, so we fall back to the global pref");
return nsIScriptGlobalObject::ShouldResistFingerprinting();
}
uint32_t nsGlobalWindowOuter::GetPrincipalHashValue() const {
@ -2015,25 +2013,22 @@ static JS::RealmCreationOptions& SelectZone(
* to manage the lifetime of it.
*/
static nsresult CreateNativeGlobalForInner(
JSContext* aCx, nsGlobalWindowInner* aNewInner, Document* aDocument,
JS::MutableHandle<JSObject*> aGlobal, bool aIsSecureContext,
bool aDefineSharedArrayBufferConstructor) {
JSContext* aCx, nsGlobalWindowInner* aNewInner, nsIURI* aURI,
nsIPrincipal* aPrincipal, JS::MutableHandle<JSObject*> aGlobal,
bool aIsSecureContext, bool aDefineSharedArrayBufferConstructor) {
MOZ_ASSERT(aCx);
MOZ_ASSERT(aNewInner);
nsCOMPtr<nsIURI> uri = aDocument->GetDocumentURI();
nsCOMPtr<nsIPrincipal> principal = aDocument->NodePrincipal();
MOZ_ASSERT(principal);
MOZ_ASSERT(aPrincipal);
// DOMWindow with nsEP is not supported, we have to make sure
// no one creates one accidentally.
nsCOMPtr<nsIExpandedPrincipal> nsEP = do_QueryInterface(principal);
nsCOMPtr<nsIExpandedPrincipal> nsEP = do_QueryInterface(aPrincipal);
MOZ_RELEASE_ASSERT(!nsEP, "DOMWindow with nsEP is not supported");
JS::RealmOptions options;
JS::RealmCreationOptions& creationOptions = options.creationOptions();
SelectZone(aCx, principal, aNewInner, creationOptions);
SelectZone(aCx, aPrincipal, aNewInner, creationOptions);
creationOptions.setSecureContext(aIsSecureContext);
@ -2046,16 +2041,15 @@ static nsresult CreateNativeGlobalForInner(
creationOptions.setDefineSharedArrayBufferConstructor(
aDefineSharedArrayBufferConstructor);
xpc::InitGlobalObjectOptions(options, principal->IsSystemPrincipal(),
aDocument->ShouldResistFingerprinting());
xpc::InitGlobalObjectOptions(options, aPrincipal);
// Determine if we need the Components object.
bool needComponents = principal->IsSystemPrincipal();
bool needComponents = aPrincipal->IsSystemPrincipal();
uint32_t flags = needComponents ? 0 : xpc::OMIT_COMPONENTS_OBJECT;
flags |= xpc::DONT_FIRE_ONNEWGLOBALHOOK;
if (!Window_Binding::Wrap(aCx, aNewInner, aNewInner, options,
nsJSPrincipals::get(principal), false, aGlobal) ||
nsJSPrincipals::get(aPrincipal), false, aGlobal) ||
!xpc::InitGlobalObject(aCx, aGlobal, flags)) {
return NS_ERROR_FAILURE;
}
@ -2064,7 +2058,7 @@ static nsresult CreateNativeGlobalForInner(
// Set the location information for the new global, so that tools like
// about:memory may use that information
xpc::SetLocationForGlobal(aGlobal, uri);
xpc::SetLocationForGlobal(aGlobal, aURI);
if (!InitializeLegacyNetscapeObject(aCx, aGlobal)) {
return NS_ERROR_FAILURE;
@ -2258,7 +2252,8 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
// Every script context we are initialized with must create a
// new global.
rv = CreateNativeGlobalForInner(
cx, newInnerWindow, aDocument, &newInnerGlobal,
cx, newInnerWindow, aDocument->GetDocumentURI(),
aDocument->NodePrincipal(), &newInnerGlobal,
ComputeIsSecureContext(aDocument),
newInnerWindow->IsSharedMemoryAllowedInternal(
aDocument->NodePrincipal()));
@ -5470,9 +5465,9 @@ void nsGlobalWindowOuter::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
CheckForDPIChange();
}
void nsGlobalWindowOuter::SizeToContentOuter(
CallerType aCallerType, const SizeToContentConstraints& aConstraints,
ErrorResult& aError) {
void nsGlobalWindowOuter::SizeToContentOuter(CallerType aCallerType,
const SizeToContentConstraints& aConstraints,
ErrorResult& aError) {
if (!mDocShell) {
return;
}
@ -5494,8 +5489,7 @@ void nsGlobalWindowOuter::SizeToContentOuter(
return aError.Throw(NS_ERROR_FAILURE);
}
auto contentSize = cv->GetContentSize(
aConstraints.mMaxWidth, aConstraints.mMaxHeight, aConstraints.mPrefWidth);
auto contentSize = cv->GetContentSize(aConstraints.mMaxWidth, aConstraints.mMaxHeight, aConstraints.mPrefWidth);
if (!contentSize) {
return aError.Throw(NS_ERROR_FAILURE);
}

Просмотреть файл

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIGlobalObject.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/Result.h"
#include "mozilla/StorageAccess.h"
@ -69,7 +68,7 @@ nsIGlobalObject::~nsIGlobalObject() {
MOZ_DIAGNOSTIC_ASSERT(mEventTargetObjects.isEmpty());
}
nsIPrincipal* nsIGlobalObject::PrincipalOrNull() const {
nsIPrincipal* nsIGlobalObject::PrincipalOrNull() {
if (!NS_IsMainThread()) {
return nullptr;
}
@ -397,26 +396,3 @@ mozilla::Result<bool, nsresult> nsIGlobalObject::HasEqualStorageKey(
return mozilla::ipc::StorageKeysEqual(storageKey, aStorageKey);
}
bool nsIGlobalObject::IsSystemPrincipal() const {
MOZ_ASSERT(NS_IsMainThread(),
"Cannot ask nsIGlobalObject IsSystemPrincipal off-main-thread");
return PrincipalOrNull()->IsSystemPrincipal();
}
RTPCallerType nsIGlobalObject::RTPCallerType() const {
if (IsSystemPrincipal()) {
return RTPCallerType::SystemPrincipal;
}
if (ShouldResistFingerprinting()) {
return RTPCallerType::ResistFingerprinting;
}
if (CrossOriginIsolated()) {
return RTPCallerType::CrossOriginIsolated;
}
return RTPCallerType::Normal;
}

Просмотреть файл

@ -13,7 +13,6 @@
#include "mozilla/dom/DispatcherTrait.h"
#include "mozilla/dom/ServiceWorkerDescriptor.h"
#include "mozilla/OriginTrials.h"
#include "nsContentUtils.h"
#include "nsHashKeys.h"
#include "nsISupports.h"
#include "nsStringFwd.h"
@ -59,16 +58,6 @@ namespace JS::loader {
class ModuleLoaderBase;
} // namespace JS::loader
// Reduce Timer Precision (RTP) Caller Type
// This lives here because anything dealing with RTPCallerType determines it
// through this object.
enum class RTPCallerType : uint8_t {
Normal = 0,
SystemPrincipal = (1 << 0),
ResistFingerprinting = (1 << 1),
CrossOriginIsolated = (1 << 2)
};
/**
* See <https://developer.mozilla.org/en-US/docs/Glossary/Global_object>.
*/
@ -145,7 +134,7 @@ class nsIGlobalObject : public nsISupports,
bool HasJSGlobal() const { return GetGlobalJSObjectPreserveColor(); }
// This method is not meant to be overridden.
nsIPrincipal* PrincipalOrNull() const;
nsIPrincipal* PrincipalOrNull();
void RegisterHostObjectURI(const nsACString& aURI);
@ -253,9 +242,7 @@ class nsIGlobalObject : public nsISupports,
* Check whether we should avoid leaking distinguishing information to JS/CSS.
* https://w3c.github.io/fingerprinting-guidance/
*/
virtual bool ShouldResistFingerprinting() const = 0;
RTPCallerType RTPCallerType() const;
virtual bool ShouldResistFingerprinting() const;
/**
* Threadsafe way to get nsIPrincipal::GetHashValue for the associated
@ -281,8 +268,6 @@ class nsIGlobalObject : public nsISupports,
protected:
virtual ~nsIGlobalObject();
virtual bool IsSystemPrincipal() const;
void StartDying() { mIsDying = true; }
void StartForbiddingScript() { mIsScriptForbidden = true; }

Просмотреть файл

@ -13,7 +13,6 @@
#ifndef mozilla_dom_SimpleGlobalObject_h__
#define mozilla_dom_SimpleGlobalObject_h__
#include "nsContentUtils.h"
#include "nsIGlobalObject.h"
#include "nsWrapperCache.h"
#include "js/TypeDecls.h"
@ -73,12 +72,6 @@ class SimpleGlobalObject : public nsIGlobalObject, public nsWrapperCache {
MOZ_CRASH("SimpleGlobalObject doesn't use DOM bindings!");
}
bool ShouldResistFingerprinting() const override {
return nsContentUtils::ShouldResistFingerprinting(
"Presently we don't have enough context to make an informed decision"
"on JS Sandboxes. See 1782853");
}
private:
SimpleGlobalObject(JSObject* global, GlobalType type) : mType(type) {
SetWrapper(global);

Просмотреть файл

@ -28,7 +28,6 @@
#include "mozilla/dom/DocumentInlines.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/SVGUtils.h"
#include "mozilla/SVGOuterSVGFrame.h"
@ -762,7 +761,9 @@ double Event::TimeStamp() {
MOZ_ASSERT(mOwner->PrincipalOrNull());
return nsRFPService::ReduceTimePrecisionAsMSecs(
ret, perf->GetRandomTimelineSeed(), perf->RTPCallerType());
ret, perf->GetRandomTimelineSeed(),
mOwner->PrincipalOrNull()->IsSystemPrincipal(),
mOwner->CrossOriginIsolated());
}
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
@ -772,7 +773,8 @@ double Event::TimeStamp() {
return nsRFPService::ReduceTimePrecisionAsMSecs(
ret, workerPrivate->GetRandomTimelineSeed(),
workerPrivate->GlobalScope()->RTPCallerType());
workerPrivate->UsesSystemPrincipal(),
workerPrivate->CrossOriginIsolated());
}
void Event::Serialize(IPC::MessageWriter* aWriter,

Просмотреть файл

@ -64,10 +64,12 @@ void BaseBlobImpl::SetLastModificationDatePrecisely(int64_t aDate) {
mLastModificationDate = aDate;
}
void BaseBlobImpl::SetLastModificationDate(RTPCallerType aRTPCallerType,
void BaseBlobImpl::SetLastModificationDate(bool aCrossOriginIsolated,
int64_t aDate) {
return SetLastModificationDatePrecisely(
nsRFPService::ReduceTimePrecisionAsUSecs(aDate, 0, aRTPCallerType));
nsRFPService::ReduceTimePrecisionAsUSecs(aDate, 0,
/* aIsSystemPrincipal */ false,
aCrossOriginIsolated));
// mLastModificationDate is an absolute timestamp so we supply a zero
// context mix-in
}

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_dom_BaseBlobImpl_h
#define mozilla_dom_BaseBlobImpl_h
#include "nsIGlobalObject.h"
#include "mozilla/dom/BlobImpl.h"
#include "mozilla/ErrorResult.h"
@ -127,7 +126,7 @@ class BaseBlobImpl : public BlobImpl {
*/
static uint64_t NextSerialNumber();
void SetLastModificationDate(RTPCallerType aRTPCallerType, int64_t aDate);
void SetLastModificationDate(bool aCrossOriginIsolated, int64_t aDate);
void SetLastModificationDatePrecisely(int64_t aDate);
#ifdef DEBUG

Просмотреть файл

@ -148,8 +148,9 @@ already_AddRefed<File> Blob::ToFile(const nsAString& aName,
nsAutoString contentType;
mImpl->GetType(contentType);
RefPtr<MultipartBlobImpl> impl = MultipartBlobImpl::Create(
std::move(blobImpls), aName, contentType, mGlobal->RTPCallerType(), aRv);
RefPtr<MultipartBlobImpl> impl =
MultipartBlobImpl::Create(std::move(blobImpls), aName, contentType,
mGlobal->CrossOriginIsolated(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
@ -225,9 +226,9 @@ already_AddRefed<Blob> Blob::Constructor(
MakeValidBlobType(type);
impl->InitializeBlob(aData.Value(), type,
aBag.mEndings == EndingType::Native,
global->RTPCallerType(), aRv);
global->CrossOriginIsolated(), aRv);
} else {
impl->InitializeBlob(global->RTPCallerType(), aRv);
impl->InitializeBlob(global->CrossOriginIsolated(), aRv);
}
if (NS_WARN_IF(aRv.Failed())) {

Просмотреть файл

@ -14,7 +14,6 @@
#include "mozilla/dom/FileSystemUtils.h"
#include "mozilla/dom/Promise.h"
#include "nsIFile.h"
#include "nsContentUtils.h"
#include "nsXULAppAPI.h"
namespace mozilla::dom {
@ -59,7 +58,8 @@ already_AddRefed<File> File::CreateMemoryFileWithLastModifiedNow(
MOZ_ASSERT(aGlobal);
RefPtr<MemoryBlobImpl> blobImpl = MemoryBlobImpl::CreateWithLastModifiedNow(
aMemoryBuffer, aLength, aName, aContentType, aGlobal->RTPCallerType());
aMemoryBuffer, aLength, aName, aContentType,
aGlobal->CrossOriginIsolated());
MOZ_ASSERT(blobImpl);
RefPtr<File> file = File::Create(aGlobal, blobImpl);
@ -143,7 +143,7 @@ already_AddRefed<File> File::Constructor(const GlobalObject& aGlobal,
nsAutoString type(aBag.mType);
MakeValidBlobType(type);
impl->InitializeBlob(aData, type, aBag.mEndings == EndingType::Native,
global->RTPCallerType(), aRv);
global->CrossOriginIsolated(), aRv);
if (aRv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -28,9 +28,10 @@ already_AddRefed<MemoryBlobImpl> MemoryBlobImpl::CreateWithCustomLastModified(
// static
already_AddRefed<MemoryBlobImpl> MemoryBlobImpl::CreateWithLastModifiedNow(
void* aMemoryBuffer, uint64_t aLength, const nsAString& aName,
const nsAString& aContentType, RTPCallerType aRTPCallerType) {
int64_t lastModificationDate =
nsRFPService::ReduceTimePrecisionAsUSecs(PR_Now(), 0, aRTPCallerType);
const nsAString& aContentType, bool aCrossOriginIsolated) {
int64_t lastModificationDate = nsRFPService::ReduceTimePrecisionAsUSecs(
PR_Now(), 0,
/* aIsSystemPrincipal */ false, aCrossOriginIsolated);
return CreateWithCustomLastModified(aMemoryBuffer, aLength, aName,
aContentType, lastModificationDate);
}

Просмотреть файл

@ -27,7 +27,7 @@ class MemoryBlobImpl final : public BaseBlobImpl {
// File constructor.
static already_AddRefed<MemoryBlobImpl> CreateWithLastModifiedNow(
void* aMemoryBuffer, uint64_t aLength, const nsAString& aName,
const nsAString& aContentType, RTPCallerType aRTPCallerType);
const nsAString& aContentType, bool aCrossOriginIsolated);
// File constructor with custom lastModified attribue value. You should
// probably use CreateWithLastModifiedNow() instead of this one.

Просмотреть файл

@ -10,7 +10,6 @@
#include "mozilla/dom/FileBinding.h"
#include "mozilla/dom/UnionTypes.h"
#include "nsComponentManagerUtils.h"
#include "nsIGlobalObject.h"
#include "nsIMultiplexInputStream.h"
#include "nsReadableUtils.h"
#include "nsRFPService.h"
@ -26,11 +25,11 @@ using namespace mozilla::dom;
/* static */
already_AddRefed<MultipartBlobImpl> MultipartBlobImpl::Create(
nsTArray<RefPtr<BlobImpl>>&& aBlobImpls, const nsAString& aName,
const nsAString& aContentType, RTPCallerType aRTPCallerType,
const nsAString& aContentType, bool aCrossOriginIsolated,
ErrorResult& aRv) {
RefPtr<MultipartBlobImpl> blobImpl =
new MultipartBlobImpl(std::move(aBlobImpls), aName, aContentType);
blobImpl->SetLengthAndModifiedDate(Some(aRTPCallerType), aRv);
blobImpl->SetLengthAndModifiedDate(Some(aCrossOriginIsolated), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
@ -44,7 +43,7 @@ already_AddRefed<MultipartBlobImpl> MultipartBlobImpl::Create(
ErrorResult& aRv) {
RefPtr<MultipartBlobImpl> blobImpl =
new MultipartBlobImpl(std::move(aBlobImpls), aContentType);
blobImpl->SetLengthAndModifiedDate(/* aRTPCallerType */ Nothing(), aRv);
blobImpl->SetLengthAndModifiedDate(/* aCrossOriginIsolated */ Nothing(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
@ -178,16 +177,16 @@ already_AddRefed<BlobImpl> MultipartBlobImpl::CreateSlice(
return impl.forget();
}
void MultipartBlobImpl::InitializeBlob(RTPCallerType aRTPCallerType,
void MultipartBlobImpl::InitializeBlob(bool aCrossOriginIsolated,
ErrorResult& aRv) {
SetLengthAndModifiedDate(Some(aRTPCallerType), aRv);
SetLengthAndModifiedDate(Some(aCrossOriginIsolated), aRv);
NS_WARNING_ASSERTION(!aRv.Failed(), "SetLengthAndModifiedDate failed");
}
void MultipartBlobImpl::InitializeBlob(const Sequence<Blob::BlobPart>& aData,
const nsAString& aContentType,
bool aNativeEOL,
RTPCallerType aRTPCallerType,
bool aCrossOriginIsolated,
ErrorResult& aRv) {
mContentType = aContentType;
BlobSet blobSet;
@ -234,12 +233,12 @@ void MultipartBlobImpl::InitializeBlob(const Sequence<Blob::BlobPart>& aData,
}
mBlobImpls = blobSet.GetBlobImpls();
SetLengthAndModifiedDate(Some(aRTPCallerType), aRv);
SetLengthAndModifiedDate(Some(aCrossOriginIsolated), aRv);
NS_WARNING_ASSERTION(!aRv.Failed(), "SetLengthAndModifiedDate failed");
}
void MultipartBlobImpl::SetLengthAndModifiedDate(
const Maybe<RTPCallerType>& aRTPCallerType, ErrorResult& aRv) {
const Maybe<bool>& aCrossOriginIsolated, ErrorResult& aRv) {
MOZ_ASSERT(mLength == MULTIPARTBLOBIMPL_UNKNOWN_LENGTH);
MOZ_ASSERT_IF(mIsFile, IsLastModificationDateUnset());
@ -278,13 +277,13 @@ void MultipartBlobImpl::SetLengthAndModifiedDate(
if (lastModifiedSet) {
SetLastModificationDatePrecisely(lastModified);
} else {
MOZ_ASSERT(aRTPCallerType.isSome());
MOZ_ASSERT(aCrossOriginIsolated.isSome());
// We cannot use PR_Now() because bug 493756 and, for this reason:
// var x = new Date(); var f = new File(...);
// x.getTime() < f.dateModified.getTime()
// could fail.
SetLastModificationDate(aRTPCallerType.value(), JS_Now());
SetLastModificationDate(aCrossOriginIsolated.value(), JS_Now());
}
}
}

Просмотреть файл

@ -10,7 +10,6 @@
#include <utility>
#include "Blob.h"
#include "nsContentUtils.h"
#include "mozilla/Attributes.h"
#include "mozilla/Maybe.h"
#include "mozilla/dom/BaseBlobImpl.h"
@ -32,7 +31,7 @@ class MultipartBlobImpl final : public BaseBlobImpl {
// Create as a file
static already_AddRefed<MultipartBlobImpl> Create(
nsTArray<RefPtr<BlobImpl>>&& aBlobImpls, const nsAString& aName,
const nsAString& aContentType, RTPCallerType aRTPCallerType,
const nsAString& aContentType, bool aCrossOriginIsolated,
ErrorResult& aRv);
// Create as a blob
@ -49,11 +48,11 @@ class MultipartBlobImpl final : public BaseBlobImpl {
MultipartBlobImpl()
: BaseBlobImpl(u""_ns, MULTIPARTBLOBIMPL_UNKNOWN_LENGTH) {}
void InitializeBlob(RTPCallerType aRTPCallerType, ErrorResult& aRv);
void InitializeBlob(bool aCrossOriginIsolated, ErrorResult& aRv);
void InitializeBlob(const Sequence<Blob::BlobPart>& aData,
const nsAString& aContentType, bool aNativeEOL,
RTPCallerType aRTPCallerType, ErrorResult& aRv);
bool aCrossOriginIsolated, ErrorResult& aRv);
already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength,
const nsAString& aContentType,
@ -94,7 +93,7 @@ class MultipartBlobImpl final : public BaseBlobImpl {
~MultipartBlobImpl() override = default;
void SetLengthAndModifiedDate(const Maybe<RTPCallerType>& aRTPCallerType,
void SetLengthAndModifiedDate(const Maybe<bool>& aCrossOriginIsolated,
ErrorResult& aRv);
nsTArray<RefPtr<BlobImpl>> mBlobImpls;

Просмотреть файл

@ -739,15 +739,12 @@ double AudioContext::CurrentTime() {
double rawTime = track->TrackTimeToSeconds(track->GetCurrentTime());
RTPCallerType callerType = GetParentObject()->AsGlobal()->RTPCallerType();
// CurrentTime increments in intervals of 128/sampleRate. If the Timer
// Precision Reduction is smaller than this interval, the jittered time
// can always be reversed to the raw step of the interval. In that case
// we can simply return the un-reduced time; and avoid breaking tests.
// We have to convert each variable into a common magnitude, we choose ms.
if ((128 / mSampleRate) * 1000.0 >
nsRFPService::TimerResolution(callerType) / 1000.0) {
if ((128 / mSampleRate) * 1000.0 > nsRFPService::TimerResolution() / 1000.0) {
return rawTime;
}
@ -756,7 +753,9 @@ double AudioContext::CurrentTime() {
// will never reset (even if one rewinds a video.) Therefore we can use a
// single Random Seed initialized at the same time as the object.
return nsRFPService::ReduceTimePrecisionAsSecs(
rawTime, GetRandomTimelineSeed(), callerType);
rawTime, GetRandomTimelineSeed(),
/* aIsSystemPrincipal */ false,
GetParentObject()->AsGlobal()->CrossOriginIsolated());
}
nsISerialEventTarget* AudioContext::GetMainThread() const {

Просмотреть файл

@ -49,9 +49,6 @@ bool AudioWorkletGlobalScope::WrapGlobalObject(
JS::RealmOptions options;
options.behaviors().setShouldResistFingerprinting(
ShouldResistFingerprinting());
// The SharedArrayBuffer global constructor property should not be present in
// a fresh global object when shared memory objects aren't allowed (because
// COOP/COEP support isn't enabled, or because COOP/COEP don't act to isolate

Просмотреть файл

@ -15,7 +15,7 @@ namespace mozilla::dom {
RTCStatsTimestampMaker::RTCStatsTimestampMaker()
: mRandomTimelineSeed(0),
mStartRealtime(WebrtcSystemTimeBase()),
mRTPCallerType(RTPCallerType::Normal),
mCrossOriginIsolated(false),
mStartWallClockRaw(
PerformanceService::GetOrCreate()->TimeOrigin(mStartRealtime)) {}
@ -27,9 +27,8 @@ RTCStatsTimestampMaker::RTCStatsTimestampMaker(nsPIDOMWindowInner* aWindow)
mStartRealtime(aWindow && aWindow->GetPerformance()
? aWindow->GetPerformance()->CreationTimeStamp()
: WebrtcSystemTimeBase()),
mRTPCallerType(aWindow && aWindow->GetPerformance()
? aWindow->GetPerformance()->RTPCallerType()
: RTPCallerType::Normal),
mCrossOriginIsolated(aWindow ? aWindow->AsGlobal()->CrossOriginIsolated()
: false),
mStartWallClockRaw(
PerformanceService::GetOrCreate()->TimeOrigin(mStartRealtime)) {}
@ -47,7 +46,8 @@ DOMHighResTimeStamp RTCStatsTimestampMaker::ReduceRealtimePrecision(
// mRandomTimelineSeed is not set in the unit-tests.
if (mRandomTimelineSeed) {
realtime = nsRFPService::ReduceTimePrecisionAsMSecs(
realtime, mRandomTimelineSeed, mRTPCallerType);
realtime, mRandomTimelineSeed,
/* aIsSystemPrincipal */ false, mCrossOriginIsolated);
}
// Ugh. Performance::TimeOrigin is not constant, which means we need to
@ -56,7 +56,8 @@ DOMHighResTimeStamp RTCStatsTimestampMaker::ReduceRealtimePrecision(
// https://searchfox.org/mozilla-central/rev/
// 053826b10f838f77c27507e5efecc96e34718541/dom/performance/Performance.cpp#111-117
DOMHighResTimeStamp start = nsRFPService::ReduceTimePrecisionAsMSecs(
mStartWallClockRaw, 0, mRTPCallerType);
mStartWallClockRaw, 0, /* aIsSystemPrincipal = */ false,
mCrossOriginIsolated);
return start + realtime;
}

Просмотреть файл

@ -21,7 +21,6 @@
#include "nsCOMPtr.h"
#include "nsIGlobalObject.h"
#include "nsPIDOMWindow.h" // nsPIDOMWindowInner
#include "nsContentUtils.h"
#include "nsWrapperCache.h"
#include "prtime.h" // PR_Now
@ -64,7 +63,7 @@ class RTCStatsTimestampMaker {
const uint64_t mRandomTimelineSeed;
const TimeStamp mStartRealtime;
const RTPCallerType mRTPCallerType;
const bool mCrossOriginIsolated;
const DOMHighResTimeStamp mStartWallClockRaw;
};

Просмотреть файл

@ -10,7 +10,6 @@
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerScope.h"
namespace mozilla::dom::network {
@ -142,7 +141,7 @@ class NotifyRunnable : public WorkerRunnable {
already_AddRefed<ConnectionWorker> ConnectionWorker::Create(
WorkerPrivate* aWorkerPrivate, ErrorResult& aRv) {
bool shouldResistFingerprinting =
aWorkerPrivate->GlobalScope()->ShouldResistFingerprinting();
aWorkerPrivate->ShouldResistFingerprinting();
RefPtr<ConnectionWorker> c = new ConnectionWorker(shouldResistFingerprinting);
c->mProxy = ConnectionProxy::Create(aWorkerPrivate, c);
if (!c->mProxy) {

Просмотреть файл

@ -57,8 +57,8 @@ already_AddRefed<Performance> Performance::CreateForMainThread(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow->AsGlobal());
RefPtr<Performance> performance =
new PerformanceMainThread(aWindow, aDOMTiming, aChannel);
RefPtr<Performance> performance = new PerformanceMainThread(
aWindow, aDOMTiming, aChannel, aPrincipal->IsSystemPrincipal());
return performance.forget();
}
@ -93,23 +93,21 @@ already_AddRefed<Performance> Performance::Get(JSContext* aCx,
return performance.forget();
}
Performance::Performance(nsIGlobalObject* aGlobal)
Performance::Performance(nsIGlobalObject* aGlobal, bool aSystemPrincipal)
: DOMEventTargetHelper(aGlobal),
mResourceTimingBufferSize(kDefaultResourceTimingBufferSize),
mPendingNotificationObserversTask(false),
mPendingResourceTimingBufferFullEvent(false),
mRTPCallerType(
RTPCallerType::Normal /* to be updated in CreateForFoo */) {
mSystemPrincipal(aSystemPrincipal) {
MOZ_ASSERT(!NS_IsMainThread());
}
Performance::Performance(nsPIDOMWindowInner* aWindow)
Performance::Performance(nsPIDOMWindowInner* aWindow, bool aSystemPrincipal)
: DOMEventTargetHelper(aWindow),
mResourceTimingBufferSize(kDefaultResourceTimingBufferSize),
mPendingNotificationObserversTask(false),
mPendingResourceTimingBufferFullEvent(false),
mRTPCallerType(
RTPCallerType::Normal /* to be updated in CreateForFoo */) {
mSystemPrincipal(aSystemPrincipal) {
MOZ_ASSERT(NS_IsMainThread());
}
@ -118,27 +116,28 @@ Performance::~Performance() = default;
DOMHighResTimeStamp Performance::TimeStampToDOMHighResForRendering(
TimeStamp aTimeStamp) const {
DOMHighResTimeStamp stamp = GetDOMTiming()->TimeStampToDOMHighRes(aTimeStamp);
// 0 is an inappropriate mixin for this this area; however CSS Animations
// needs to have it's Time Reduction Logic refactored, so it's currently
// only clamping for RFP mode. RFP mode gives a much lower time precision,
// so we accept the security leak here for now.
return nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(stamp, 0,
mRTPCallerType);
if (!IsSystemPrincipal()) {
// 0 is an inappropriate mixin for this this area; however CSS Animations
// needs to have it's Time Reduction Logic refactored, so it's currently
// only clamping for RFP mode. RFP mode gives a much lower time precision,
// so we accept the security leak here for now.
return nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(stamp, 0);
}
return stamp;
}
DOMHighResTimeStamp Performance::Now() {
DOMHighResTimeStamp rawTime = NowUnclamped();
// XXX: Removing this caused functions in pkcs11f.h to fail.
// Bug 1628021 investigates the root cause - it involves initializing
// the RNG service (part of GetRandomTimelineSeed()) off-main-thread
// but the underlying cause hasn't been identified yet.
if (mRTPCallerType == RTPCallerType::SystemPrincipal) {
// XXX: Remove this would cause functions in pkcs11f.h to fail.
// Bug 1628021 will find out the root cause.
if (mSystemPrincipal) {
return rawTime;
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawTime, GetRandomTimelineSeed(), mRTPCallerType);
rawTime, GetRandomTimelineSeed(), mSystemPrincipal,
CrossOriginIsolated());
}
DOMHighResTimeStamp Performance::NowUnclamped() const {
@ -155,8 +154,8 @@ DOMHighResTimeStamp Performance::TimeOrigin() {
DOMHighResTimeStamp rawTimeOrigin =
mPerformanceService->TimeOrigin(CreationTimeStamp());
// Time Origin is an absolute timestamp, so we supply a 0 context mix-in
return nsRFPService::ReduceTimePrecisionAsMSecs(rawTimeOrigin, 0,
mRTPCallerType);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawTimeOrigin, 0, mSystemPrincipal, CrossOriginIsolated());
}
JSObject* Performance::WrapObject(JSContext* aCx,

Просмотреть файл

@ -10,7 +10,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
#include "nsDOMNavigationTiming.h"
#include "nsTObserverArray.h"
@ -120,7 +119,7 @@ class Performance : public DOMEventTargetHelper {
virtual TimeStamp CreationTimeStamp() const = 0;
RTPCallerType RTPCallerType() const { return mRTPCallerType; }
bool IsSystemPrincipal() const { return mSystemPrincipal; }
DOMHighResTimeStamp TimeStampToDOMHighResForRendering(TimeStamp) const;
@ -158,8 +157,8 @@ class Performance : public DOMEventTargetHelper {
virtual bool IsGlobalObjectWindow() const { return false; };
protected:
Performance(nsIGlobalObject* aGlobal);
Performance(nsPIDOMWindowInner* aWindow);
Performance(nsIGlobalObject* aGlobal, bool aSystemPrincipal);
Performance(nsPIDOMWindowInner* aWindow, bool aSystemPrincipal);
virtual ~Performance();
@ -205,7 +204,7 @@ class Performance : public DOMEventTargetHelper {
RefPtr<PerformanceService> mPerformanceService;
enum RTPCallerType mRTPCallerType;
bool mSystemPrincipal;
private:
MOZ_ALWAYS_INLINE bool CanAddResourceTimingEntry();

Просмотреть файл

@ -43,7 +43,8 @@ class PerformanceEventTiming final
if (mCachedProcessingStart.isNothing()) {
mCachedProcessingStart.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
mProcessingStart, mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType()));
mPerformance->IsSystemPrincipal(),
mPerformance->CrossOriginIsolated()));
}
return mCachedProcessingStart.value();
}
@ -52,7 +53,8 @@ class PerformanceEventTiming final
if (mCachedProcessingEnd.isNothing()) {
mCachedProcessingEnd.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
mProcessingEnd, mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType()));
mPerformance->IsSystemPrincipal(),
mPerformance->CrossOriginIsolated()));
}
return mCachedProcessingEnd.value();
}
@ -74,7 +76,8 @@ class PerformanceEventTiming final
if (mCachedDuration.isNothing()) {
mCachedDuration.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
mDuration, mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType()));
mPerformance->IsSystemPrincipal(),
mPerformance->CrossOriginIsolated()));
}
return mCachedDuration.value();
}
@ -87,7 +90,8 @@ class PerformanceEventTiming final
if (mCachedStartTime.isNothing()) {
mCachedStartTime.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
mStartTime, mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType()));
mPerformance->IsSystemPrincipal(),
mPerformance->CrossOriginIsolated()));
}
return mCachedStartTime.value();
}

Просмотреть файл

@ -90,13 +90,13 @@ NS_INTERFACE_MAP_END_INHERITING(Performance)
PerformanceMainThread::PerformanceMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel)
: Performance(aWindow),
nsITimedChannel* aChannel,
bool aPrincipal)
: Performance(aWindow, aPrincipal),
mDOMTiming(aDOMTiming),
mChannel(aChannel),
mCrossOriginIsolated(aWindow->AsGlobal()->CrossOriginIsolated()) {
MOZ_ASSERT(aWindow, "Parent window object should be provided");
mRTPCallerType = aWindow->AsGlobal()->RTPCallerType();
if (StaticPrefs::dom_enable_event_timing()) {
mEventCounts = new class EventCounts(GetParentObject());
}
@ -361,7 +361,8 @@ DOMHighResTimeStamp PerformanceMainThread::GetPerformanceTimingFromString(
"of sync");
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
retValue, GetRandomTimelineSeed(), mRTPCallerType);
retValue, GetRandomTimelineSeed(), /* aIsSystemPrinciapl */ false,
CrossOriginIsolated());
}
void PerformanceMainThread::InsertUserEntry(PerformanceEntry* aEntry) {

Просмотреть файл

@ -20,7 +20,7 @@ class PerformanceMainThread final : public Performance,
public:
PerformanceMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel);
nsITimedChannel* aChannel, bool aPrincipal);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMainThread,

Просмотреть файл

@ -26,7 +26,7 @@ JSObject* PerformanceNavigationTiming::WrapObject(
#define REDUCE_TIME_PRECISION \
return nsRFPService::ReduceTimePrecisionAsMSecs( \
rawValue, mPerformance->GetRandomTimelineSeed(), \
mPerformance->RTPCallerType())
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated())
DOMHighResTimeStamp PerformanceNavigationTiming::UnloadEventStart() const {
DOMHighResTimeStamp rawValue = 0;

Просмотреть файл

@ -41,7 +41,8 @@ DOMHighResTimeStamp PerformancePaintTiming::StartTime() const {
mPerformance->GetDOMTiming()->TimeStampToDOMHighRes(mRawStartTime);
mCachedStartTime.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType()));
mPerformance->IsSystemPrincipal(),
mPerformance->CrossOriginIsolated()));
}
return mCachedStartTime.value();
}

Просмотреть файл

@ -84,7 +84,8 @@ PerformanceTiming::PerformanceTiming(Performance* aPerformance,
aChannel, aHttpChannel,
nsRFPService::ReduceTimePrecisionAsMSecs(
aZeroTime, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType())));
aPerformance->IsSystemPrincipal(),
aPerformance->CrossOriginIsolated())));
// Non-null aHttpChannel implies that this PerformanceTiming object is being
// used for subresources, which is irrelevant to this probe.
@ -310,7 +311,7 @@ DOMHighResTimeStamp PerformanceTimingData::FetchStartHighRes(
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
mFetchStart, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec PerformanceTiming::FetchStart() {
@ -381,7 +382,7 @@ DOMHighResTimeStamp PerformanceTimingData::AsyncOpenHighRes(
TimeStampToDOMHighRes(aPerformance, mAsyncOpen);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
DOMHighResTimeStamp PerformanceTimingData::WorkerStartHighRes(
@ -396,7 +397,7 @@ DOMHighResTimeStamp PerformanceTimingData::WorkerStartHighRes(
TimeStampToDOMHighRes(aPerformance, mWorkerStart);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
/**
@ -505,7 +506,7 @@ DOMHighResTimeStamp PerformanceTimingData::DomainLookupEndHighRes(
TimeStampToDOMHighRes(aPerformance, mDomainLookupEnd);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec PerformanceTiming::DomainLookupEnd() {
@ -527,7 +528,7 @@ DOMHighResTimeStamp PerformanceTimingData::ConnectStartHighRes(
TimeStampToDOMHighRes(aPerformance, mConnectStart);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec PerformanceTiming::ConnectStart() {
@ -552,7 +553,7 @@ DOMHighResTimeStamp PerformanceTimingData::SecureConnectionStartHighRes(
TimeStampToDOMHighRes(aPerformance, mSecureConnectionStart);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec PerformanceTiming::SecureConnectionStart() {
@ -575,7 +576,7 @@ DOMHighResTimeStamp PerformanceTimingData::ConnectEndHighRes(
TimeStampToDOMHighRes(aPerformance, mConnectEnd);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec PerformanceTiming::ConnectEnd() {
@ -646,7 +647,7 @@ DOMHighResTimeStamp PerformanceTimingData::ResponseEndHighRes(
TimeStampToDOMHighRes(aPerformance, mResponseEnd);
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawValue, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec PerformanceTiming::ResponseEnd() {

Просмотреть файл

@ -84,7 +84,7 @@ class PerformanceTimingData final {
return nsRFPService::ReduceTimePrecisionAsMSecs(
rawTimestamp, aPerformance->GetRandomTimelineSeed(),
aPerformance->RTPCallerType());
aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
}
/**
@ -262,7 +262,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetNavigationStart(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec UnloadEventStart() {
@ -271,7 +272,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetUnloadEventStart(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec UnloadEventEnd() {
@ -280,7 +282,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetUnloadEventEnd(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
// Low resolution (used by navigation timing)
@ -302,7 +305,7 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetDomLoading(), mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType());
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec DomInteractive() const {
@ -311,7 +314,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetDomInteractive(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec DomContentLoadedEventStart() const {
@ -320,7 +324,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetDomContentLoadedEventStart(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec DomContentLoadedEventEnd() const {
@ -329,7 +334,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetDomContentLoadedEventEnd(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec DomComplete() const {
@ -338,7 +344,7 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetDomComplete(), mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType());
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec LoadEventStart() const {
@ -347,7 +353,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetLoadEventStart(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec LoadEventEnd() const {
@ -356,7 +363,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetLoadEventEnd(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec TimeToNonBlankPaint() const {
@ -365,7 +373,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetTimeToNonBlankPaint(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec TimeToContentfulPaint() const {
@ -374,7 +383,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetTimeToContentfulComposite(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec TimeToDOMContentFlushed() const {
@ -383,7 +393,8 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetTimeToDOMContentFlushed(),
mPerformance->GetRandomTimelineSeed(), mPerformance->RTPCallerType());
mPerformance->GetRandomTimelineSeed(),
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
DOMTimeMilliSec TimeToFirstInteractive() const {
@ -392,7 +403,7 @@ class PerformanceTiming final : public nsWrapperCache {
}
return nsRFPService::ReduceTimePrecisionAsMSecs(
GetDOMTiming()->GetTimeToTTFI(), mPerformance->GetRandomTimelineSeed(),
mPerformance->RTPCallerType());
mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
}
PerformanceTimingData* Data() const { return mTimingData.get(); }

Просмотреть файл

@ -11,10 +11,10 @@
namespace mozilla::dom {
PerformanceWorker::PerformanceWorker(WorkerPrivate* aWorkerPrivate)
: Performance(aWorkerPrivate->GlobalScope()),
: Performance(aWorkerPrivate->GlobalScope(),
aWorkerPrivate->UsesSystemPrincipal()),
mWorkerPrivate(aWorkerPrivate) {
mWorkerPrivate->AssertIsOnWorkerThread();
mRTPCallerType = aWorkerPrivate->GlobalScope()->RTPCallerType();
}
PerformanceWorker::~PerformanceWorker() {

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/Maybe.h"
#include "mozilla/OriginTrials.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsContentUtils.h"
#include "nsIGlobalObject.h"
#include "nsWrapperCache.h"
@ -55,12 +54,6 @@ class ShadowRealmGlobalScope : public nsIGlobalObject, public nsWrapperCache {
JS::loader::ModuleLoaderBase* GetModuleLoader(JSContext* aCx) override;
bool ShouldResistFingerprinting() const override {
return nsContentUtils::ShouldResistFingerprinting(
"Presently we don't have enough context to make an informed decision"
"on JS Sandboxes. See 1782853");
}
private:
virtual ~ShadowRealmGlobalScope() = default;

Просмотреть файл

@ -157,21 +157,13 @@ void WorkerNavigator::GetPlatform(nsString& aPlatform, CallerType aCallerType,
namespace {
/*
* This Worker Runnable needs to check RFP; but our standard way of doing so
* relies on accessing GlobalScope() - which can only be accessed on the worker
* thread. So we need to pass it in.
*/
class GetUserAgentRunnable final : public WorkerMainThreadRunnable {
nsString& mUA;
bool mShouldResistFingerprinting;
public:
GetUserAgentRunnable(WorkerPrivate* aWorkerPrivate, nsString& aUA,
bool aShouldResistFingerprinting)
GetUserAgentRunnable(WorkerPrivate* aWorkerPrivate, nsString& aUA)
: WorkerMainThreadRunnable(aWorkerPrivate, "UserAgent getter"_ns),
mUA(aUA),
mShouldResistFingerprinting(aShouldResistFingerprinting) {
mUA(aUA) {
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
}
@ -181,9 +173,11 @@ class GetUserAgentRunnable final : public WorkerMainThreadRunnable {
nsCOMPtr<nsPIDOMWindowInner> window = mWorkerPrivate->GetWindow();
bool shouldResistFingerprinting =
mWorkerPrivate->ShouldResistFingerprinting();
nsresult rv =
dom::Navigator::GetUserAgent(window, mWorkerPrivate->GetDocument(),
Some(mShouldResistFingerprinting), mUA);
Some(shouldResistFingerprinting), mUA);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to retrieve user-agent from the worker thread.");
}
@ -199,9 +193,8 @@ void WorkerNavigator::GetUserAgent(nsString& aUserAgent, CallerType aCallerType,
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
RefPtr<GetUserAgentRunnable> runnable = new GetUserAgentRunnable(
workerPrivate, aUserAgent,
workerPrivate->GlobalScope()->ShouldResistFingerprinting());
RefPtr<GetUserAgentRunnable> runnable =
new GetUserAgentRunnable(workerPrivate, aUserAgent);
runnable->Dispatch(Canceling, aRv);
}
@ -211,7 +204,7 @@ uint64_t WorkerNavigator::HardwareConcurrency() const {
MOZ_ASSERT(rts);
WorkerPrivate* aWorkerPrivate = GetCurrentThreadWorkerPrivate();
bool rfp = aWorkerPrivate->GlobalScope()->ShouldResistFingerprinting();
bool rfp = aWorkerPrivate->ShouldResistFingerprinting();
return rts->ClampedHardwareConcurrency(rfp);
}

Просмотреть файл

@ -2364,10 +2364,8 @@ WorkerPrivate::WorkerPrivate(
// Make timing imprecise in unprivileged code to blunt Spectre timing
// attacks.
bool clampAndJitterTime = !usesSystemPrincipal;
chromeRealmBehaviors.setClampAndJitterTime(clampAndJitterTime)
.setShouldResistFingerprinting(false);
contentRealmBehaviors.setClampAndJitterTime(clampAndJitterTime)
.setShouldResistFingerprinting(mLoadInfo.mShouldResistFingerprinting);
chromeRealmBehaviors.setClampAndJitterTime(clampAndJitterTime);
contentRealmBehaviors.setClampAndJitterTime(clampAndJitterTime);
JS::RealmCreationOptions& chromeCreationOptions =
chromeRealmOptions.creationOptions();
@ -2744,10 +2742,10 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
loadInfo.mOriginAttributes = aParent->GetOriginAttributes();
loadInfo.mServiceWorkersTestingInWindow =
aParent->ServiceWorkersTestingInWindow();
loadInfo.mShouldResistFingerprinting =
aParent->ShouldResistFingerprinting();
loadInfo.mIsThirdPartyContextToTopWindow =
aParent->IsThirdPartyContextToTopWindow();
loadInfo.mShouldResistFingerprinting =
aParent->GlobalScope()->ShouldResistFingerprinting();
loadInfo.mParentController = aParent->GlobalScope()->GetController();
loadInfo.mWatchedByDevTools = aParent->IsWatchedByDevTools();
} else {
@ -5438,18 +5436,15 @@ WorkerGlobalScope* WorkerPrivate::GetOrCreateGlobalScope(JSContext* aCx) {
return data->mScope;
}
bool rfp = mLoadInfo.mShouldResistFingerprinting;
if (IsSharedWorker()) {
data->mScope = new SharedWorkerGlobalScope(this, CreateClientSource(),
WorkerName(), rfp);
data->mScope =
new SharedWorkerGlobalScope(this, CreateClientSource(), WorkerName());
} else if (IsServiceWorker()) {
data->mScope = new ServiceWorkerGlobalScope(
this, CreateClientSource(), GetServiceWorkerRegistrationDescriptor(),
rfp);
this, CreateClientSource(), GetServiceWorkerRegistrationDescriptor());
} else {
data->mScope = new DedicatedWorkerGlobalScope(this, CreateClientSource(),
WorkerName(), rfp);
WorkerName());
}
JS::Rooted<JSObject*> global(aCx);
@ -5477,10 +5472,8 @@ WorkerDebuggerGlobalScope* WorkerPrivate::CreateDebuggerGlobalScope(
auto clientSource = ClientManager::CreateSource(
GetClientType(), HybridEventTarget(), NullPrincipalInfo());
bool rfp = false; // The debugger for a worker can exempt RFP; it is not
// client-exposed
data->mDebuggerScope =
new WorkerDebuggerGlobalScope(this, std::move(clientSource), rfp);
new WorkerDebuggerGlobalScope(this, std::move(clientSource));
JS::Rooted<JSObject*> global(aCx);
NS_ENSURE_TRUE(data->mDebuggerScope->WrapGlobalObject(aCx, &global), nullptr);

Просмотреть файл

@ -891,7 +891,11 @@ class WorkerPrivate final
return mLoadInfo.mServiceWorkersTestingInWindow;
}
// Determine if the worker was created under a third-party context.
bool ShouldResistFingerprinting() const {
return mLoadInfo.mShouldResistFingerprinting;
}
// Determin if the worker was created under a third-party context.
bool IsThirdPartyContextToTopWindow() const {
return mLoadInfo.mIsThirdPartyContextToTopWindow;
}

Просмотреть файл

@ -232,12 +232,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WorkerGlobalScopeBase)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
WorkerGlobalScopeBase::WorkerGlobalScopeBase(
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
bool aShouldResistFingerprinting)
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource)
: mWorkerPrivate(aWorkerPrivate),
mClientSource(std::move(aClientSource)),
mSerialEventTarget(aWorkerPrivate->HybridEventTarget()),
mShouldResistFingerprinting(aShouldResistFingerprinting) {
mSerialEventTarget(aWorkerPrivate->HybridEventTarget()) {
MOZ_ASSERT(mWorkerPrivate);
#ifdef DEBUG
mWorkerPrivate->AssertIsOnWorkerThread();
@ -273,11 +271,7 @@ bool WorkerGlobalScopeBase::IsSharedMemoryAllowed() const {
bool WorkerGlobalScopeBase::ShouldResistFingerprinting() const {
AssertIsOnWorkerThread();
return mShouldResistFingerprinting;
}
bool WorkerGlobalScopeBase::IsSystemPrincipal() const {
return mWorkerPrivate->UsesSystemPrincipal();
return mWorkerPrivate->ShouldResistFingerprinting();
}
uint32_t WorkerGlobalScopeBase::GetPrincipalHashValue() const {
@ -878,9 +872,8 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(DedicatedWorkerGlobalScope,
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
const nsString& aName, bool aShouldResistFingerprinting)
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource),
aShouldResistFingerprinting),
const nsString& aName)
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource)),
NamedWorkerGlobalScopeMixin(aName) {}
bool DedicatedWorkerGlobalScope::WrapGlobalObject(
@ -1035,8 +1028,7 @@ void DedicatedWorkerGlobalScope::OnVsync(const VsyncEvent& aVsync) {
// needs to have it's Time Reduction Logic refactored, so it's currently
// only clamping for RFP mode. RFP mode gives a much lower time precision,
// so we accept the security leak here for now.
timeStamp = nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(
timeStamp, 0, this->RTPCallerType());
timeStamp = nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(timeStamp, 0);
}
for (auto& callback : callbacks) {
@ -1054,9 +1046,8 @@ void DedicatedWorkerGlobalScope::OnVsync(const VsyncEvent& aVsync) {
SharedWorkerGlobalScope::SharedWorkerGlobalScope(
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
const nsString& aName, bool aShouldResistFingerprinting)
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource),
aShouldResistFingerprinting),
const nsString& aName)
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource)),
NamedWorkerGlobalScopeMixin(aName) {}
bool SharedWorkerGlobalScope::WrapGlobalObject(
@ -1089,10 +1080,8 @@ NS_IMPL_RELEASE_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope)
ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor,
bool aShouldResistFingerprinting)
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource),
aShouldResistFingerprinting),
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor)
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource)),
mScope(NS_ConvertUTF8toUTF16(aRegistrationDescriptor.Scope()))
// Eagerly create the registration because we will need to receive

Просмотреть файл

@ -98,8 +98,7 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
DOMEventTargetHelper)
WorkerGlobalScopeBase(WorkerPrivate* aWorkerPrivate,
UniquePtr<ClientSource> aClientSource,
bool mShouldResistFingerprinting);
UniquePtr<ClientSource> aClientSource);
virtual bool WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector) = 0;
@ -173,8 +172,6 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
protected:
~WorkerGlobalScopeBase();
bool IsSystemPrincipal() const final;
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
void AssertIsOnWorkerThread() const {
@ -185,7 +182,6 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
RefPtr<Console> mConsole;
const UniquePtr<ClientSource> mClientSource;
nsCOMPtr<nsISerialEventTarget> mSerialEventTarget;
bool mShouldResistFingerprinting;
#ifdef DEBUG
PRThread* mWorkerThreadUsedOnlyForAssert;
#endif
@ -378,8 +374,7 @@ class DedicatedWorkerGlobalScope final
DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
UniquePtr<ClientSource> aClientSource,
const nsString& aName,
bool aShouldResistFingerprinting);
const nsString& aName);
bool WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector) override;
@ -423,8 +418,7 @@ class SharedWorkerGlobalScope final
public:
SharedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
UniquePtr<ClientSource> aClientSource,
const nsString& aName,
bool aShouldResistFingerprinting);
const nsString& aName);
bool WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector) override;
@ -445,8 +439,7 @@ class ServiceWorkerGlobalScope final : public WorkerGlobalScope {
ServiceWorkerGlobalScope(
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor,
bool aShouldResistFingerprinting);
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor);
bool WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector) override;

Просмотреть файл

@ -72,14 +72,6 @@ bool WorkletGlobalScope::IsSharedMemoryAllowed() const {
return mImpl->IsSharedMemoryAllowed();
}
bool WorkletGlobalScope::ShouldResistFingerprinting() const {
return mImpl->ShouldResistFingerprinting();
}
bool WorkletGlobalScope::IsSystemPrincipal() const {
return mImpl->IsSystemPrincipal();
}
void WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const {
WorkletThread::AssertIsOnWorkletThread();

Просмотреть файл

@ -68,13 +68,10 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache {
OriginTrials Trials() const override;
Maybe<nsID> GetAgentClusterId() const override;
bool IsSharedMemoryAllowed() const override;
bool ShouldResistFingerprinting() const override;
protected:
~WorkletGlobalScope();
bool IsSystemPrincipal() const override;
const RefPtr<WorkletImpl> mImpl;
private:

Просмотреть файл

@ -39,7 +39,6 @@ WorkletLoadInfo::WorkletLoadInfo(nsPIDOMWindowInner* aWindow)
WorkletImpl::WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
: mPrincipal(NullPrincipal::CreateWithInheritedAttributes(aPrincipal)),
mIsSystemPrincipal(mPrincipal->IsSystemPrincipal()),
mWorkletLoadInfo(aWindow),
mTerminated(false),
mFinishedOnExecutionThread(false),
@ -53,9 +52,6 @@ WorkletImpl::WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
mSharedMemoryAllowed =
nsGlobalWindowInner::Cast(aWindow)->IsSharedMemoryAllowed();
mShouldResistFingerprinting =
aWindow->AsGlobal()->ShouldResistFingerprinting();
}
WorkletImpl::~WorkletImpl() {

Просмотреть файл

@ -82,10 +82,6 @@ class WorkletImpl {
const Maybe<nsID>& GetAgentClusterId() const { return mAgentClusterId; }
bool IsSharedMemoryAllowed() const { return mSharedMemoryAllowed; }
bool IsSystemPrincipal() const { return mIsSystemPrincipal; }
bool ShouldResistFingerprinting() const {
return mShouldResistFingerprinting;
}
virtual void OnAddModuleStarted() const {
MOZ_ASSERT(NS_IsMainThread());
@ -107,8 +103,6 @@ class WorkletImpl {
ipc::PrincipalInfo mPrincipalInfo;
// Accessed on only worklet parent thread.
nsCOMPtr<nsIPrincipal> mPrincipal;
// For off-main-thread checks
bool mIsSystemPrincipal;
const WorkletLoadInfo mWorkletLoadInfo;
@ -123,7 +117,6 @@ class WorkletImpl {
Maybe<nsID> mAgentClusterId;
bool mSharedMemoryAllowed;
bool mShouldResistFingerprinting;
const OriginTrials mTrials;
};

Просмотреть файл

@ -186,12 +186,10 @@ JS_PUBLIC_API double DayFromYear(double year);
// |JS::DayFromYear(time)|.
JS_PUBLIC_API double DayWithinYear(double time, double year);
// The callback will be a wrapper function that accepts a double (the time
// to clamp and jitter) as well as a bool indicating if we should be resisting
// fingerprinting. Inside the JS Engine, other parameters that may be
// The callback will be a wrapper function that accepts a single double (the
// time to clamp and jitter.) Inside the JS Engine, other parameters that may be
// needed are all constant, so they are handled inside the wrapper function
using ReduceMicrosecondTimePrecisionCallback = double (*)(double, bool,
JSContext*);
using ReduceMicrosecondTimePrecisionCallback = double (*)(double, JSContext*);
// Set a callback into the toolkit/components/resistfingerprinting function that
// will centralize time resolution and jitter into one place.

Просмотреть файл

@ -313,14 +313,6 @@ class JS_PUBLIC_API RealmBehaviors {
return *this;
}
bool shouldResistFingerprinting() const {
return shouldResistFingerprinting_;
}
RealmBehaviors& setShouldResistFingerprinting(bool flag) {
shouldResistFingerprinting_ = flag;
return *this;
}
class Override {
public:
Override() : mode_(Default) {}
@ -356,7 +348,6 @@ class JS_PUBLIC_API RealmBehaviors {
private:
bool discardSource_ = false;
bool clampAndJitterTime_ = true;
bool shouldResistFingerprinting_ = false;
bool isNonLive_ = false;
};

Просмотреть файл

@ -1536,11 +1536,8 @@ static ClippedTime NowAsMillis(JSContext* cx) {
double now = PRMJ_Now();
bool clampAndJitter = cx->realm()->behaviors().clampAndJitterTime();
bool shouldResistFingerprinting =
cx->realm()->behaviors().shouldResistFingerprinting();
if (clampAndJitter && sReduceMicrosecondTimePrecisionCallback) {
now = sReduceMicrosecondTimePrecisionCallback(
now, shouldResistFingerprinting, cx);
now = sReduceMicrosecondTimePrecisionCallback(now, cx);
} else if (clampAndJitter && sResolutionUsec) {
double clamped = floor(now / sResolutionUsec) * sResolutionUsec;

Просмотреть файл

@ -8,7 +8,6 @@
#define BackstagePass_h__
#include "js/loader/ModuleLoaderBase.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/StorageAccess.h"
#include "nsISupports.h"
#include "nsWeakReference.h"
@ -68,12 +67,6 @@ class BackstagePass final : public nsIGlobalObject,
mModuleLoader = aModuleLoader;
}
bool ShouldResistFingerprinting() const override {
// BackstagePass is always the System Principal
MOZ_RELEASE_ASSERT(mPrincipal->IsSystemPrincipal());
return false;
}
private:
virtual ~BackstagePass() = default;

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StorageAccess.h"
#include "mozilla/net/CookieJarSettings.h"
#include "nsContentUtils.h"
#include "nsIGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIPrincipal.h"
@ -97,12 +96,6 @@ class SandboxPrivate : public nsIGlobalObject,
return 0;
}
bool ShouldResistFingerprinting() const override {
return nsContentUtils::ShouldResistFingerprinting(
"Presently we don't have enough context to make an informed decision"
"on JS Sandboxes. See 1782853");
}
private:
explicit SandboxPrivate(nsIPrincipal* principal) : mPrincipal(principal) {}

Просмотреть файл

@ -477,22 +477,23 @@ JSObject* CreateGlobalObject(JSContext* cx, const JSClass* clasp,
}
void InitGlobalObjectOptions(JS::RealmOptions& aOptions,
bool aIsSystemPrincipal,
bool aShouldResistFingerprinting) {
nsIPrincipal* aPrincipal) {
bool shouldDiscardSystemSource = ShouldDiscardSystemSource();
if (aIsSystemPrincipal) {
bool isSystem = aPrincipal->IsSystemPrincipal();
if (isSystem) {
// Make toSource functions [ChromeOnly]
aOptions.creationOptions().setToSourceEnabled(true);
// Make sure [SecureContext] APIs are visible:
aOptions.creationOptions().setSecureContext(true);
aOptions.behaviors().setClampAndJitterTime(false);
}
aOptions.behaviors().setShouldResistFingerprinting(
aShouldResistFingerprinting);
if (shouldDiscardSystemSource) {
aOptions.behaviors().setDiscardSource(aIsSystemPrincipal);
bool discardSource = isSystem;
aOptions.behaviors().setDiscardSource(discardSource);
}
}
@ -536,13 +537,8 @@ nsresult InitClassesWithNewWrappedGlobal(JSContext* aJSContext,
// We pass null for the 'extra' pointer during global object creation, so
// we need to have a principal.
MOZ_ASSERT(aPrincipal);
// All uses (at time of writing) were System Principal, meaning
// aShouldResistFingerprinting can be hardcoded to false.
// If this changes, ShouldRFP needs to be updated accordingly.
MOZ_RELEASE_ASSERT(aPrincipal->IsSystemPrincipal());
InitGlobalObjectOptions(aOptions, /* aSystemPrincipal */ true,
/* aShouldResistFingerprinting */ false);
InitGlobalObjectOptions(aOptions, aPrincipal);
// Call into XPCWrappedNative to make a new global object, scope, and global
// prototype.

Просмотреть файл

@ -2424,8 +2424,7 @@ JSObject* CreateGlobalObject(JSContext* cx, const JSClass* clasp,
// you can't get a *mutable* JS::RealmOptions& from an existing global
// object.)
void InitGlobalObjectOptions(JS::RealmOptions& aOptions,
bool aIsSystemPrincipal,
bool aShouldResistFingerprinting);
nsIPrincipal* aPrincipal);
// Finish initializing an already-created, not-yet-exposed-to-script global
// object. This will attach a Components object (if necessary) and call

Просмотреть файл

@ -24,9 +24,6 @@ bool PaintWorkletGlobalScope::WrapGlobalObject(
JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) {
JS::RealmOptions options;
options.behaviors().setShouldResistFingerprinting(
ShouldResistFingerprinting());
// The SharedArrayBuffer global constructor property should not be present in
// a fresh global object when shared memory objects aren't allowed (because
// COOP/COEP support isn't enabled, or because COOP/COEP don't act to isolate

Просмотреть файл

@ -171,10 +171,10 @@ minutes, I'm impressed, and we might revisit this.
*/
/* static */
double nsRFPService::TimerResolution(RTPCallerType aRTPCallerType) {
double nsRFPService::TimerResolution() {
double prefValue = StaticPrefs::
privacy_resistFingerprinting_reduceTimerPrecision_microseconds();
if (aRTPCallerType == RTPCallerType::ResistFingerprinting) {
if (StaticPrefs::privacy_resistFingerprinting()) {
return std::max(RFP_TIME_ATOM_MS * 1000.0, prefValue);
}
return prefValue;
@ -447,69 +447,66 @@ double nsRFPService::ReduceTimePrecisionImpl(double aTime, TimeScale aTimeScale,
/* static */
double nsRFPService::ReduceTimePrecisionAsUSecs(double aTime,
int64_t aContextMixin,
RTPCallerType aRTPCallerType) {
const auto type = GetTimerPrecisionType(aRTPCallerType);
return nsRFPService::ReduceTimePrecisionImpl(aTime, MicroSeconds,
TimerResolution(aRTPCallerType),
aContextMixin, type);
bool aIsSystemPrincipal,
bool aCrossOriginIsolated) {
const auto type =
GetTimerPrecisionType(aIsSystemPrincipal, aCrossOriginIsolated);
return nsRFPService::ReduceTimePrecisionImpl(
aTime, MicroSeconds, TimerResolution(), aContextMixin, type);
}
/* static */
double nsRFPService::ReduceTimePrecisionAsMSecs(double aTime,
int64_t aContextMixin,
RTPCallerType aRTPCallerType) {
const auto type = GetTimerPrecisionType(aRTPCallerType);
return nsRFPService::ReduceTimePrecisionImpl(aTime, MilliSeconds,
TimerResolution(aRTPCallerType),
aContextMixin, type);
bool aIsSystemPrincipal,
bool aCrossOriginIsolated) {
const auto type =
GetTimerPrecisionType(aIsSystemPrincipal, aCrossOriginIsolated);
return nsRFPService::ReduceTimePrecisionImpl(
aTime, MilliSeconds, TimerResolution(), aContextMixin, type);
}
/* static */
double nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(
double aTime, int64_t aContextMixin, RTPCallerType aRTPCallerType) {
return nsRFPService::ReduceTimePrecisionImpl(
aTime, MilliSeconds, TimerResolution(aRTPCallerType), aContextMixin,
GetTimerPrecisionTypeRFPOnly(aRTPCallerType));
double nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(double aTime,
int64_t aContextMixin) {
return nsRFPService::ReduceTimePrecisionImpl(aTime, MilliSeconds,
TimerResolution(), aContextMixin,
GetTimerPrecisionTypeRFPOnly());
}
/* static */
double nsRFPService::ReduceTimePrecisionAsSecs(double aTime,
int64_t aContextMixin,
RTPCallerType aRTPCallerType) {
const auto type = GetTimerPrecisionType(aRTPCallerType);
bool aIsSystemPrincipal,
bool aCrossOriginIsolated) {
const auto type =
GetTimerPrecisionType(aIsSystemPrincipal, aCrossOriginIsolated);
return nsRFPService::ReduceTimePrecisionImpl(
aTime, Seconds, TimerResolution(aRTPCallerType), aContextMixin, type);
aTime, Seconds, TimerResolution(), aContextMixin, type);
}
/* static */
double nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(
double aTime, int64_t aContextMixin, RTPCallerType aRTPCallerType) {
return nsRFPService::ReduceTimePrecisionImpl(
aTime, Seconds, TimerResolution(aRTPCallerType), aContextMixin,
GetTimerPrecisionTypeRFPOnly(aRTPCallerType));
double nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(double aTime,
int64_t aContextMixin) {
return nsRFPService::ReduceTimePrecisionImpl(aTime, Seconds,
TimerResolution(), aContextMixin,
GetTimerPrecisionTypeRFPOnly());
}
/* static */
double nsRFPService::ReduceTimePrecisionAsUSecsWrapper(
double aTime, bool aShouldResistFingerprinting, JSContext* aCx) {
double nsRFPService::ReduceTimePrecisionAsUSecsWrapper(double aTime,
JSContext* aCx) {
MOZ_ASSERT(aCx);
nsCOMPtr<nsIGlobalObject> global = xpc::CurrentNativeGlobal(aCx);
MOZ_ASSERT(global);
RTPCallerType callerType;
if (aShouldResistFingerprinting) {
callerType = RTPCallerType::ResistFingerprinting;
} else if (global->CrossOriginIsolated()) {
callerType = RTPCallerType::CrossOriginIsolated;
} else {
callerType = RTPCallerType::Normal;
}
const auto type = GetTimerPrecisionType(/* aIsSystemPrincipal */ false,
global->CrossOriginIsolated());
return nsRFPService::ReduceTimePrecisionImpl(
aTime, MicroSeconds, TimerResolution(callerType),
aTime, MicroSeconds, TimerResolution(),
0, /* For absolute timestamps (all the JS engine does), supply zero
context mixin */
GetTimerPrecisionType(callerType));
type);
}
/* static */
@ -519,8 +516,7 @@ uint32_t nsRFPService::CalculateTargetVideoResolution(uint32_t aVideoQuality) {
/* static */
uint32_t nsRFPService::GetSpoofedTotalFrames(double aTime) {
double precision =
TimerResolution(RTPCallerType::ResistFingerprinting) / 1000 / 1000;
double precision = TimerResolution() / 1000 / 1000;
double time = floor(aTime / precision) * precision;
return NSToIntFloor(time * kVideoFramesPerSec);
@ -538,8 +534,7 @@ uint32_t nsRFPService::GetSpoofedDroppedFrames(double aTime, uint32_t aWidth,
return 0;
}
double precision =
TimerResolution(RTPCallerType::ResistFingerprinting) / 1000 / 1000;
double precision = TimerResolution() / 1000 / 1000;
double time = floor(aTime / precision) * precision;
// Bound the dropped ratio from 0 to 100.
uint32_t boundedDroppedRatio = std::min(kVideoDroppedRatio, 100U);
@ -560,8 +555,7 @@ uint32_t nsRFPService::GetSpoofedPresentedFrames(double aTime, uint32_t aWidth,
return GetSpoofedTotalFrames(aTime);
}
double precision =
TimerResolution(RTPCallerType::ResistFingerprinting) / 1000 / 1000;
double precision = TimerResolution() / 1000 / 1000;
double time = floor(aTime / precision) * precision;
// Bound the dropped ratio from 0 to 100.
uint32_t boundedDroppedRatio = std::min(kVideoDroppedRatio, 100U);
@ -663,17 +657,37 @@ nsresult nsRFPService::Init() {
return rv;
}
// This function updates only timing-related fingerprinting items
void nsRFPService::UpdateTimers() {
MOZ_ASSERT(NS_IsMainThread());
if (StaticPrefs::privacy_resistFingerprinting() ||
StaticPrefs::privacy_reduceTimerPrecision()) {
JS::SetTimeResolutionUsec(
TimerResolution(),
StaticPrefs::
privacy_resistFingerprinting_reduceTimerPrecision_jitter());
JS::SetReduceMicrosecondTimePrecisionCallback(
nsRFPService::ReduceTimePrecisionAsUSecsWrapper);
} else if (StaticPrefs::privacy_reduceTimerPrecision_unconditional()) {
JS::SetTimeResolutionUsec(RFP_TIMER_UNCONDITIONAL_VALUE, false);
JS::SetReduceMicrosecondTimePrecisionCallback(
nsRFPService::ReduceTimePrecisionAsUSecsWrapper);
} else if (sInitialized) {
JS::SetTimeResolutionUsec(0, false);
}
}
// This function updates every fingerprinting item necessary except
// timing-related
void nsRFPService::UpdateRFPPref() {
MOZ_ASSERT(NS_IsMainThread());
UpdateTimers();
bool privacyResistFingerprinting =
StaticPrefs::privacy_resistFingerprinting();
JS::SetReduceMicrosecondTimePrecisionCallback(
nsRFPService::ReduceTimePrecisionAsUSecsWrapper);
// set fdlibm pref
JS::SetUseFdlibmForSinCosTan(
StaticPrefs::javascript_options_use_fdlibm_for_sin_cos_tan() ||
@ -951,17 +965,16 @@ bool nsRFPService::GetSpoofedKeyCode(const dom::Document* aDoc,
/* static */
TimerPrecisionType nsRFPService::GetTimerPrecisionType(
RTPCallerType aRTPCallerType) {
if (aRTPCallerType == RTPCallerType::SystemPrincipal) {
bool aIsSystemPrincipal, bool aCrossOriginIsolated) {
if (aIsSystemPrincipal) {
return DangerouslyNone;
}
if (aRTPCallerType == RTPCallerType::ResistFingerprinting) {
if (StaticPrefs::privacy_resistFingerprinting()) {
return RFP;
}
if (StaticPrefs::privacy_reduceTimerPrecision() &&
aRTPCallerType == RTPCallerType::CrossOriginIsolated) {
if (StaticPrefs::privacy_reduceTimerPrecision() && aCrossOriginIsolated) {
return UnconditionalAKAHighRes;
}
@ -977,14 +990,12 @@ TimerPrecisionType nsRFPService::GetTimerPrecisionType(
}
/* static */
TimerPrecisionType nsRFPService::GetTimerPrecisionTypeRFPOnly(
RTPCallerType aRTPCallerType) {
if (aRTPCallerType == RTPCallerType::ResistFingerprinting) {
TimerPrecisionType nsRFPService::GetTimerPrecisionTypeRFPOnly() {
if (StaticPrefs::privacy_resistFingerprinting()) {
return RFP;
}
if (StaticPrefs::privacy_reduceTimerPrecision_unconditional() &&
aRTPCallerType != RTPCallerType::SystemPrincipal) {
if (StaticPrefs::privacy_reduceTimerPrecision_unconditional()) {
return UnconditionalAKAHighRes;
}
@ -1021,7 +1032,12 @@ void nsRFPService::PrefChanged(const char* aPref, void* aSelf) {
void nsRFPService::PrefChanged(const char* aPref) {
nsDependentCString pref(aPref);
if (pref.EqualsLiteral(RESIST_FINGERPRINTING_PREF)) {
if (pref.EqualsLiteral(RFP_TIMER_PREF) ||
pref.EqualsLiteral(RFP_TIMER_UNCONDITIONAL_PREF) ||
pref.EqualsLiteral(RFP_TIMER_VALUE_PREF) ||
pref.EqualsLiteral(RFP_JITTER_VALUE_PREF)) {
UpdateTimers();
} else if (pref.EqualsLiteral(RESIST_FINGERPRINTING_PREF)) {
UpdateRFPPref();
#if defined(XP_WIN)

Просмотреть файл

@ -10,9 +10,7 @@
#include "ErrorList.h"
#include "PLDHashTable.h"
#include "mozilla/BasicEvents.h"
#include "nsContentUtils.h"
#include "nsHashtablesFwd.h"
#include "nsIGlobalObject.h"
#include "nsIObserver.h"
#include "nsISupports.h"
#include "nsStringFwd.h"
@ -136,27 +134,27 @@ class nsRFPService final : public nsIObserver {
NS_DECL_NSIOBSERVER
static nsRFPService* GetOrCreate();
static double TimerResolution(RTPCallerType aRTPCallerType);
static double TimerResolution();
enum TimeScale { Seconds = 1, MilliSeconds = 1000, MicroSeconds = 1000000 };
// The following Reduce methods can be called off main thread.
static double ReduceTimePrecisionAsUSecs(double aTime, int64_t aContextMixin,
RTPCallerType aRTPCallerType);
bool aIsSystemPrincipal,
bool aCrossOriginIsolated);
static double ReduceTimePrecisionAsMSecs(double aTime, int64_t aContextMixin,
RTPCallerType aRTPCallerType);
bool aIsSystemPrincipal,
bool aCrossOriginIsolated);
static double ReduceTimePrecisionAsMSecsRFPOnly(double aTime,
int64_t aContextMixin,
RTPCallerType aRTPCallerType);
int64_t aContextMixin);
static double ReduceTimePrecisionAsSecs(double aTime, int64_t aContextMixin,
RTPCallerType aRTPCallerType);
bool aIsSystemPrincipal,
bool aCrossOriginIsolated);
static double ReduceTimePrecisionAsSecsRFPOnly(double aTime,
int64_t aContextMixin,
RTPCallerType aRTPCallerType);
int64_t aContextMixin);
// Used by the JS Engine, as it doesn't know about the TimerPrecisionType enum
static double ReduceTimePrecisionAsUSecsWrapper(
double aTime, bool aShouldResistFingerprinting, JSContext* aCx);
static double ReduceTimePrecisionAsUSecsWrapper(double aTime, JSContext* aCx);
// Public only for testing purposes
static double ReduceTimePrecisionImpl(double aTime, TimeScale aTimeScale,
@ -234,6 +232,7 @@ class nsRFPService final : public nsIObserver {
~nsRFPService() = default;
void UpdateTimers();
void UpdateRFPPref();
void StartShutdown();
@ -254,10 +253,10 @@ class nsRFPService final : public nsIObserver {
static nsTHashMap<KeyboardHashKey, const SpoofingKeyboardCode*>*
sSpoofingKeyboardCodes;
static TimerPrecisionType GetTimerPrecisionType(RTPCallerType aRTPCallerType);
static TimerPrecisionType GetTimerPrecisionType(bool aIsSystemPrincipal,
bool aCrossOriginIsolated);
static TimerPrecisionType GetTimerPrecisionTypeRFPOnly(
RTPCallerType aRTPCallerType);
static TimerPrecisionType GetTimerPrecisionTypeRFPOnly();
static void TypeToText(TimerPrecisionType aType, nsACString& aText);