From f92f3340b6c56c01596039146c5267c594cfef13 Mon Sep 17 00:00:00 2001 From: Bryan Thrall Date: Fri, 2 Feb 2024 19:08:17 +0000 Subject: [PATCH] Bug 1860887 - Enable JSON.parse with source when configured r=jandem Differential Revision: https://phabricator.services.mozilla.com/D198319 --- js/moz.configure | 18 ++++++++++++++++++ js/src/builtin/TestingFunctions.cpp | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/js/moz.configure b/js/moz.configure index cb2a3c833f72a..edaa33825afa9 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -173,6 +173,24 @@ def enable_decorators(value): set_config("ENABLE_DECORATORS", enable_decorators) set_define("ENABLE_DECORATORS", enable_decorators) +# Enable JSON.parse with source +# =================================================== +option( + "--enable-json-parse-with-source", + default=moz_debug, + help="Enable experimental JS JSON.parse with source support", +) + + +@depends("--enable-json-parse-with-source", moz_debug) +def enable_json_parse_with_source(value, moz_debug): + if value or moz_debug: + return True + + +set_config("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source) +set_define("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source) + # Portable Baseline Intepreter # ======================================================= diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index b4c3b6bf69870..f2fe91808a327 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -619,6 +619,15 @@ static bool GetBuildConfiguration(JSContext* cx, unsigned argc, Value* vp) { return false; } +#ifdef ENABLE_JSON_PARSE_WITH_SOURCE + value = BooleanValue(true); +#else + value = BooleanValue(false); +#endif + if (!JS_SetProperty(cx, info, "json-parse-with-source", value)) { + return false; + } + #ifdef FUZZING value = BooleanValue(true); #else