зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1654286 - Convert private fields option to a JSContext option r=jandem
This avoids the issue where xpcshell appears to startup, create a realm, then read preferences. Prior to this patch, by the time the prefs were read, it was too late for the realm creation option to take effect. This way, we update the realm option. Differential Revision: https://phabricator.services.mozilla.com/D84426
This commit is contained in:
Родитель
fd4664735a
Коммит
f337f90b04
|
@ -43,7 +43,8 @@ class JS_PUBLIC_API ContextOptions {
|
|||
trackNotImplemented_(false),
|
||||
trySmoosh_(false),
|
||||
#endif
|
||||
fuzzing_(false) {
|
||||
fuzzing_(false),
|
||||
privateClassFields_(false) {
|
||||
}
|
||||
|
||||
bool asmJS() const { return asmJS_; }
|
||||
|
@ -139,6 +140,12 @@ class JS_PUBLIC_API ContextOptions {
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool privateClassFields() const { return privateClassFields_; }
|
||||
ContextOptions& setPrivateClassFields(bool enabled) {
|
||||
privateClassFields_ = enabled;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Override to allow disabling the eval restriction security checks for
|
||||
// this context.
|
||||
bool disableEvalSecurityChecks() const { return disableEvalSecurityChecks_; }
|
||||
|
@ -246,6 +253,7 @@ class JS_PUBLIC_API ContextOptions {
|
|||
bool trySmoosh_ : 1;
|
||||
#endif
|
||||
bool fuzzing_ : 1;
|
||||
bool privateClassFields_ : 1;
|
||||
};
|
||||
|
||||
JS_PUBLIC_API ContextOptions& ContextOptionsRef(JSContext* cx);
|
||||
|
|
|
@ -244,12 +244,6 @@ class JS_PUBLIC_API RealmCreationOptions {
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool getPrivateClassFieldsEnabled() const { return privateClassFields_; }
|
||||
RealmCreationOptions& setPrivateClassFieldsEnabled(bool flag) {
|
||||
privateClassFields_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// This flag doesn't affect JS engine behavior. It is used by Gecko to
|
||||
// mark whether content windows and workers are "Secure Context"s. See
|
||||
// https://w3c.github.io/webappsec-secure-contexts/
|
||||
|
@ -290,7 +284,6 @@ class JS_PUBLIC_API RealmCreationOptions {
|
|||
bool toSource_ = false;
|
||||
bool propertyErrorMessageFix_ = false;
|
||||
bool iteratorHelpers_ = false;
|
||||
bool privateClassFields_ = false;
|
||||
bool secureContext_ = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -159,8 +159,7 @@ static bool GetRealmConfiguration(JSContext* cx, unsigned argc, Value* vp) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool privateFields =
|
||||
cx->realm()->creationOptions().getPrivateClassFieldsEnabled();
|
||||
bool privateFields = cx->options().privateClassFields();
|
||||
if (!JS_SetProperty(cx, info, "privateFields",
|
||||
privateFields ? TrueHandleValue : FalseHandleValue)) {
|
||||
return false;
|
||||
|
|
|
@ -3562,8 +3562,7 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
|
|||
}
|
||||
throwOnAsmJSValidationFailureOption =
|
||||
cx->options().throwOnAsmJSValidationFailure();
|
||||
privateClassFields =
|
||||
cx->realm()->creationOptions().getPrivateClassFieldsEnabled();
|
||||
privateClassFields = cx->options().privateClassFields();
|
||||
|
||||
sourcePragmas_ = cx->options().sourcePragmas();
|
||||
|
||||
|
|
|
@ -3887,8 +3887,7 @@ static void SetStandardRealmOptions(JS::RealmOptions& options) {
|
|||
: JS::WeakRefSpecifier::Disabled)
|
||||
.setToSourceEnabled(enableToSource)
|
||||
.setPropertyErrorMessageFixEnabled(enablePropertyErrorMessageFix)
|
||||
.setIteratorHelpersEnabled(enableIteratorHelpers)
|
||||
.setPrivateClassFieldsEnabled(enablePrivateClassFields);
|
||||
.setIteratorHelpersEnabled(enableIteratorHelpers);
|
||||
}
|
||||
|
||||
static MOZ_MUST_USE bool CheckRealmOptions(JSContext* cx,
|
||||
|
@ -10130,7 +10129,8 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
|
|||
.setTestWasmAwaitTier2(enableTestWasmAwaitTier2)
|
||||
.setSourcePragmas(enableSourcePragmas)
|
||||
.setAsyncStack(enableAsyncStacks)
|
||||
.setAsyncStackCaptureDebuggeeOnly(enableAsyncStackCaptureDebuggeeOnly);
|
||||
.setAsyncStackCaptureDebuggeeOnly(enableAsyncStackCaptureDebuggeeOnly)
|
||||
.setPrivateClassFields(enablePrivateClassFields);
|
||||
|
||||
if (op.getBoolOption("no-ion-for-main-context")) {
|
||||
JS::ContextOptionsRef(cx).setDisableIon();
|
||||
|
|
|
@ -761,7 +761,6 @@ static mozilla::Atomic<bool> sPropertyErrorMessageFixEnabled(false);
|
|||
static mozilla::Atomic<bool> sWeakRefsEnabled(false);
|
||||
static mozilla::Atomic<bool> sWeakRefsExposeCleanupSome(false);
|
||||
static mozilla::Atomic<bool> sIteratorHelpersEnabled(false);
|
||||
static mozilla::Atomic<bool> sPrivateFieldsEnabled(false);
|
||||
|
||||
static JS::WeakRefSpecifier GetWeakRefsEnabled() {
|
||||
if (!sWeakRefsEnabled) {
|
||||
|
@ -786,8 +785,7 @@ void xpc::SetPrefableRealmOptions(JS::RealmOptions& options) {
|
|||
StaticPrefs::javascript_options_writable_streams())
|
||||
.setPropertyErrorMessageFixEnabled(sPropertyErrorMessageFixEnabled)
|
||||
.setWeakRefsEnabled(GetWeakRefsEnabled())
|
||||
.setIteratorHelpersEnabled(sIteratorHelpersEnabled)
|
||||
.setPrivateClassFieldsEnabled(sPrivateFieldsEnabled);
|
||||
.setIteratorHelpersEnabled(sIteratorHelpersEnabled);
|
||||
}
|
||||
|
||||
static void LoadStartupJSPrefs(XPCJSContext* xpccx) {
|
||||
|
@ -969,7 +967,7 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
|
|||
#ifdef NIGHTLY_BUILD
|
||||
sIteratorHelpersEnabled =
|
||||
Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.iterator_helpers");
|
||||
sPrivateFieldsEnabled =
|
||||
bool privateFieldsEnabled =
|
||||
Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.private_fields");
|
||||
#endif
|
||||
|
||||
|
@ -1014,7 +1012,8 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
|
|||
.setAsyncStack(useAsyncStack)
|
||||
.setAsyncStackCaptureDebuggeeOnly(useAsyncStackCaptureDebuggeeOnly)
|
||||
.setThrowOnDebuggeeWouldRun(throwOnDebuggeeWouldRun)
|
||||
.setDumpStackOnDebuggeeWouldRun(dumpStackOnDebuggeeWouldRun);
|
||||
.setDumpStackOnDebuggeeWouldRun(dumpStackOnDebuggeeWouldRun)
|
||||
.setPrivateClassFields(privateFieldsEnabled);
|
||||
|
||||
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
|
||||
if (xr) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче