diff --git a/js/public/Prefs.h b/js/public/Prefs.h index 374b5bdbee1a..dee6731b2f4e 100644 --- a/js/public/Prefs.h +++ b/js/public/Prefs.h @@ -106,26 +106,6 @@ class Prefs { #undef DEF_GETSET }; -/** - * Specification for whether weak refs should be enabled and if so whether the - * FinalizationRegistry.cleanupSome method should be present. - */ -enum class WeakRefSpecifier { - Disabled, - EnabledWithCleanupSome, - EnabledWithoutCleanupSome -}; - -inline WeakRefSpecifier GetWeakRefsEnabled() { - if (!Prefs::weakrefs()) { - return WeakRefSpecifier::Disabled; - } - if (Prefs::experimental_weakrefs_expose_cleanupSome()) { - return WeakRefSpecifier::EnabledWithCleanupSome; - } - return WeakRefSpecifier::EnabledWithoutCleanupSome; -} - }; // namespace JS #endif /* js_Prefs_h */ diff --git a/js/src/fuzz-tests/tests.cpp b/js/src/fuzz-tests/tests.cpp index 587597bf417b..b730db188eaf 100644 --- a/js/src/fuzz-tests/tests.cpp +++ b/js/src/fuzz-tests/tests.cpp @@ -76,7 +76,6 @@ static void jsfuzz_uninit(JSContext* cx) { int main(int argc, char* argv[]) { // Override prefs for fuzz-tests. - JS::Prefs::setAtStartup_weakrefs(true); JS::Prefs::setAtStartup_experimental_weakrefs_expose_cleanupSome(true); if (!JS_Init()) { diff --git a/js/src/jsapi-tests/tests.cpp b/js/src/jsapi-tests/tests.cpp index 1dc36e7bc3fa..d85b63370904 100644 --- a/js/src/jsapi-tests/tests.cpp +++ b/js/src/jsapi-tests/tests.cpp @@ -231,7 +231,6 @@ int main(int argc, char* argv[]) { } // Override prefs for jsapi-tests. - JS::Prefs::setAtStartup_weakrefs(true); JS::Prefs::setAtStartup_experimental_weakrefs_expose_cleanupSome(true); #ifdef NIGHTLY_BUILD JS::Prefs::setAtStartup_experimental_symbols_as_weakmap_keys(true); diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 4291ccc680f5..9fbb266a5ab7 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -12427,7 +12427,6 @@ bool InitOptionParser(OptionParser& op) { !op.addBoolOption('\0', "less-debug-code", "Emit less machine code for " "checking assertions under DEBUG.") || - !op.addBoolOption('\0', "disable-weak-refs", "Disable weak references") || !op.addBoolOption('\0', "disable-tosource", "Disable toSource/uneval") || !op.addBoolOption('\0', "disable-property-error-message-fix", "Disable fix for the error message when accessing " @@ -12933,9 +12932,6 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) { JS::Prefs::set_experimental_json_parse_with_source(true); } - if (op.getBoolOption("disable-weak-refs")) { - JS::Prefs::setAtStartup_weakrefs(false); - } JS::Prefs::setAtStartup_experimental_weakrefs_expose_cleanupSome(true); if (op.getBoolOption("disable-destructuring-fuse")) { diff --git a/js/src/tests/user.js b/js/src/tests/user.js index 00972d75f768..8490841cc320 100644 --- a/js/src/tests/user.js +++ b/js/src/tests/user.js @@ -28,7 +28,6 @@ user_pref("privacy.trackingprotection.enabled", false); user_pref("privacy.trackingprotection.pbmode.enabled", false); user_pref("general.useragent.updates.enabled", false); user_pref("browser.webapps.checkForUpdates", 0); -user_pref("javascript.options.weakrefs", true); user_pref("javascript.options.experimental.weakrefs.expose_cleanupSome", true); user_pref("javascript.options.experimental.iterator_helpers", true); user_pref("javascript.options.experimental.import_attributes", true); diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 079caf281547..54c0a2464c99 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -169,6 +169,8 @@ bool GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) { case JSProto_AsyncFunction: case JSProto_GeneratorFunction: case JSProto_AsyncGeneratorFunction: + case JSProto_WeakRef: + case JSProto_FinalizationRegistry: return false; case JSProto_WebAssembly: @@ -230,10 +232,6 @@ bool GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) { case JSProto_SharedArrayBuffer: return !cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled(); - case JSProto_WeakRef: - case JSProto_FinalizationRegistry: - return JS::GetWeakRefsEnabled() == JS::WeakRefSpecifier::Disabled; - case JSProto_AsyncIterator: return !IsAsyncIteratorHelpersEnabled(); diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp index 2352c12ba349..5f8fe808d0ac 100644 --- a/js/src/vm/JSObject.cpp +++ b/js/src/vm/JSObject.cpp @@ -2221,8 +2221,7 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, } if (key == JSProto_FinalizationRegistry && - JS::GetWeakRefsEnabled() == - JS::WeakRefSpecifier::EnabledWithoutCleanupSome && + !JS::Prefs::experimental_weakrefs_expose_cleanupSome() && id == NameToId(cx->names().cleanupSome)) { return true; } diff --git a/js/xpconnect/tests/mochitest/mochitest.toml b/js/xpconnect/tests/mochitest/mochitest.toml index 34d5346c8268..d7b5729dd79a 100644 --- a/js/xpconnect/tests/mochitest/mochitest.toml +++ b/js/xpconnect/tests/mochitest/mochitest.toml @@ -44,7 +44,6 @@ support-files = [ "shadow_realm_module.js", ] prefs = [ - "javascript.options.weakrefs=true", "javascript.options.spectre.disable_for_isolated_content=true", "javascript.options.experimental.json_parse_with_source=true", "javascript.options.experimental.shadow_realms=true", diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 3df829c2a19b..941ed66091bd 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -8334,13 +8334,6 @@ mirror: always set_spidermonkey_pref: startup -# Support for weak references in JavaScript (WeakRef and FinalizationRegistry). -- name: javascript.options.weakrefs - type: bool - value: true - mirror: always - set_spidermonkey_pref: startup - # Whether to expose the FinalizationRegistry.prototype.cleanupSome method. - name: javascript.options.experimental.weakrefs.expose_cleanupSome type: bool