From b56bdc1e4bd37413cc1517bd6e4fe87f2182785b Mon Sep 17 00:00:00 2001 From: Matthew Gaudet Date: Mon, 20 Jul 2020 13:49:14 +0000 Subject: [PATCH] Bug 1652744 - Add browser pref for private fields support r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D83511 --- js/src/tests/user.js | 1 + js/xpconnect/src/XPCJSContext.cpp | 6 +++++- modules/libpref/init/StaticPrefList.yaml | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/js/src/tests/user.js b/js/src/tests/user.js index fccc6c696d28..bd32d987fa8e 100644 --- a/js/src/tests/user.js +++ b/js/src/tests/user.js @@ -33,3 +33,4 @@ 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.private_fields", true); \ No newline at end of file diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index 54461fb88c1d..119fb221c58a 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -760,6 +760,7 @@ static mozilla::Atomic sPropertyErrorMessageFixEnabled(false); static mozilla::Atomic sWeakRefsEnabled(false); static mozilla::Atomic sWeakRefsExposeCleanupSome(false); static mozilla::Atomic sIteratorHelpersEnabled(false); +static mozilla::Atomic sPrivateFieldsEnabled(false); static JS::WeakRefSpecifier GetWeakRefsEnabled() { if (!sWeakRefsEnabled) { @@ -784,7 +785,8 @@ void xpc::SetPrefableRealmOptions(JS::RealmOptions& options) { StaticPrefs::javascript_options_writable_streams()) .setPropertyErrorMessageFixEnabled(sPropertyErrorMessageFixEnabled) .setWeakRefsEnabled(GetWeakRefsEnabled()) - .setIteratorHelpersEnabled(sIteratorHelpersEnabled); + .setIteratorHelpersEnabled(sIteratorHelpersEnabled) + .setPrivateClassFieldsEnabled(sPrivateFieldsEnabled); } static void LoadStartupJSPrefs(XPCJSContext* xpccx) { @@ -967,6 +969,8 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) { #ifdef NIGHTLY_BUILD sIteratorHelpersEnabled = Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.iterator_helpers"); + sPrivateFieldsEnabled = + Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.private_fields"); #endif #ifdef JS_GC_ZEAL diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 994d3f3d6e5c..c8f5776425e2 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -4909,6 +4909,12 @@ type: RelaxedAtomicBool value: false mirror: always + + # Experimental support for Private Fields in JavaScript. +- name: javascript.options.experimental.private_fields + type: RelaxedAtomicBool + value: false + mirror: always #endif # The amount of time we wait between a request to GC (due to leaving a page) and doing the actual GC, in ms.