Bug 1767525 - Implement (under a flag) ShadowRealm constructor and evaluate function. r=jandem

Shell only, without HostInitializeShadowRealm, nor importValue

Differential Revision: https://phabricator.services.mozilla.com/D146236
This commit is contained in:
Matthew Gaudet
2022-06-28 22:04:16 +00:00
parent 640195e6fd
commit 18a19d61d4
17 changed files with 923 additions and 2 deletions

View File

@@ -140,6 +140,7 @@
#include "js/MemoryFunctions.h"
#include "js/Modules.h" // JS::GetModulePrivate, JS::SetModule{DynamicImport,Metadata,Resolve}Hook, JS::SetModulePrivate
#include "js/Object.h" // JS::GetClass, JS::GetCompartment, JS::GetReservedSlot, JS::SetReservedSlot
#include "js/Principals.h"
#include "js/Printf.h"
#include "js/PropertyAndElement.h" // JS_DefineElement, JS_DefineFunction, JS_DefineFunctions, JS_DefineProperties, JS_DefineProperty, JS_GetElement, JS_GetProperty, JS_GetPropertyById, JS_HasProperty, JS_SetElement, JS_SetProperty, JS_SetPropertyById
#include "js/PropertySpec.h"
@@ -626,6 +627,7 @@ bool shell::enableWeakRefs = false;
bool shell::enableToSource = false;
bool shell::enablePropertyErrorMessageFix = false;
bool shell::enableIteratorHelpers = false;
bool shell::enableShadowRealms = false;
#ifdef NIGHTLY_BUILD
bool shell::enableArrayGrouping = true;
#endif
@@ -4246,6 +4248,7 @@ static void SetStandardRealmOptions(JS::RealmOptions& options) {
.setToSourceEnabled(enableToSource)
.setPropertyErrorMessageFixEnabled(enablePropertyErrorMessageFix)
.setIteratorHelpersEnabled(enableIteratorHelpers)
.setShadowRealmsEnabled(enableShadowRealms)
#ifdef NIGHTLY_BUILD
.setArrayGroupingEnabled(enableArrayGrouping)
#endif
@@ -11039,6 +11042,7 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
enablePropertyErrorMessageFix =
!op.getBoolOption("disable-property-error-message-fix");
enableIteratorHelpers = op.getBoolOption("enable-iterator-helpers");
enableShadowRealms = op.getBoolOption("enable-shadow-realms");
#ifdef NIGHTLY_BUILD
enableArrayGrouping = op.getBoolOption("enable-array-grouping");
#endif
@@ -12074,6 +12078,7 @@ int main(int argc, char** argv) {
"property of null or undefined") ||
!op.addBoolOption('\0', "enable-iterator-helpers",
"Enable iterator helpers") ||
!op.addBoolOption('\0', "enable-shadow-realms", "Enable ShadowRealms") ||
!op.addBoolOption('\0', "enable-array-grouping",
"Enable Array Grouping") ||
!op.addBoolOption('\0', "enable-array-find-last",
@@ -12636,6 +12641,7 @@ int main(int argc, char** argv) {
// Waiting is allowed on the shell's main thread, for now.
JS_SetFutexCanWait(cx);
JS::SetWarningReporter(cx, WarningReporter);
if (!SetContextOptions(cx, op)) {
return 1;
}