mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-02-10 07:02:03 -08:00
Add timezone spoofing #5
Adds "timezone" property to set a custom tz identifier (ex: "America/Chicago"). Also changes Date() properties to return the local time.
This commit is contained in:
parent
bf20ab8546
commit
8385561b19
2 changed files with 51 additions and 1 deletions
49
patches/timezone-spoofing.patch
Normal file
49
patches/timezone-spoofing.patch
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
diff --git a/intl/components/moz.build b/intl/components/moz.build
|
||||
index b0af60b999..28c221136e 100644
|
||||
--- a/intl/components/moz.build
|
||||
+++ b/intl/components/moz.build
|
||||
@@ -89,3 +89,6 @@ if CONFIG["MOZ_ICU4X"]:
|
||||
DEFINES["MOZ_HAS_MOZGLUE"] = True
|
||||
|
||||
Library("intlcomponents")
|
||||
+
|
||||
+# DOM Mask
|
||||
+LOCAL_INCLUDES += ["/camoucfg"]
|
||||
\ No newline at end of file
|
||||
diff --git a/intl/components/src/TimeZone.cpp b/intl/components/src/TimeZone.cpp
|
||||
index 5b09dfdcc5..98a78b33cc 100644
|
||||
--- a/intl/components/src/TimeZone.cpp
|
||||
+++ b/intl/components/src/TimeZone.cpp
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
-
|
||||
+#include "unicode/unistr.h"
|
||||
+#include "MaskConfig.hpp"
|
||||
#include "unicode/uenum.h"
|
||||
#if MOZ_INTL_USE_ICU_CPP_TIMEZONE
|
||||
# include "unicode/basictz.h"
|
||||
@@ -22,7 +23,21 @@ Result<UniquePtr<TimeZone>, ICUError> TimeZone::TryCreate(
|
||||
Maybe<Span<const char16_t>> aTimeZoneOverride) {
|
||||
const UChar* zoneID = nullptr;
|
||||
int32_t zoneIDLen = 0;
|
||||
- if (aTimeZoneOverride) {
|
||||
+
|
||||
+ if (auto value = MaskConfig::GetString("timezone")) {
|
||||
+ std::string camouTimeZone = value.value();
|
||||
+
|
||||
+ // Because we don't have access to NS_ConvertUTF8toUTF16 here,
|
||||
+ // convert UTF-8 to UTF-16 using ICU's UnicodeString
|
||||
+ icu::UnicodeString uniStr = icu::UnicodeString::fromUTF8(camouTimeZone);
|
||||
+
|
||||
+ if (uniStr.isBogus()) {
|
||||
+ return Err(ICUError::InternalError);
|
||||
+ }
|
||||
+
|
||||
+ zoneIDLen = uniStr.length();
|
||||
+ zoneID = uniStr.getBuffer();
|
||||
+ } else if (aTimeZoneOverride) {
|
||||
zoneIDLen = static_cast<int32_t>(aTimeZoneOverride->Length());
|
||||
zoneID = aTimeZoneOverride->Elements();
|
||||
}
|
||||
|
|
@ -57,5 +57,6 @@
|
|||
{ "property": "fonts", "type": "array" },
|
||||
{ "property": "geolocation:latitude", "type": "double" },
|
||||
{ "property": "geolocation:longitude", "type": "double" },
|
||||
{ "property": "geolocation:accuracy", "type": "double" }
|
||||
{ "property": "geolocation:accuracy", "type": "double" },
|
||||
{ "property": "timezone", "type": "str" }
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue