Loading browser/components/resistfingerprinting/test/browser/browser.toml +2 −0 Original line number Diff line number Diff line Loading @@ -196,3 +196,5 @@ lineno = "172" ["browser_timezone.js"] lineno = "176" ["browser_exslt_timezone_load.js"] browser/components/resistfingerprinting/test/browser/browser_exslt_timezone_load.js 0 → 100644 +62 −0 Original line number Diff line number Diff line /** * Bug 1891690 - A test case for verifying EXSLT date will use Atlantic/Reykjavik * timezone (GMT and "real" equivalent to UTC) after fingerprinting * resistance is enabled. */ function getTimeZone(tab) { const extractTime = function () { const xslText = ` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date"> <xsl:output method="text" /> <xsl:template match="/"> <xsl:value-of select="date:date-time()" /> </xsl:template> </xsl:stylesheet>`; const parser = new DOMParser(); const xsltProcessor = new XSLTProcessor(); const xslStylesheet = parser.parseFromString(xslText, "application/xml"); xsltProcessor.importStylesheet(xslStylesheet); const xmlDoc = parser.parseFromString("<test />", "application/xml"); const styledDoc = xsltProcessor.transformToDocument(xmlDoc); const time = styledDoc.firstChild.textContent; return time; }; const extractTimeExpr = `(${extractTime.toString()})();`; return SpecialPowers.spawn( tab.linkedBrowser, [extractTimeExpr], async funccode => content.eval(funccode) ); } add_task(async function test_new_window() { await SpecialPowers.pushPrefEnv({ set: [ ["privacy.fingerprintingProtection", true], ["privacy.fingerprintingProtection.overrides", "+JSDateTimeUTC"], ], }); // Open a tab for extracting the time zone from XSLT. const tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser, opening: TEST_PATH + "file_dummy.html", forceNewProcess: true, }); SpecialPowers.Cu.getJSTestingFunctions().setTimeZone("America/Toronto"); const timeZone = await getTimeZone(tab); ok(timeZone.endsWith("+00:00"), "Timezone was spoofed."); BrowserTestUtils.removeTab(tab); await SpecialPowers.popPrefEnv(); }); dom/xslt/xslt/txEXSLTFunctions.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -590,7 +590,15 @@ nsresult txEXSLTFunctionCall::evaluate(txIEvalContext* aContext, // http://exslt.org/date/functions/date-time/ PRExplodedTime prtime; PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &prtime); Document* sourceDoc = getSourceDocument(aContext); NS_ENSURE_STATE(sourceDoc); PR_ExplodeTime( PR_Now(), sourceDoc->ShouldResistFingerprinting(RFPTarget::JSDateTimeUTC) ? PR_GMTParameters : PR_LocalTimeParameters, &prtime); int32_t offset = (prtime.tm_params.tp_gmt_offset + prtime.tm_params.tp_dst_offset) / Loading Loading @@ -634,7 +642,7 @@ Expr::ResultType txEXSLTFunctionCall::getReturnType() { bool txEXSLTFunctionCall::isSensitiveTo(ContextSensitivity aContext) { if (mType == txEXSLTType::NODE_SET || mType == txEXSLTType::SPLIT || mType == txEXSLTType::TOKENIZE) { mType == txEXSLTType::TOKENIZE || mType == txEXSLTType::DATE_TIME) { return (aContext & PRIVATE_CONTEXT) || argsSensitiveTo(aContext); } return argsSensitiveTo(aContext); Loading Loading
browser/components/resistfingerprinting/test/browser/browser.toml +2 −0 Original line number Diff line number Diff line Loading @@ -196,3 +196,5 @@ lineno = "172" ["browser_timezone.js"] lineno = "176" ["browser_exslt_timezone_load.js"]
browser/components/resistfingerprinting/test/browser/browser_exslt_timezone_load.js 0 → 100644 +62 −0 Original line number Diff line number Diff line /** * Bug 1891690 - A test case for verifying EXSLT date will use Atlantic/Reykjavik * timezone (GMT and "real" equivalent to UTC) after fingerprinting * resistance is enabled. */ function getTimeZone(tab) { const extractTime = function () { const xslText = ` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date"> <xsl:output method="text" /> <xsl:template match="/"> <xsl:value-of select="date:date-time()" /> </xsl:template> </xsl:stylesheet>`; const parser = new DOMParser(); const xsltProcessor = new XSLTProcessor(); const xslStylesheet = parser.parseFromString(xslText, "application/xml"); xsltProcessor.importStylesheet(xslStylesheet); const xmlDoc = parser.parseFromString("<test />", "application/xml"); const styledDoc = xsltProcessor.transformToDocument(xmlDoc); const time = styledDoc.firstChild.textContent; return time; }; const extractTimeExpr = `(${extractTime.toString()})();`; return SpecialPowers.spawn( tab.linkedBrowser, [extractTimeExpr], async funccode => content.eval(funccode) ); } add_task(async function test_new_window() { await SpecialPowers.pushPrefEnv({ set: [ ["privacy.fingerprintingProtection", true], ["privacy.fingerprintingProtection.overrides", "+JSDateTimeUTC"], ], }); // Open a tab for extracting the time zone from XSLT. const tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser, opening: TEST_PATH + "file_dummy.html", forceNewProcess: true, }); SpecialPowers.Cu.getJSTestingFunctions().setTimeZone("America/Toronto"); const timeZone = await getTimeZone(tab); ok(timeZone.endsWith("+00:00"), "Timezone was spoofed."); BrowserTestUtils.removeTab(tab); await SpecialPowers.popPrefEnv(); });
dom/xslt/xslt/txEXSLTFunctions.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -590,7 +590,15 @@ nsresult txEXSLTFunctionCall::evaluate(txIEvalContext* aContext, // http://exslt.org/date/functions/date-time/ PRExplodedTime prtime; PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &prtime); Document* sourceDoc = getSourceDocument(aContext); NS_ENSURE_STATE(sourceDoc); PR_ExplodeTime( PR_Now(), sourceDoc->ShouldResistFingerprinting(RFPTarget::JSDateTimeUTC) ? PR_GMTParameters : PR_LocalTimeParameters, &prtime); int32_t offset = (prtime.tm_params.tp_gmt_offset + prtime.tm_params.tp_dst_offset) / Loading Loading @@ -634,7 +642,7 @@ Expr::ResultType txEXSLTFunctionCall::getReturnType() { bool txEXSLTFunctionCall::isSensitiveTo(ContextSensitivity aContext) { if (mType == txEXSLTType::NODE_SET || mType == txEXSLTType::SPLIT || mType == txEXSLTType::TOKENIZE) { mType == txEXSLTType::TOKENIZE || mType == txEXSLTType::DATE_TIME) { return (aContext & PRIVATE_CONTEXT) || argsSensitiveTo(aContext); } return argsSensitiveTo(aContext); Loading