Loading browser/components/resistfingerprinting/test/browser/browser_timezone.js +9 −12 Original line number Diff line number Diff line /** * Bug 1330890 - A test case for verifying Date() object of javascript will use * Atlantic/Reykjavik timezone (GMT and "real" equivalent to UTC) * after fingerprinting resistance is enabled. * UTC timezone after fingerprinting resistance is enabled. */ async function verifySpoofed() { Loading @@ -17,15 +16,13 @@ async function verifySpoofed() { // Running in content: function test() { let date = new Date(); const TZ_NAME = "Atlantic/Reykjavik"; const TZ_SUFFIX = "(Greenwich Mean Time)"; ok( date.toString().endsWith(TZ_SUFFIX), `The date toString() is in ${TZ_NAME} timezone.` date.toString().endsWith("(Coordinated Universal Time)"), "The date toString() is in UTC timezone." ); ok( date.toTimeString().endsWith(TZ_SUFFIX), `The date toTimeString() is in ${TZ_NAME} timezone.` date.toTimeString().endsWith("(Coordinated Universal Time)"), "The date toTimeString() is in UTC timezone." ); let dateTimeFormat = Intl.DateTimeFormat("en-US", { dateStyle: "full", Loading @@ -33,12 +30,12 @@ async function verifySpoofed() { }); is( dateTimeFormat.resolvedOptions().timeZone, TZ_NAME, `The Intl.DateTimeFormat is in ${TZ_NAME} timezone.` "UTC", "The Intl.DateTimeFormat is in UTC timezone." ); ok( dateTimeFormat.format(date).endsWith(TZ_SUFFIX), `The Intl.DateTimeFormat is formatting with the ${TZ_NAME} timezone.` dateTimeFormat.format(date).endsWith("Coordinated Universal Time"), "The Intl.DateTimeFormat is formatting with the UTC timezone." ); is( date.getFullYear(), Loading js/src/jit-test/tests/resist-fingerprinting/timezone.js +5 −8 Original line number Diff line number Diff line Loading @@ -2,10 +2,7 @@ let tzRE = /\(([^\)]+)\)/; const SPOOFED_TZ_NAME = "Atlantic/Reykjavik"; const SPOOFED_TZ_GENERIC = "Greenwich Mean Time"; // Make sure we aren't already running with spoofed TZ // Make sure we aren't already running with UTC let original = new Date(0); assertEq(tzRE.exec(original.toString())[1], "Pacific Standard Time"); Loading @@ -19,8 +16,8 @@ assertEq(originalDT.resolvedOptions().timeZone, "PST8PDT"); let global = newGlobal({shouldResistFingerprinting: true}); let date = new global.Date(); assertEq(tzRE.exec(date.toString())[1], SPOOFED_TZ_GENERIC); assertEq(tzRE.exec(date.toTimeString())[1], SPOOFED_TZ_GENERIC); assertEq(tzRE.exec(date.toString())[1], "Coordinated Universal Time"); assertEq(tzRE.exec(date.toTimeString())[1], "Coordinated Universal Time"); assertEq(date.getFullYear(), date.getUTCFullYear()); assertEq(date.getMonth(), date.getUTCMonth()); assertEq(date.getDate(), date.getUTCDate()); Loading @@ -32,5 +29,5 @@ let dt = global.Intl.DateTimeFormat("en-US", { dateStyle: "full", timeStyle: "full", }); assertEq(dt.format(date).endsWith(SPOOFED_TZ_GENERIC), true); assertEq(dt.resolvedOptions().timeZone, SPOOFED_TZ_NAME); assertEq(dt.format(date).endsWith("Coordinated Universal Time"), true); assertEq(dt.resolvedOptions().timeZone, "UTC"); js/src/vm/DateTime.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -484,11 +484,10 @@ bool js::DateTimeInfo::internalTimeZoneDisplayName(char16_t* buf, size_t buflen, mozilla::intl::TimeZone* js::DateTimeInfo::timeZone() { if (!timeZone_) { // For resist finger printing mode we always use the Atlantic/Reykjavik time zone // as a "real world" UTC equivalent. // For resist finger printing mode we always use the UTC time zone. mozilla::Maybe<mozilla::Span<const char16_t>> timeZoneOverride; if (shouldResistFingerprinting_) { timeZoneOverride = mozilla::Some(mozilla::MakeStringSpan(u"Atlantic/Reykjavik")); timeZoneOverride = mozilla::Some(mozilla::MakeStringSpan(u"UTC")); } auto timeZone = mozilla::intl::TimeZone::TryCreate(timeZoneOverride); Loading toolkit/components/resistfingerprinting/nsRFPService.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -227,7 +227,7 @@ void nsRFPService::UpdateRFPPref() { } if (resistFingerprinting) { PR_SetEnv("TZ=Atlantic/Reykjavik"); PR_SetEnv("TZ=UTC"); } else if (sInitialized) { // We will not touch the TZ value if 'privacy.resistFingerprinting' is false // during the time of initialization. Loading Loading
browser/components/resistfingerprinting/test/browser/browser_timezone.js +9 −12 Original line number Diff line number Diff line /** * Bug 1330890 - A test case for verifying Date() object of javascript will use * Atlantic/Reykjavik timezone (GMT and "real" equivalent to UTC) * after fingerprinting resistance is enabled. * UTC timezone after fingerprinting resistance is enabled. */ async function verifySpoofed() { Loading @@ -17,15 +16,13 @@ async function verifySpoofed() { // Running in content: function test() { let date = new Date(); const TZ_NAME = "Atlantic/Reykjavik"; const TZ_SUFFIX = "(Greenwich Mean Time)"; ok( date.toString().endsWith(TZ_SUFFIX), `The date toString() is in ${TZ_NAME} timezone.` date.toString().endsWith("(Coordinated Universal Time)"), "The date toString() is in UTC timezone." ); ok( date.toTimeString().endsWith(TZ_SUFFIX), `The date toTimeString() is in ${TZ_NAME} timezone.` date.toTimeString().endsWith("(Coordinated Universal Time)"), "The date toTimeString() is in UTC timezone." ); let dateTimeFormat = Intl.DateTimeFormat("en-US", { dateStyle: "full", Loading @@ -33,12 +30,12 @@ async function verifySpoofed() { }); is( dateTimeFormat.resolvedOptions().timeZone, TZ_NAME, `The Intl.DateTimeFormat is in ${TZ_NAME} timezone.` "UTC", "The Intl.DateTimeFormat is in UTC timezone." ); ok( dateTimeFormat.format(date).endsWith(TZ_SUFFIX), `The Intl.DateTimeFormat is formatting with the ${TZ_NAME} timezone.` dateTimeFormat.format(date).endsWith("Coordinated Universal Time"), "The Intl.DateTimeFormat is formatting with the UTC timezone." ); is( date.getFullYear(), Loading
js/src/jit-test/tests/resist-fingerprinting/timezone.js +5 −8 Original line number Diff line number Diff line Loading @@ -2,10 +2,7 @@ let tzRE = /\(([^\)]+)\)/; const SPOOFED_TZ_NAME = "Atlantic/Reykjavik"; const SPOOFED_TZ_GENERIC = "Greenwich Mean Time"; // Make sure we aren't already running with spoofed TZ // Make sure we aren't already running with UTC let original = new Date(0); assertEq(tzRE.exec(original.toString())[1], "Pacific Standard Time"); Loading @@ -19,8 +16,8 @@ assertEq(originalDT.resolvedOptions().timeZone, "PST8PDT"); let global = newGlobal({shouldResistFingerprinting: true}); let date = new global.Date(); assertEq(tzRE.exec(date.toString())[1], SPOOFED_TZ_GENERIC); assertEq(tzRE.exec(date.toTimeString())[1], SPOOFED_TZ_GENERIC); assertEq(tzRE.exec(date.toString())[1], "Coordinated Universal Time"); assertEq(tzRE.exec(date.toTimeString())[1], "Coordinated Universal Time"); assertEq(date.getFullYear(), date.getUTCFullYear()); assertEq(date.getMonth(), date.getUTCMonth()); assertEq(date.getDate(), date.getUTCDate()); Loading @@ -32,5 +29,5 @@ let dt = global.Intl.DateTimeFormat("en-US", { dateStyle: "full", timeStyle: "full", }); assertEq(dt.format(date).endsWith(SPOOFED_TZ_GENERIC), true); assertEq(dt.resolvedOptions().timeZone, SPOOFED_TZ_NAME); assertEq(dt.format(date).endsWith("Coordinated Universal Time"), true); assertEq(dt.resolvedOptions().timeZone, "UTC");
js/src/vm/DateTime.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -484,11 +484,10 @@ bool js::DateTimeInfo::internalTimeZoneDisplayName(char16_t* buf, size_t buflen, mozilla::intl::TimeZone* js::DateTimeInfo::timeZone() { if (!timeZone_) { // For resist finger printing mode we always use the Atlantic/Reykjavik time zone // as a "real world" UTC equivalent. // For resist finger printing mode we always use the UTC time zone. mozilla::Maybe<mozilla::Span<const char16_t>> timeZoneOverride; if (shouldResistFingerprinting_) { timeZoneOverride = mozilla::Some(mozilla::MakeStringSpan(u"Atlantic/Reykjavik")); timeZoneOverride = mozilla::Some(mozilla::MakeStringSpan(u"UTC")); } auto timeZone = mozilla::intl::TimeZone::TryCreate(timeZoneOverride); Loading
toolkit/components/resistfingerprinting/nsRFPService.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -227,7 +227,7 @@ void nsRFPService::UpdateRFPPref() { } if (resistFingerprinting) { PR_SetEnv("TZ=Atlantic/Reykjavik"); PR_SetEnv("TZ=UTC"); } else if (sInitialized) { // We will not touch the TZ value if 'privacy.resistFingerprinting' is false // during the time of initialization. Loading