Bug 1877193 part 10 - Use JS::Prefs for experimental.shadow_realms pref. r=mgaudet

Differential Revision: https://phabricator.services.mozilla.com/D200001
This commit is contained in:
Jan de Mooij 2024-02-06 12:51:31 +00:00
parent c6e9374a01
commit 64f095ae18
5 changed files with 5 additions and 15 deletions

View File

@ -194,12 +194,6 @@ class JS_PUBLIC_API RealmCreationOptions {
return *this;
}
bool getShadowRealmsEnabled() const { return shadowRealms_; }
RealmCreationOptions& setShadowRealmsEnabled(bool flag) {
shadowRealms_ = flag;
return *this;
}
#ifdef NIGHTLY_BUILD
bool getNewSetMethodsEnabled() const { return newSetMethods_; }
RealmCreationOptions& setNewSetMethodsEnabled(bool flag) {
@ -291,7 +285,6 @@ class JS_PUBLIC_API RealmCreationOptions {
bool defineSharedArrayBufferConstructor_ = true;
bool coopAndCoep_ = false;
bool toSource_ = false;
bool shadowRealms_ = false;
#ifdef NIGHTLY_BUILD
// Pref for new Set.prototype methods.
bool newSetMethods_ = false;

View File

@ -737,7 +737,6 @@ bool shell::enableAsyncStacks = false;
bool shell::enableAsyncStackCaptureDebuggeeOnly = false;
bool shell::enableWeakRefs = false;
bool shell::enableToSource = false;
bool shell::enableShadowRealms = false;
#ifdef NIGHTLY_BUILD
// Pref for new Set.prototype methods.
bool shell::enableNewSetMethods = false;
@ -4131,7 +4130,6 @@ static void SetStandardRealmOptions(JS::RealmOptions& options) {
? JS::WeakRefSpecifier::EnabledWithCleanupSome
: JS::WeakRefSpecifier::Disabled)
.setToSourceEnabled(enableToSource)
.setShadowRealmsEnabled(enableShadowRealms)
#ifdef NIGHTLY_BUILD
.setNewSetMethodsEnabled(enableNewSetMethods)
.setArrayBufferResizableEnabled(enableArrayBufferResizable)
@ -12141,6 +12139,8 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) {
!op.getBoolOption("disable-array-grouping"));
JS::Prefs::setAtStartup_arraybuffer_transfer(
!op.getBoolOption("disable-arraybuffer-transfer"));
JS::Prefs::set_experimental_shadow_realms(
op.getBoolOption("enable-shadow-realms"));
JS::Prefs::setAtStartup_well_formed_unicode_strings(
!op.getBoolOption("disable-well-formed-unicode-strings"));
#ifdef NIGHTLY_BUILD
@ -12345,7 +12345,6 @@ bool SetContextOptions(JSContext* cx, const OptionParser& op) {
op.getBoolOption("async-stacks-capture-debuggee-only");
enableWeakRefs = !op.getBoolOption("disable-weak-refs");
enableToSource = !op.getBoolOption("disable-tosource");
enableShadowRealms = op.getBoolOption("enable-shadow-realms");
#ifdef NIGHTLY_BUILD
enableNewSetMethods = op.getBoolOption("enable-new-set-methods");
enableArrayBufferResizable = op.getBoolOption("enable-arraybuffer-resizable");

View File

@ -240,7 +240,7 @@ bool GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) {
return !IsIteratorHelpersEnabled();
case JSProto_ShadowRealm:
return !cx->realm()->creationOptions().getShadowRealmsEnabled();
return !JS::Prefs::experimental_shadow_realms();
default:
MOZ_CRASH("unexpected JSProtoKey");

View File

@ -780,7 +780,6 @@ static mozilla::Atomic<bool> sStreamsEnabled(false);
static mozilla::Atomic<bool> sWeakRefsEnabled(false);
static mozilla::Atomic<bool> sWeakRefsExposeCleanupSome(false);
static mozilla::Atomic<bool> sShadowRealmsEnabled(false);
#ifdef NIGHTLY_BUILD
static mozilla::Atomic<bool> sNewSetMethodsEnabled(false);
static mozilla::Atomic<bool> sArrayBufferResizableEnabled(false);
@ -806,7 +805,6 @@ void xpc::SetPrefableRealmOptions(JS::RealmOptions& options) {
StaticPrefs::browser_tabs_remote_useCrossOriginOpenerPolicy() &&
StaticPrefs::browser_tabs_remote_useCrossOriginEmbedderPolicy())
.setWeakRefsEnabled(GetWeakRefsEnabled())
.setShadowRealmsEnabled(sShadowRealmsEnabled)
#ifdef NIGHTLY_BUILD
.setNewSetMethodsEnabled(sNewSetMethodsEnabled)
.setArrayBufferResizableEnabled(sArrayBufferResizableEnabled)
@ -1014,8 +1012,6 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
sWeakRefsEnabled = Preferences::GetBool(JS_OPTIONS_DOT_STR "weakrefs");
sWeakRefsExposeCleanupSome = Preferences::GetBool(
JS_OPTIONS_DOT_STR "experimental.weakrefs.expose_cleanupSome");
sShadowRealmsEnabled =
Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.shadow_realms");
#ifdef NIGHTLY_BUILD
sNewSetMethodsEnabled =
Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.new_set_methods");

View File

@ -7457,6 +7457,8 @@
type: RelaxedAtomicBool
value: false
mirror: always
# Non-startup pref because the WPT test harness sets prefs after startup.
set_spidermonkey_pref: always
# Support for String.prototype.{is,to}WellFormed in JavaScript.
- name: javascript.options.well_formed_unicode_strings