diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 870e6b58be76..01e43a320448 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -12956,9 +12956,6 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) { if (op.getBoolOption("enable-atomics-pause")) { JS::Prefs::setAtStartup_experimental_atomics_pause(true); } - if (op.getBoolOption("enable-error-iserror")) { - JS::Prefs::set_experimental_error_iserror(true); - } #ifdef NIGHTLY_BUILD if (op.getBoolOption("enable-async-iterator-helpers")) { JS::Prefs::setAtStartup_experimental_async_iterator_helpers(true); @@ -12966,6 +12963,9 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) { if (op.getBoolOption("enable-symbols-as-weakmap-keys")) { JS::Prefs::setAtStartup_experimental_symbols_as_weakmap_keys(true); } + if (op.getBoolOption("enable-error-iserror")) { + JS::Prefs::set_experimental_error_iserror(true); + } if (op.getBoolOption("enable-iterator-sequencing")) { JS::Prefs::setAtStartup_experimental_iterator_sequencing(true); } diff --git a/js/src/vm/ErrorObject.cpp b/js/src/vm/ErrorObject.cpp index acf0a1a65b52..99d4567d84a8 100644 --- a/js/src/vm/ErrorObject.cpp +++ b/js/src/vm/ErrorObject.cpp @@ -979,6 +979,8 @@ static bool exn_toSource(JSContext* cx, unsigned argc, Value* vp) { return true; } +#ifdef NIGHTLY_BUILD + /** * Error.isError Proposal * Error.isError ( arg ) @@ -1026,6 +1028,7 @@ static bool exn_isError(JSContext* cx, unsigned argc, Value* vp) { args.rval().setBoolean(false); return true; } +#endif // The below is the "documentation" from https://v8.dev/docs/stack-trace-api // diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp index 303fff57c79e..204280889e71 100644 --- a/js/src/vm/JSObject.cpp +++ b/js/src/vm/JSObject.cpp @@ -2259,10 +2259,6 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, id == NameToId(cx->names().try_)) { return true; } - if (!JS::Prefs::experimental_error_iserror() && - id == NameToId(cx->names().isError)) { - return true; - } } #ifdef JS_HAS_TEMPORAL_API @@ -2277,6 +2273,10 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, // to realize is that this is a -constructor function-, not a function // on the prototype; and the proto of the constructor is JSProto_Function. if (key == JSProto_Function) { + if (!JS::Prefs::experimental_error_iserror() && + id == NameToId(cx->names().isError)) { + return true; + } if (!JS::Prefs::experimental_iterator_range() && (id == NameToId(cx->names().range))) { return true; diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 79a43f2b70cd..c2f60df01274 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -8512,18 +8512,11 @@ set_spidermonkey_pref: startup # Experimental support for Atomics.pause in JavaScript. -- name: javascript.options.experimental.atomics_pause - type: bool - value: true - mirror: always - set_spidermonkey_pref: startup - - # Experimental support for Error.isError in JavaScript. -- name: javascript.options.experimental.error_iserror - type: bool - value: true - mirror: always - set_spidermonkey_pref: always +- name: javascript.options.experimental.atomics_pause + type: bool + value: true + mirror: always + set_spidermonkey_pref: startup #ifdef NIGHTLY_BUILD # Experimental support for Async Iterator Helpers in JavaScript. @@ -8540,6 +8533,13 @@ mirror: always set_spidermonkey_pref: startup + # Experimental support for Error.isError in JavaScript. +- name: javascript.options.experimental.error_iserror + type: bool + value: false + mirror: always + set_spidermonkey_pref: always + # Experimental support for Iterator.range in JavaScript. - name: javascript.options.experimental.iterator_range type: bool