commit 9cfd08b1b4b205a775f1352105586e05d3d1b40c parent ba21d0d47ecadbce40b1b7413116bd3aff282645 Author: Cornelius Emase <corneliuslochipi@gmail.com> Date: Thu, 23 Oct 2025 14:51:21 +0000 Bug 1913086 - remove json_parse_with_source pref and js shell option. r=bthrall This patch removes the experimental pref and shell option, along with related skip-if clauses in the tests. Differential Revision: https://phabricator.services.mozilla.com/D267244 Diffstat:
34 files changed, 37 insertions(+), 88 deletions(-)
diff --git a/js/src/builtin/JSON.cpp b/js/src/builtin/JSON.cpp @@ -1716,35 +1716,33 @@ static bool InternalizeJSONProperty(JSContext* cx, HandleObject holder, RootedObject context(cx); Rooted<ParseRecordObject*> entries(cx); - if (JS::Prefs::experimental_json_parse_with_source()) { - // https://tc39.es/proposal-json-parse-with-source/#sec-internalizejsonproperty - if (parseRecord) { - bool sameVal = false; - if (!SameValue(cx, parseRecord->getValue(), val, &sameVal)) { - return false; - } - if (parseRecord->hasValue() && sameVal) { - if (parseRecord->getParseNode()) { - MOZ_ASSERT(!val.isObject()); - Rooted<IdValueVector> props(cx, cx); - if (!props.emplaceBack( - IdValuePair(NameToId(cx->names().source), - StringValue(parseRecord->getParseNode())))) { - return false; - } - context = NewPlainObjectWithUniqueNames(cx, props); - if (!context) { - return false; - } + // https://tc39.es/proposal-json-parse-with-source/#sec-internalizejsonproperty + if (parseRecord) { + bool sameVal = false; + if (!SameValue(cx, parseRecord->getValue(), val, &sameVal)) { + return false; + } + if (parseRecord->hasValue() && sameVal) { + if (parseRecord->getParseNode()) { + MOZ_ASSERT(!val.isObject()); + Rooted<IdValueVector> props(cx, cx); + if (!props.emplaceBack( + IdValuePair(NameToId(cx->names().source), + StringValue(parseRecord->getParseNode())))) { + return false; + } + context = NewPlainObjectWithUniqueNames(cx, props); + if (!context) { + return false; } - entries.set(parseRecord); } + entries.set(parseRecord); } + } + if (!context) { + context = NewPlainObject(cx); if (!context) { - context = NewPlainObject(cx); - if (!context) { - return false; - } + return false; } } @@ -1870,11 +1868,8 @@ static bool InternalizeJSONProperty(JSContext* cx, HandleObject holder, } RootedValue keyVal(cx, StringValue(key)); - if (JS::Prefs::experimental_json_parse_with_source()) { - RootedValue contextVal(cx, ObjectValue(*context)); - return js::Call(cx, reviver, holder, keyVal, val, contextVal, vp); - } - return js::Call(cx, reviver, holder, keyVal, val, vp); + RootedValue contextVal(cx, ObjectValue(*context)); + return js::Call(cx, reviver, holder, keyVal, val, contextVal, vp); } static bool Revive(JSContext* cx, HandleValue reviver, @@ -1888,8 +1883,7 @@ static bool Revive(JSContext* cx, HandleValue reviver, return false; } - MOZ_ASSERT_IF(JS::Prefs::experimental_json_parse_with_source(), - pro->getValue() == vp.get()); + MOZ_ASSERT(pro->getValue() == vp.get()); Rooted<jsid> id(cx, NameToId(cx->names().empty_)); return InternalizeJSONProperty(cx, obj, id, reviver, pro, vp); } @@ -1910,7 +1904,7 @@ bool js::ParseJSONWithReviver(JSContext* cx, JS::ProfilingCategoryPair::JS_Parsing); /* https://262.ecma-international.org/14.0/#sec-json.parse steps 2-10. */ Rooted<ParseRecordObject*> pro(cx); - if (JS::Prefs::experimental_json_parse_with_source() && IsCallable(reviver)) { + if (IsCallable(reviver)) { Rooted<JSONReviveParser<CharT>> parser(cx, cx, chars); if (!parser.get().parse(vp, &pro)) { return false; diff --git a/js/src/jit-test/tests/JSON/parse-oom.js b/js/src/jit-test/tests/JSON/parse-oom.js @@ -1,4 +1,4 @@ -// |jit-test| --enable-json-parse-with-source; skip-if: !JSON.hasOwnProperty('isRawJSON') +// |jit-test| skip-if: !JSON.hasOwnProperty('isRawJSON') oomTest(() => { JSON.parse('{"a": [1, {"b":2}, "7"], "c": 8}'); diff --git a/js/src/jit-test/tests/JSON/parse-with-source-oom.js b/js/src/jit-test/tests/JSON/parse-with-source-oom.js @@ -1,4 +1,4 @@ -// |jit-test| --enable-json-parse-with-source +// |jit-test| oomTest(() => { JSON.parse( diff --git a/js/src/jsapi-tests/testParseJSON.cpp b/js/src/jsapi-tests/testParseJSON.cpp @@ -321,9 +321,7 @@ END_TEST(testParseJSON_error) static bool Censor(JSContext* cx, unsigned argc, JS::Value* vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - const unsigned expectedArgCount = - JS::Prefs::experimental_json_parse_with_source() ? 3 : 2; - MOZ_RELEASE_ASSERT(args.length() == expectedArgCount); + MOZ_RELEASE_ASSERT(args.length() == 3); MOZ_RELEASE_ASSERT(args[0].isString()); args.rval().setNull(); return true; diff --git a/js/src/shell/fuzz-flags.txt b/js/src/shell/fuzz-flags.txt @@ -8,8 +8,7 @@ --no-blinterp --blinterp-eager --cache-ir-stubs=off ---cache-ir-stubs=on ---enable-json-parse-with-source +--cache-ir-stubs=on --ion-check-range-analysis --ion-eager --ion-edgecase-analysis=off diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp @@ -12829,8 +12829,6 @@ bool InitOptionParser(OptionParser& op) { "Enable iterator helpers") || !op.addBoolOption('\0', "enable-async-iterator-helpers", "Enable async iterator helpers") || - !op.addBoolOption('\0', "enable-json-parse-with-source", - "Enable JSON.parse with source") || !op.addBoolOption('\0', "enable-shadow-realms", "Enable ShadowRealms") || !op.addBoolOption('\0', "disable-array-grouping", "Disable Object.groupBy and Map.groupBy") || @@ -13285,10 +13283,6 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) { JS::Prefs::setAtStartup_experimental_temporal(true); } #endif - if (op.getBoolOption("enable-json-parse-with-source")) { - JS::Prefs::set_experimental_json_parse_with_source(true); - } - JS::Prefs::setAtStartup_experimental_weakrefs_expose_cleanupSome(true); if (op.getBoolOption("disable-property-error-message-fix")) { diff --git a/js/src/tests/non262/JSON/parse-with-source-ccw.js b/js/src/tests/non262/JSON/parse-with-source-ccw.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) +// |reftest| skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) (function checkCrossCompartmentWrappers() { var gbl = newGlobal({newCompartment: true}); diff --git a/js/src/tests/non262/JSON/parse-with-source-proto.js b/js/src/tests/non262/JSON/parse-with-source-proto.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) +// |reftest| skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) // Changing Object.prototype should not change the behavior of JSON parsing. Object.defineProperty(Object.prototype, 1, { diff --git a/js/src/tests/test262-update.py b/js/src/tests/test262-update.py @@ -35,7 +35,7 @@ FEATURE_CHECK_NEEDED = { "Intl.Segmenter": "!Intl.Segmenter", # Bug 1423593 "Intl.DurationFormat": "!Intl.hasOwnProperty('DurationFormat')", # Bug 1648139 "uint8array-base64": "!Uint8Array.fromBase64", # Bug 1862220 - "json-parse-with-source": "!JSON.hasOwnProperty('isRawJSON')", # Bug 1658310 + "RegExp.escape": "!RegExp.escape", "explicit-resource-management": "!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))", # Bug 1569081 "Atomics.pause": "!this.hasOwnProperty('Atomics')||!Atomics.pause", "Error.isError": "!Error.isError", @@ -50,7 +50,9 @@ SHELL_OPTIONS = { "iterator-helpers": "--enable-iterator-helpers", "symbols-as-weakmap-keys": "--enable-symbols-as-weakmap-keys", "uint8array-base64": "--enable-uint8array-base64", - "json-parse-with-source": "--enable-json-parse-with-source", + "regexp-duplicate-named-groups": "--enable-regexp-duplicate-named-groups", + "RegExp.escape": "--enable-regexp-escape", + "regexp-modifiers": "--enable-regexp-modifiers", "explicit-resource-management": "--enable-explicit-resource-management", "Atomics.pause": "--enable-atomics-pause", "Temporal": "--enable-temporal", diff --git a/js/src/tests/test262/built-ins/JSON/isRawJSON/basic.js b/js/src/tests/test262/built-ins/JSON/isRawJSON/basic.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/isRawJSON/builtin.js b/js/src/tests/test262/built-ins/JSON/isRawJSON/builtin.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/isRawJSON/length.js b/js/src/tests/test262/built-ins/JSON/isRawJSON/length.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/isRawJSON/name.js b/js/src/tests/test262/built-ins/JSON/isRawJSON/name.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/isRawJSON/not-a-constructor.js b/js/src/tests/test262/built-ins/JSON/isRawJSON/not-a-constructor.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/isRawJSON/prop-desc.js b/js/src/tests/test262/built-ins/JSON/isRawJSON/prop-desc.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-call-args-after-forward-modification.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-call-args-after-forward-modification.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-context-source-array-literal.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-context-source-array-literal.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-context-source-object-literal.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-context-source-object-literal.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-context-source-primitive-literal.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-context-source-primitive-literal.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-forward-modifies-object.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-forward-modifies-object.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/basic.js b/js/src/tests/test262/built-ins/JSON/rawJSON/basic.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/bigint-raw-json-can-be-stringified.js b/js/src/tests/test262/built-ins/JSON/rawJSON/bigint-raw-json-can-be-stringified.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/builtin.js b/js/src/tests/test262/built-ins/JSON/rawJSON/builtin.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/illegal-empty-and-start-end-chars.js b/js/src/tests/test262/built-ins/JSON/rawJSON/illegal-empty-and-start-end-chars.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/invalid-JSON-text.js b/js/src/tests/test262/built-ins/JSON/rawJSON/invalid-JSON-text.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/length.js b/js/src/tests/test262/built-ins/JSON/rawJSON/length.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/name.js b/js/src/tests/test262/built-ins/JSON/rawJSON/name.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/not-a-constructor.js b/js/src/tests/test262/built-ins/JSON/rawJSON/not-a-constructor.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/prop-desc.js b/js/src/tests/test262/built-ins/JSON/rawJSON/prop-desc.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2024 Igalia S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/JSON/rawJSON/returns-expected-object.js b/js/src/tests/test262/built-ins/JSON/rawJSON/returns-expected-object.js @@ -1,4 +1,3 @@ -// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options // Copyright (C) 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp @@ -2253,13 +2253,6 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, return true; } - if (key == JSProto_JSON && - !JS::Prefs::experimental_json_parse_with_source() && - (id == NameToId(cx->names().isRawJSON) || - id == NameToId(cx->names().rawJSON))) { - return true; - } - if (key == JSProto_Math && !JS::Prefs::experimental_math_sumprecise() && id == NameToId(cx->names().sumPrecise)) { return true; diff --git a/js/xpconnect/tests/mochitest/mochitest.toml b/js/xpconnect/tests/mochitest/mochitest.toml @@ -45,7 +45,6 @@ support-files = [ ] prefs = [ "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/js/xpconnect/tests/unit/xpcshell.toml b/js/xpconnect/tests/unit/xpcshell.toml @@ -261,9 +261,6 @@ skip-if = ["!nightly_build"] ["test_js_weak_references.js"] ["test_json_parse_with_source.js"] -prefs = [ - "javascript.options.experimental.json_parse_with_source=true", -] ["test_loadedESModules.js"] diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -9048,12 +9048,6 @@ mirror: always set_spidermonkey_pref: always -- name: javascript.options.experimental.json_parse_with_source - type: bool - value: true - mirror: always - set_spidermonkey_pref: always - # Dictionary Teleporting - name: javascript.options.experimental.dictionary_teleporting type: bool