Backed out 9 changesets (bug 1747059, bug 1767525)for causing hazard failures on ShadowRealmGlobalScope.cpp. CLOSED TREE

Backed out changeset ed7aad37f2cf (bug 1747059)
Backed out changeset 40a257fb4788 (bug 1747059)
Backed out changeset f7b049ef3b8c (bug 1747059)
Backed out changeset aad38abc7139 (bug 1747059)
Backed out changeset 8115813e77a5 (bug 1747059)
Backed out changeset e06192e664fd (bug 1747059)
Backed out changeset a198b0893220 (bug 1767525)
Backed out changeset c083f0824619 (bug 1767525)
Backed out changeset 9a3bf794ec6d (bug 1767525)
This commit is contained in:
Csoregi Natalia
2022-06-28 02:39:08 +03:00
parent 1a15d785af
commit d91db2b437
108 changed files with 82 additions and 1858 deletions

View File

@@ -139,7 +139,7 @@ nsresult nsJSUtils::CompileFunction(AutoJSAPI& jsapi,
/* static */
bool nsJSUtils::IsScriptable(JS::Handle<JSObject*> aEvaluationGlobal) {
return xpc::Scriptability::AllowedIfExists(aEvaluationGlobal);
return xpc::Scriptability::Get(aEvaluationGlobal).Allowed();
}
static bool AddScopeChainItem(JSContext* aCx, nsINode* aNode,

View File

@@ -2802,8 +2802,7 @@ bool IsNonExposedGlobal(JSContext* aCx, JSObject* aGlobal,
GlobalNames::WorkerDebuggerGlobalScope |
GlobalNames::WorkletGlobalScope |
GlobalNames::AudioWorkletGlobalScope |
GlobalNames::PaintWorkletGlobalScope |
GlobalNames::ShadowRealmGlobalScope)) == 0,
GlobalNames::PaintWorkletGlobalScope)) == 0,
"Unknown non-exposed global type");
const char* name = JS::GetClass(aGlobal)->name;
@@ -2848,11 +2847,6 @@ bool IsNonExposedGlobal(JSContext* aCx, JSObject* aGlobal,
return true;
}
if ((aNonExposedGlobals & GlobalNames::ShadowRealmGlobalScope) &&
!strcmp(name, "ShadowRealmGlobalScope")) {
return true;
}
return false;
}

View File

@@ -785,10 +785,6 @@ DOMInterfaces = {
'implicitJSContext': [ 'pushManager' ],
},
'ShadowRealmGlobalScope': {
'hasOrdinaryObjectPrototype': True,
},
'SharedWorkerGlobalScope': {
'headerFile': 'mozilla/dom/WorkerScope.h',
},

View File

@@ -571,18 +571,13 @@ def DOMClass(descriptor):
else:
wrapperCacheGetter = "nullptr"
if descriptor.hasOrdinaryObjectPrototype:
getProto = "JS::GetRealmObjectPrototypeHandle"
else:
getProto = "GetProtoObjectHandle"
return fill(
"""
{ ${protoChain} },
std::is_base_of_v<nsISupports, ${nativeType}>,
${hooks},
FindAssociatedGlobalForNative<${nativeType}>::Get,
${getProto},
GetProtoObjectHandle,
GetCCParticipant<${nativeType}>::Get(),
${serializer},
${wrapperCacheGetter}
@@ -592,7 +587,6 @@ def DOMClass(descriptor):
hooks=NativePropertyHooks(descriptor),
serializer=serializer,
wrapperCacheGetter=wrapperCacheGetter,
getProto=getProto,
)
@@ -3889,11 +3883,9 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
else:
unforgeableHolderSetup = None
# FIXME Unclear whether this is needed for hasOrdinaryObjectPrototype
if (
self.descriptor.interface.isOnGlobalProtoChain()
and needInterfacePrototypeObject
and not self.descriptor.hasOrdinaryObjectPrototype
):
makeProtoPrototypeImmutable = CGGeneric(
fill(
@@ -4802,17 +4794,13 @@ class CGWrapGlobalMethod(CGAbstractMethod):
else:
unforgeable = ""
if self.descriptor.hasOrdinaryObjectPrototype:
getProto = "JS::GetRealmObjectPrototypeHandle"
else:
getProto = "GetProtoObjectHandle"
return fill(
"""
$*{assertions}
MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
"nsISupports must be on our primary inheritance chain");
if (!CreateGlobal<${nativeType}, ${getProto}>(aCx,
if (!CreateGlobal<${nativeType}, GetProtoObjectHandle>(aCx,
aObject,
aCache,
sClass.ToJSClass(),
@@ -4838,7 +4826,6 @@ class CGWrapGlobalMethod(CGAbstractMethod):
""",
assertions=AssertInheritanceChain(self.descriptor),
nativeType=self.descriptor.nativeType,
getProto=getProto,
properties=properties,
chromeProperties=chromeProperties,
failureCode=failureCode,
@@ -16533,10 +16520,7 @@ class CGDescriptor(CGThing):
# CGGetProtoObjectMethod and CGGetConstructorObjectMethod need
# to come after CGCreateInterfaceObjectsMethod.
if (
descriptor.interface.hasInterfacePrototypeObject()
and not descriptor.hasOrdinaryObjectPrototype
):
if descriptor.interface.hasInterfacePrototypeObject():
cgThings.append(CGGetProtoObjectHandleMethod(descriptor))
if descriptor.interface.hasChildInterfaces():
cgThings.append(CGGetProtoObjectMethod(descriptor))
@@ -17770,38 +17754,6 @@ class CGRegisterWorkletBindings(CGAbstractMethod):
return CGList(lines, "\n").define()
class CGRegisterShadowRealmBindings(CGAbstractMethod):
def __init__(self, config):
CGAbstractMethod.__init__(
self,
None,
"RegisterShadowRealmBindings",
"bool",
[Argument("JSContext*", "aCx"), Argument("JS::Handle<JSObject*>", "aObj")],
)
self.config = config
def definition_body(self):
descriptors = self.config.getDescriptors(
hasInterfaceObject=True, isExposedInShadowRealms=True, register=True
)
conditions = []
for desc in descriptors:
bindingNS = toBindingNamespace(desc.name)
condition = "!%s::GetConstructorObject(aCx)" % bindingNS
if desc.isExposedConditionally():
condition = (
"%s::ConstructorEnabled(aCx, aObj) && " % bindingNS + condition
)
conditions.append(condition)
lines = [
CGIfWrapper(CGGeneric("return false;\n"), condition)
for condition in conditions
]
lines.append(CGGeneric("return true;\n"))
return CGList(lines, "\n").define()
def BindingNamesOffsetEnum(name):
return CppKeywords.checkMethodName(name.replace(" ", "_"))
@@ -23134,33 +23086,6 @@ class GlobalGenRoots:
# Done.
return curr
@staticmethod
def RegisterShadowRealmBindings(config):
curr = CGRegisterShadowRealmBindings(config)
# Wrap all of that in our namespaces.
curr = CGNamespace.build(["mozilla", "dom"], CGWrapper(curr, post="\n"))
curr = CGWrapper(curr, post="\n")
# Add the includes
defineIncludes = [
CGHeaders.getDeclarationFilename(desc.interface)
for desc in config.getDescriptors(
hasInterfaceObject=True, register=True, isExposedInShadowRealms=True
)
]
curr = CGHeaders(
[], [], [], [], [], defineIncludes, "RegisterShadowRealmBindings", curr
)
# Add include guards.
curr = CGIncludeGuard("RegisterShadowRealmBindings", curr)
# Done.
return curr
@staticmethod
def UnionTypes(config):
unionTypes = UnionsForFile(config, None)

View File

@@ -296,8 +296,6 @@ class Configuration(DescriptorProvider):
getter = lambda x: x.interface.isExposedInAnyWorklet()
elif key == "isExposedInWindow":
getter = lambda x: x.interface.isExposedInWindow()
elif key == "isExposedInShadowRealms":
getter = lambda x: x.interface.isExposedInShadowRealms()
elif key == "isSerializable":
getter = lambda x: x.interface.isSerializable()
else:
@@ -677,8 +675,6 @@ class Descriptor(DescriptorProvider):
config.maxProtoChainLength, len(self.prototypeChain)
)
self.hasOrdinaryObjectPrototype = desc.get("hasOrdinaryObjectPrototype", False)
def binaryNameFor(self, name):
return self._binaryNames.get(name, name)

View File

@@ -112,9 +112,8 @@ static const uint32_t WorkerDebuggerGlobalScope = 1u << 4;
static const uint32_t WorkletGlobalScope = 1u << 5;
static const uint32_t AudioWorkletGlobalScope = 1u << 6;
static const uint32_t PaintWorkletGlobalScope = 1u << 7;
static const uint32_t ShadowRealmGlobalScope = 1u << 8;
static constexpr uint32_t kCount = 9;
static constexpr uint32_t kCount = 8;
} // namespace GlobalNames
struct PrefableDisablers {

View File

@@ -156,7 +156,6 @@ class WebIDLCodegenManager(LoggingMixin):
"GeneratedEventList.h",
"PrototypeList.h",
"RegisterBindings.h",
"RegisterShadowRealmBindings.h",
"RegisterWorkerBindings.h",
"RegisterWorkerDebuggerBindings.h",
"RegisterWorkletBindings.h",
@@ -170,7 +169,6 @@ class WebIDLCodegenManager(LoggingMixin):
GLOBAL_DEFINE_FILES = {
"BindingNames.cpp",
"RegisterBindings.cpp",
"RegisterShadowRealmBindings.cpp",
"RegisterWorkerBindings.cpp",
"RegisterWorkerDebuggerBindings.cpp",
"RegisterWorkletBindings.cpp",

View File

@@ -492,7 +492,7 @@ class IDLExposureMixins:
# and add global interfaces and [Exposed] annotations to all those
# tests.
if len(scope.globalNames) != 0:
if len(self._exposureGlobalNames) == 0 and not self.isPseudoInterface():
if len(self._exposureGlobalNames) == 0:
raise WebIDLError(
(
"'%s' is not exposed anywhere even though we have "
@@ -528,9 +528,6 @@ class IDLExposureMixins:
workerScopes = self.parentScope.globalNameMapping["Worker"]
return len(workerScopes.difference(self.exposureSet)) > 0
def isExposedInShadowRealms(self):
return "ShadowRealmGlobalScope" in self.exposureSet
def getWorkerExposureSet(self):
workerScopes = self._globalScope.globalNameMapping["Worker"]
return workerScopes.intersection(self.exposureSet)
@@ -962,9 +959,6 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
self.interfacesBasedOnSelf = set([self])
self._hasChildInterfaces = False
self._isOnGlobalProtoChain = False
# Pseudo interfaces aren't exposed anywhere, and so shouldn't issue warnings
self._isPseudo = False
# Tracking of the number of reserved slots we need for our
# members and those of ancestor interfaces.
self.totalMembersInSlots = 0
@@ -1719,14 +1713,13 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
def hasInterfaceObject(self):
if self.isCallback():
return self.hasConstants()
return not hasattr(self, "_noInterfaceObject") and not self.isPseudoInterface()
return not hasattr(self, "_noInterfaceObject")
def hasInterfacePrototypeObject(self):
return (
not self.isCallback()
and not self.isNamespace()
and self.getUserData("hasConcreteDescendant", False)
and not self.isPseudoInterface()
)
def addIncludedMixin(self, includedMixin):
@@ -1790,9 +1783,6 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
def isOnGlobalProtoChain(self):
return self._isOnGlobalProtoChain
def isPseudoInterface(self):
return self._isPseudo
def _getDependentObjects(self):
deps = set(self.members)
deps.update(self.includedMixins)

View File

@@ -172,7 +172,7 @@ NS_IMPL_CYCLE_COLLECTION(ScriptLoader, mNonAsyncExternalScriptInsertedRequests,
mXSLTRequests, mParserBlockingRequest,
mBytecodeEncodingQueue, mPreloads,
mPendingChildLoaders, mModuleLoader,
mWebExtModuleLoaders, mShadowRealmModuleLoaders)
mWebExtModuleLoaders)
NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptLoader)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptLoader)
@@ -279,13 +279,6 @@ void ScriptLoader::RegisterContentScriptModuleLoader(ModuleLoader* aLoader) {
mWebExtModuleLoaders.AppendElement(aLoader);
}
void ScriptLoader::RegisterShadowRealmModuleLoader(ModuleLoader* aLoader) {
MOZ_ASSERT(aLoader);
MOZ_ASSERT(aLoader->GetScriptLoader() == this);
mShadowRealmModuleLoaders.AppendElement(aLoader);
}
// Collect telemtry data about the cache information, and the kind of source
// which are being loaded, and where it is being loaded from.
static void CollectScriptTelemetry(ScriptLoadRequest* aRequest) {
@@ -2691,12 +2684,6 @@ bool ScriptLoader::HasPendingDynamicImports() const {
}
}
for (ModuleLoader* loader : mShadowRealmModuleLoaders) {
if (loader->HasPendingDynamicImports()) {
return true;
}
}
return false;
}
@@ -3535,10 +3522,6 @@ void ScriptLoader::ParsingComplete(bool aTerminated) {
loader->CancelAndClearDynamicImports();
}
for (ModuleLoader* loader : mShadowRealmModuleLoaders) {
loader->CancelAndClearDynamicImports();
}
if (mParserBlockingRequest) {
mParserBlockingRequest->Cancel();
mParserBlockingRequest = nullptr;

View File

@@ -210,7 +210,6 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
ModuleLoader* GetModuleLoader() { return mModuleLoader; }
void RegisterContentScriptModuleLoader(ModuleLoader* aLoader);
void RegisterShadowRealmModuleLoader(ModuleLoader* aLoader);
/**
* Check whether to speculatively OMT parse scripts as soon as
@@ -741,7 +740,6 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
RefPtr<ModuleLoader> mModuleLoader;
nsTArray<RefPtr<ModuleLoader>> mWebExtModuleLoaders;
nsTArray<RefPtr<ModuleLoader>> mShadowRealmModuleLoaders;
// Logging
public:

View File

@@ -1,125 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsGlobalWindowInner.h"
#include "nsIGlobalObject.h"
#include "xpcpublic.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ModuleLoader.h"
#include "mozilla/dom/ShadowRealmGlobalScope.h"
#include "mozilla/dom/ShadowRealmGlobalScopeBinding.h"
#include "js/loader/ModuleLoaderBase.h"
using namespace JS::loader;
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ShadowRealmGlobalScope, mModuleLoader,
mCreatingGlobal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(ShadowRealmGlobalScope)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ShadowRealmGlobalScope)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ShadowRealmGlobalScope)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_INTERFACE_MAP_ENTRY(ShadowRealmGlobalScope)
NS_INTERFACE_MAP_END
JSObject* NewShadowRealmGlobal(JSContext* aCx, JS::RealmOptions& aOptions,
JSPrincipals* aPrincipals,
JS::Handle<JSObject*> aGlobalObj) {
GlobalObject global(aCx, aGlobalObj);
nsCOMPtr<nsIGlobalObject> nsGlobal =
do_QueryInterface(global.GetAsSupports());
MOZ_ASSERT(nsGlobal);
RefPtr<ShadowRealmGlobalScope> scope = new ShadowRealmGlobalScope(nsGlobal);
JS::Rooted<JSObject*> reflector(aCx);
ShadowRealmGlobalScope_Binding::Wrap(aCx, scope, scope, aOptions, aPrincipals,
true, &reflector);
return reflector;
}
static nsIGlobalObject* FindEnclosingNonShadowRealmGlobal(
ShadowRealmGlobalScope* scope) {
nsCOMPtr<nsIGlobalObject> global = scope->GetCreatingGlobal();
do {
nsCOMPtr<ShadowRealmGlobalScope> shadowRealmGlobalScope =
do_QueryInterface(global);
if (!shadowRealmGlobalScope) {
break;
}
// Our global was a ShadowRealmGlobal; that's a problem, as we can't find a
// window or worker global associated with a ShadowRealmGlobal... so we
// continue following the chain.
//
// This will happen if you have nested ShadowRealms.
global = shadowRealmGlobalScope->GetCreatingGlobal();
} while (true);
return global;
}
ModuleLoaderBase* ShadowRealmGlobalScope::GetModuleLoader(JSContext* aCx) {
if (mModuleLoader) {
return mModuleLoader;
}
// Note: if this fails, we don't need to report an exception, as one will be
// reported by ModuleLoaderBase::GetCurrentModuleLoader.
// Don't bother asking the ShadowRealmGlobal itself for a host object to get a
// module loader from, instead, delegate to the enclosing global of the shadow
// realm
nsCOMPtr<nsIGlobalObject> global = FindEnclosingNonShadowRealmGlobal(this);
MOZ_RELEASE_ASSERT(global);
JSObject* object = global->GetGlobalJSObject();
MOZ_ASSERT(object);
// Currently Workers will never get here, because dynamic import is disabled
// in Worker context, and so importValue will throw before we get here.
//
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1247687 and
// https://bugzilla.mozilla.org/show_bug.cgi?id=1772162
nsGlobalWindowInner* window = xpc::WindowGlobalOrNull(object);
if (!window) {
return nullptr;
}
RefPtr<Document> doc = window->GetExtantDoc();
if (!doc) {
return nullptr;
}
ScriptLoader* scriptLoader = doc->ScriptLoader();
mModuleLoader = new ModuleLoader(scriptLoader, this, ModuleLoader::Normal);
// Register the shadow realm module loader for tracing and ownership.
scriptLoader->RegisterShadowRealmModuleLoader(
static_cast<ModuleLoader*>(mModuleLoader.get()));
return mModuleLoader;
}
bool IsShadowRealmGlobal(JSObject* aObject) {
return IS_INSTANCE_OF(ShadowRealmGlobalScope, aObject);
}
} // namespace mozilla::dom

View File

@@ -1,77 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_ShadowRealmGlobalScope_h
#define mozilla_dom_ShadowRealmGlobalScope_h
#include "js/TypeDecls.h"
#include "mozilla/Attributes.h"
#include "mozilla/Maybe.h"
#include "mozilla/OriginTrials.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsIGlobalObject.h"
#include "nsWrapperCache.h"
#include "js/loader/ModuleLoaderBase.h"
namespace mozilla::dom {
#define SHADOWREALMGLOBALSCOPE_IID \
{ /* 1b0a59dd-c1cb-429a-bb90-cea17994dba2 */ \
0x1b0a59dd, 0xc1cb, 0x429a, { \
0xbb, 0x90, 0xce, 0xa1, 0x79, 0x94, 0xdb, 0xa2 \
} \
}
// Required for providing the wrapper, as this is the global used inside a Gecko
// backed ShadowRealm, but also required to power module resolution.
class ShadowRealmGlobalScope : public nsIGlobalObject, public nsWrapperCache {
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ShadowRealmGlobalScope)
NS_DECLARE_STATIC_IID_ACCESSOR(SHADOWREALMGLOBALSCOPE_IID)
explicit ShadowRealmGlobalScope(nsIGlobalObject* aCreatingGlobal)
: mCreatingGlobal(aCreatingGlobal){};
nsIGlobalObject* GetCreatingGlobal() const { return mCreatingGlobal; }
OriginTrials Trials() const override { return {}; }
JSObject* GetGlobalJSObject() override { return GetWrapper(); }
JSObject* GetGlobalJSObjectPreserveColor() const override {
return GetWrapperPreserveColor();
}
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override {
MOZ_CRASH("Shouldn't be here");
return nullptr;
}
JS::loader::ModuleLoaderBase* GetModuleLoader(JSContext* aCx) override;
private:
virtual ~ShadowRealmGlobalScope() = default;
RefPtr<JS::loader::ModuleLoaderBase> mModuleLoader;
// The global which created this ShadowRealm
nsCOMPtr<nsIGlobalObject> mCreatingGlobal;
};
NS_DEFINE_STATIC_IID_ACCESSOR(ShadowRealmGlobalScope,
SHADOWREALMGLOBALSCOPE_IID)
JSObject* NewShadowRealmGlobal(JSContext* aCx, JS::RealmOptions& aOptions,
JSPrincipals* aPrincipals,
JS::Handle<JSObject*> aGlobalObj);
bool IsShadowRealmGlobal(JSObject* aObject);
} // namespace mozilla::dom
#endif

View File

@@ -27,7 +27,6 @@ EXPORTS.mozilla.dom += [
"ScriptLoader.h",
"ScriptSettings.h",
"ScriptTrace.h",
"ShadowRealmGlobalScope.h",
]
UNIFIED_SOURCES += [
@@ -40,7 +39,6 @@ UNIFIED_SOURCES += [
"ScriptLoader.cpp",
"ScriptLoadHandler.cpp",
"ScriptSettings.cpp",
"ShadowRealmGlobalScope.cpp",
]
LOCAL_INCLUDES += [

View File

@@ -1,11 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// This interface exists purely to register a new global as part of
// code generation so that we can properly hook this into
// shadow realms.
[Global=(ShadowRealmGlobal), Exposed=ShadowRealmGlobal, LegacyNoInterfaceObject]
interface ShadowRealmGlobalScope { };

View File

@@ -812,7 +812,6 @@ WEBIDL_FILES = [
"ServiceWorkerContainer.webidl",
"ServiceWorkerGlobalScope.webidl",
"ServiceWorkerRegistration.webidl",
"ShadowRealmGlobalScope.webidl",
"ShadowRoot.webidl",
"SharedWorker.webidl",
"SharedWorkerGlobalScope.webidl",

View File

@@ -46,7 +46,6 @@
#include "mozilla/dom/RemoteWorkerChild.h"
#include "mozilla/dom/WorkerBinding.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/ShadowRealmGlobalScope.h"
#include "mozilla/dom/IndexedDatabaseManager.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Preferences.h"
@@ -894,11 +893,11 @@ class WorkerJSContext final : public mozilla::CycleCollectedJSContext {
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
NS_ASSERTION(global, "This should never be null!");
// On worker threads, if the current global is the worker global or
// ShadowRealm global, we use the main micro task queue. Otherwise, the
// current global must be either the debugger global or a debugger sandbox,
// and we use the debugger micro task queue instead.
if (IsWorkerGlobal(global) || IsShadowRealmGlobal(global)) {
// On worker threads, if the current global is the worker global, we use the
// main micro task queue. Otherwise, the current global must be
// either the debugger global or a debugger sandbox, and we use the debugger
// micro task queue instead.
if (IsWorkerGlobal(global)) {
microTaskQueue = &GetMicroTaskQueue();
} else {
MOZ_ASSERT(IsWorkerDebuggerGlobal(global) ||

View File

@@ -90,7 +90,6 @@
REAL(Set, OCLASP(Set)) \
REAL(DataView, OCLASP(DataView)) \
REAL(Symbol, OCLASP(Symbol)) \
REAL(ShadowRealm, OCLASP(ShadowRealm)) \
REAL(SharedArrayBuffer, OCLASP(SharedArrayBuffer)) \
REAL_IF_INTL(Intl, CLASP(Intl)) \
REAL_IF_INTL(Collator, OCLASP(Collator)) \

View File

@@ -102,8 +102,6 @@ extern JS_PUBLIC_API bool MaybeFreezeCtorAndPrototype(JSContext* cx,
*/
extern JS_PUBLIC_API JSObject* GetRealmObjectPrototype(JSContext* cx);
extern JS_PUBLIC_API JS::Handle<JSObject*> GetRealmObjectPrototypeHandle(
JSContext* cx);
extern JS_PUBLIC_API JSObject* GetRealmFunctionPrototype(JSContext* cx);

View File

@@ -214,12 +214,6 @@ class JS_PUBLIC_API RealmCreationOptions {
return *this;
}
bool getShadowRealmsEnabled() const { return shadowRealms_; }
RealmCreationOptions& setShadowRealmsEnabled(bool flag) {
shadowRealms_ = flag;
return *this;
}
#ifdef NIGHTLY_BUILD
bool getArrayGroupingEnabled() const { return arrayGrouping_; }
RealmCreationOptions& setArrayGroupingEnabled(bool flag) {
@@ -280,7 +274,6 @@ class JS_PUBLIC_API RealmCreationOptions {
bool propertyErrorMessageFix_ = false;
bool iteratorHelpers_ = false;
bool arrayFindLast_ = false;
bool shadowRealms_ = false;
#ifdef NIGHTLY_BUILD
bool arrayGrouping_ = true;
#endif

View File

@@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef js_ShadowReamCallbacks_h
#define js_ShadowReamCallbacks_h
#include "jstypes.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
struct JS_PUBLIC_API JSContext;
namespace JS {
class RealmOptions;
using GlobalInitializeCallback = bool (*)(JSContext*, JS::Handle<JSObject*>);
// Install the HostInitializeShadowRealm callback that will be invoked when
// creating a shadow realm.
//
// The callback will be passed the realm's global object, so that it is possible
// for the embedding to make any host-determined manipulations to the global,
// such as installing interfaces or helpers that should exist even within
// ShadowRealms. (For example, in the web platform, WebIDL with the
// [Exposed=*] attribute should be installed within a shadow realm.)
extern JS_PUBLIC_API void SetShadowRealmInitializeGlobalCallback(
JSContext* cx, GlobalInitializeCallback callback);
using GlobalCreationCallback =
JSObject* (*)(JSContext* cx, JS::RealmOptions& creationOptions,
JSPrincipals* principals,
JS::Handle<JSObject*> enclosingGlobal);
// Create the Global object for a ShadowRealm.
//
// This isn't directly specified, however at least in Gecko, in order to
// correctly implement HostInitializeShadowRealm, there are requirements
// placed on the global for the ShadowRealm.
//
// This callback should return a Global object compatible with the
// callback installed by SetShadowRealmInitializeGlobalCallback
extern JS_PUBLIC_API void SetShadowRealmGlobalCreationCallback(
JSContext* cx, GlobalCreationCallback callback);
} // namespace JS
#endif // js_ShadowReamCallbacks_h

View File

@@ -80,12 +80,12 @@ class MOZ_STACK_CLASS JS_PUBLIC_API AutoStableStringChars final {
mozilla::Range<const Latin1Char> latin1Range() const {
MOZ_ASSERT(state_ == Latin1);
return mozilla::Range<const Latin1Char>(latin1Chars_, length());
return mozilla::Range<const Latin1Char>(latin1Chars_, GetStringLength(s_));
}
mozilla::Range<const char16_t> twoByteRange() const {
MOZ_ASSERT(state_ == TwoByte);
return mozilla::Range<const char16_t>(twoByteChars_, length());
return mozilla::Range<const char16_t>(twoByteChars_, GetStringLength(s_));
}
/* If we own the chars, transfer ownership to the caller. */
@@ -99,8 +99,6 @@ class MOZ_STACK_CLASS JS_PUBLIC_API AutoStableStringChars final {
return true;
}
size_t length() const { return GetStringLength(s_); }
private:
AutoStableStringChars(const AutoStableStringChars& other) = delete;
void operator=(const AutoStableStringChars& other) = delete;

View File

@@ -178,7 +178,6 @@ MSG_DEF(JSMSG_TOO_MANY_ARGUMENTS, 0, JSEXN_RANGEERR, "too many arguments pr
MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 0, JSEXN_EVALERR, "call to eval() blocked by CSP")
MSG_DEF(JSMSG_CSP_BLOCKED_FUNCTION, 0, JSEXN_EVALERR, "call to Function() blocked by CSP")
MSG_DEF(JSMSG_CSP_BLOCKED_WASM, 1, JSEXN_WASMCOMPILEERROR, "call to {0}() blocked by CSP")
MSG_DEF(JSMSG_CSP_BLOCKED_SHADOWREALM, 0, JSEXN_EVALERR, "call to ShadowRealm.prototype.evaluate blocked by CSP")
// Wrappers
MSG_DEF(JSMSG_ACCESSOR_DEF_DENIED, 1, JSEXN_ERR, "Permission denied to define accessor property {0}")
@@ -782,18 +781,4 @@ MSG_DEF(JSMSG_BAD_TUPLE_INDEX, 0, JSEXN_RANGEERR, "index out of range for
MSG_DEF(JSMSG_BAD_TUPLE_OBJECT, 0, JSEXN_TYPEERR, "value of TupleObject must be a Tuple")
MSG_DEF(JSMSG_RECORD_TUPLE_TO_NUMBER, 0, JSEXN_TYPEERR, "can't convert Record or Tuple to number")
// Shadow Realms
MSG_DEF(JSMSG_NOT_SHADOW_REALM, 0, JSEXN_TYPEERR, "Object is not a ShadowRealm")
MSG_DEF(JSMSG_SHADOW_REALM_EVALUATE_NOT_STRING, 0, JSEXN_TYPEERR, "a ShadowRealm can only evaluate a string")
MSG_DEF(JSMSG_SHADOW_REALM_INVALID_RETURN, 0, JSEXN_TYPEERR, "return value not primitive or callable")
MSG_DEF(JSMSG_SHADOW_REALM_WRAP_FAILURE, 0, JSEXN_TYPEERR, "unable to wrap callable return object")
MSG_DEF(JSMSG_SHADOW_REALM_EVALUATE_FAILURE, 0, JSEXN_TYPEERR, "evaluate failed")
MSG_DEF(JSMSG_SHADOW_REALM_WRAPPED_EXECUTION_FAILURE, 0, JSEXN_TYPEERR, "wrapped function threw")
MSG_DEF(JSMSG_SHADOW_REALM_GENERIC_SYNTAX, 0, JSEXN_SYNTAXERR, "Couldn't compile string")
MSG_DEF(JSMSG_SHADOW_REALM_EXPORT_NOT_STRING, 0, JSEXN_TYPEERR, "exportName must be a string")
MSG_DEF(JSMSG_SHADOW_REALM_IMPORTVALUE_FAILED, 0, JSEXN_TYPEERR, "import value failed")
MSG_DEF(JSMSG_SHADOW_REALM_VALUE_NOT_EXPORTED, 0, JSEXN_TYPEERR, "value not exported")
//clang-format on

View File

@@ -1,669 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "builtin/ShadowRealm.h"
#include "mozilla/Assertions.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "builtin/ModuleObject.h"
#include "builtin/Promise.h"
#include "builtin/WrappedFunctionObject.h"
#include "frontend/BytecodeCompilation.h"
#include "js/CompilationAndEvaluation.h"
#include "js/ErrorReport.h"
#include "js/Exception.h"
#include "js/GlobalObject.h"
#include "js/Principals.h"
#include "js/Promise.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/ShadowRealmCallbacks.h"
#include "js/SourceText.h"
#include "js/StableStringChars.h"
#include "js/TypeDecls.h"
#include "js/Wrapper.h"
#include "vm/GlobalObject.h"
#include "vm/ObjectOperations.h"
#include "builtin/HandlerFunction-inl.h"
#include "vm/JSObject-inl.h"
using namespace js;
using JS::AutoStableStringChars;
using JS::CompileOptions;
using JS::SourceOwnership;
using JS::SourceText;
static JSObject* DefaultNewShadowRealmGlobal(JSContext* cx,
JS::RealmOptions& options,
JSPrincipals* principals,
HandleObject unused) {
static const JSClass shadowRealmGlobal = {
"ShadowRealmGlobal", JSCLASS_GLOBAL_FLAGS, &JS::DefaultGlobalClassOps};
return JS_NewGlobalObject(cx, &shadowRealmGlobal, principals,
JS::FireOnNewGlobalHook, options);
}
// https://tc39.es/proposal-shadowrealm/#sec-shadowrealm-constructor
/*static*/
bool ShadowRealmObject::construct(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);
// Step 1. If NewTarget is undefined, throw a TypeError exception.
if (!args.isConstructing()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_NOT_CONSTRUCTOR, "ShadowRealm");
return false;
}
// Step 2. Let O be ? OrdinaryCreateFromConstructor(NewTarget,
// "%ShadowRealm.prototype%", « [[ShadowRealm]], [[ExecutionContext]] »).
RootedObject proto(cx);
if (!GetPrototypeFromBuiltinConstructor(cx, args, JSProto_ShadowRealm,
&proto)) {
return false;
}
Rooted<ShadowRealmObject*> shadowRealmObj(
cx, NewObjectWithClassProto<ShadowRealmObject>(cx, proto));
if (!shadowRealmObj) {
return false;
}
// Instead of managing Realms, spidermonkey associates a realm with a global
// object, and so we will manage and store a global.
// Step 3. Let realmRec be CreateRealm().
// Initially steal creation options from current realm:
JS::RealmOptions options(cx->realm()->creationOptions(),
cx->realm()->behaviors());
// We don't want to have to deal with CCWs in addition to
// WrappedFunctionObjects.
options.creationOptions().setExistingCompartment(cx->compartment());
JS::GlobalCreationCallback newGlobal =
cx->runtime()->getShadowRealmGlobalCreationCallback();
// If an embedding didn't provide a callback to initialize the global,
// use the basic default one.
if (!newGlobal) {
newGlobal = DefaultNewShadowRealmGlobal;
}
// Our shadow realm inherits the principals of the current realm,
// but is otherwise constrained.
JSPrincipals* principals = JS::GetRealmPrincipals(cx->realm());
// Steps 5-11: In SpiderMonkey these fall under the aegis of the global
// creation. It's worth noting that the newGlobal callback
// needs to respect the SetRealmGlobalObject call below, which
// sets the global to
// OrdinaryObjectCreate(intrinsics.[[%Object.prototype%]]).
//
// Step 5. Let context be a new execution context.
// Step 6. Set the Function of context to null.
// Step 7. Set the Realm of context to realmRec.
// Step 8. Set the ScriptOrModule of context to null.
// Step 9. Set O.[[ExecutionContext]] to context.
// Step 10. Perform ? SetRealmGlobalObject(realmRec, undefined, undefined).
// Step 11. Perform ? SetDefaultGlobalBindings(O.[[ShadowRealm]]).
RootedObject global(cx, newGlobal(cx, options, principals, cx->global()));
if (!global) {
return false;
}
// Make sure the new global hook obeyed our request in the
// creation options to have a same compartment global.
MOZ_RELEASE_ASSERT(global->compartment() == cx->compartment());
// Step 4. Set O.[[ShadowRealm]] to realmRec.
shadowRealmObj->initFixedSlot(GlobalSlot, ObjectValue(*global));
// Step 12. Perform ? HostInitializeShadowRealm(O.[[ShadowRealm]]).
JS::GlobalInitializeCallback hostInitializeShadowRealm =
cx->runtime()->getShadowRealmInitializeGlobalCallback();
if (hostInitializeShadowRealm) {
if (!hostInitializeShadowRealm(cx, global)) {
return false;
}
}
// Step 13. Return O.
args.rval().setObject(*shadowRealmObj);
return true;
}
// https://tc39.es/proposal-shadowrealm/#sec-validateshadowrealmobject
// (slightly modified into a cast operator too)
static ShadowRealmObject* ValidateShadowRealmObject(JSContext* cx,
HandleObject O) {
// Step 1. Perform ? RequireInternalSlot(O, [[ShadowRealm]]).
// Step 2. Perform ? RequireInternalSlot(O, [[ExecutionContext]]).
RootedObject maybeUnwrappedO(cx, O);
if (IsCrossCompartmentWrapper(O)) {
maybeUnwrappedO = CheckedUnwrapDynamic(O, cx);
// Unwrapping failed; security wrapper denied.
if (!maybeUnwrappedO) {
return nullptr;
}
}
if (!maybeUnwrappedO->is<ShadowRealmObject>()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_NOT_SHADOW_REALM);
return nullptr;
}
return &maybeUnwrappedO->as<ShadowRealmObject>();
}
// PerformShadowRealmEval ( sourceText: a String, callerRealm: a Realm Record,
// evalRealm: a Realm Record, )
//
// https://tc39.es/proposal-shadowrealm/#sec-performshadowrealmeval
static bool PerformShadowRealmEval(JSContext* cx, HandleString sourceText,
Realm* callerRealm, Realm* evalRealm,
MutableHandleValue rval) {
MOZ_ASSERT(callerRealm != evalRealm);
// Step 1. Perform ? HostEnsureCanCompileStrings(callerRealm, evalRealm).
if (!cx->isRuntimeCodeGenEnabled(JS::RuntimeCode::JS, sourceText)) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_CSP_BLOCKED_SHADOWREALM);
return false;
}
// Need to compile the script into the realm we will execute into.
//
// We hoist the error handling out however to ensure that errors
// are thrown from the correct realm.
bool compileSuccess = false;
bool evalSuccess = false;
do {
Rooted<GlobalObject*> evalRealmGlobal(cx, evalRealm->maybeGlobal());
AutoRealm ar(cx, evalRealmGlobal);
// Step 2. Perform the following substeps in an implementation-defined
// order, possibly interleaving parsing and error detection:
// a. Let script be ParseText(! StringToCodePoints(sourceText), Script).
// b. If script is a List of errors, throw a SyntaxError exception.
// c. If script Contains ScriptBody is false, return undefined.
// d. Let body be the ScriptBody of script.
// e. If body Contains NewTarget is true, throw a SyntaxError exception.
// f. If body Contains SuperProperty is true, throw a SyntaxError
// exception. g. If body Contains SuperCall is true, throw a SyntaxError
// exception.
AutoStableStringChars linearChars(cx);
if (!linearChars.initTwoByte(cx, sourceText)) {
return false;
}
SourceText<char16_t> srcBuf;
const char16_t* chars = linearChars.twoByteRange().begin().get();
SourceOwnership ownership = linearChars.maybeGiveOwnershipToCaller()
? SourceOwnership::TakeOwnership
: SourceOwnership::Borrowed;
if (!srcBuf.init(cx, chars, linearChars.length(), ownership)) {
return false;
}
// Lets propagate some information into the compilation here.
//
// We may need to censor the stacks eventually, see
// https://bugzilla.mozilla.org/show_bug.cgi?id=1770017
RootedScript callerScript(cx);
const char* filename;
unsigned lineno;
uint32_t pcOffset;
bool mutedErrors;
DescribeScriptedCallerForCompilation(cx, &callerScript, &filename, &lineno,
&pcOffset, &mutedErrors);
CompileOptions options(cx);
options.setIsRunOnce(true)
.setNoScriptRval(false)
.setMutedErrors(mutedErrors)
.setFileAndLine(filename, lineno);
Rooted<Scope*> enclosing(cx, &evalRealmGlobal->emptyGlobalScope());
RootedScript script(
cx, frontend::CompileEvalScript(cx, options, srcBuf, enclosing,
evalRealmGlobal));
compileSuccess = !!script;
if (!compileSuccess) {
break;
}
// Step 3. Let strictEval be IsStrict of script.
// Step 4. Let runningContext be the running execution context.
// Step 5. Let lexEnv be NewDeclarativeEnvironment(evalRealm.[[GlobalEnv]]).
// Step 6. Let varEnv be evalRealm.[[GlobalEnv]].
// Step 7. If strictEval is true, set varEnv to lexEnv.
// Step 8. If runningContext is not already suspended, suspend
// runningContext. Step 9. Let evalContext be a new ECMAScript code
// execution context. Step 10. Set evalContext's Function to null. Step 11.
// Set evalContext's Realm to evalRealm. Step 12. Set evalContext's
// ScriptOrModule to null. Step 13. Set evalContext's VariableEnvironment to
// varEnv. Step 14. Set evalContext's LexicalEnvironment to lexEnv. Step 15.
// Push evalContext onto the execution context stack; evalContext is
// now the running execution context.
// Step 16. Let result be EvalDeclarationInstantiation(body, varEnv,
// lexEnv, null, strictEval).
// Step 17. If result.[[Type]] is normal, then
// a. Set result to the result of evaluating body.
// Step 18. If result.[[Type]] is normal and result.[[Value]] is empty, then
// a. Set result to NormalCompletion(undefined).
// Step 19. Suspend evalContext and remove it from the execution context
// stack.
// Step 20. Resume the context that is now on the top of the execution
// context stack as the running execution context.
RootedObject environment(cx, &evalRealmGlobal->lexicalEnvironment());
evalSuccess = ExecuteKernel(cx, script, environment,
/* evalInFrame = */ NullFramePtr(), rval);
} while (false); // AutoRealm
if (!compileSuccess) {
// MG:XXX: figure out how to extract the syntax error information for
// re-throw here (See DebuggerObject::getErrorColumnNumber ?)
//
// https://bugzilla.mozilla.org/show_bug.cgi?id=1769848
// The SyntaxError here needs to come from the calling global, so has to
// happen outside the AutoRealm above.
JS_ClearPendingException(cx);
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_GENERIC_SYNTAX);
return false;
}
if (!evalSuccess) {
// Step 21. If result.[[Type]] is not normal, throw a TypeError
// exception.
//
// The type error here needs to come from the calling global, so has to
// happen outside the AutoRealm above.
// MG:XXX: Figure out how to extract the error message and include in
// message of TypeError (if possible): See discussion in
// https://github.com/tc39/proposal-shadowrealm/issues/353 for some
// potential pitfalls (i.e. what if the error has a getter on the message
// property?)
//
// I imagine we could do something like GetPropertyPure, and have a nice
// error message if we *don't* have anything to worry about.
//
// https://bugzilla.mozilla.org/show_bug.cgi?id=1769849
JS_ClearPendingException(cx);
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_EVALUATE_FAILURE);
return false;
}
// Step 22. Return ? GetWrappedValue(callerRealm, result.[[Value]]).
return GetWrappedValue(cx, callerRealm, rval, rval);
}
// ShadowRealm.prototype.evaluate ( sourceText )
// https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.evaluate
static bool ShadowRealm_evaluate(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);
// Step 1. Let O be this value (implicit ToObject)
RootedObject obj(cx, ToObject(cx, args.thisv()));
if (!obj) {
return false;
}
// Step 2. Perform ? ValidateShadowRealmObject(O)
Rooted<ShadowRealmObject*> shadowRealm(cx,
ValidateShadowRealmObject(cx, obj));
if (!shadowRealm) {
return false;
}
// Step 3. If Type(sourceText) is not String, throw a TypeError exception.
if (!args.get(0).isString()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_EVALUATE_NOT_STRING);
return false;
}
RootedString sourceText(cx, args.get(0).toString());
// Step 4. Let callerRealm be the current Realm Record.
Realm* callerRealm = cx->realm();
// Step 5. Let evalRealm be O.[[ShadowRealm]].
Realm* evalRealm = shadowRealm->getShadowRealm();
// Step 6. Return ? PerformShadowRealmEval(sourceText, callerRealm,
// evalRealm).
return PerformShadowRealmEval(cx, sourceText, callerRealm, evalRealm,
args.rval());
}
// MG:XXX: Cribbed/Overlapping with StartDynamicModuleImport; may need to
// refactor to share.
// https://tc39.es/proposal-shadowrealm/#sec-shadowrealmimportvalue
static JSObject* ShadowRealmImportValue(JSContext* cx,
HandleString specifierString,
HandleString exportName,
Realm* callerRealm, Realm* evalRealm) {
// Step 1. Assert: evalContext is an execution context associated to a
// ShadowRealm instance's [[ExecutionContext]].
// Step 2. Let innerCapability be ! NewPromiseCapability(%Promise%).
RootedObject promiseConstructor(cx, JS::GetPromiseConstructor(cx));
if (!promiseConstructor) {
return nullptr;
}
RootedObject promiseObject(cx, JS::NewPromiseObject(cx, nullptr));
if (!promiseObject) {
return nullptr;
}
Handle<PromiseObject*> promise = promiseObject.as<PromiseObject>();
JS::ModuleDynamicImportHook importHook =
cx->runtime()->moduleDynamicImportHook;
if (!importHook) {
// Dynamic import can be disabled by a pref and is not supported in all
// contexts (e.g. web workers).
JS_ReportErrorASCII(
cx,
"Dynamic module import is disabled or not supported in this context");
if (!RejectPromiseWithPendingError(cx, promise)) {
return nullptr;
}
return promise;
}
{
// Step 3. Let runningContext be the running execution context. (Implicit)
// Step 4. If runningContext is not already suspended, suspend
// runningContext. (Implicit)
// Step 5. Push evalContext onto the execution context stack; evalContext is
// now the running execution context. (Implicit)
Rooted<GlobalObject*> evalRealmGlobal(cx, evalRealm->maybeGlobal());
AutoRealm ar(cx, evalRealmGlobal);
// Not Speced: Get referencing private to pass to importHook.
RootedScript script(cx);
const char* filename;
unsigned lineno;
uint32_t pcOffset;
bool mutedErrors;
DescribeScriptedCallerForCompilation(cx, &script, &filename, &lineno,
&pcOffset, &mutedErrors);
MOZ_ASSERT(script);
RootedValue referencingPrivate(cx, script->sourceObject()->getPrivate());
cx->runtime()->addRefScriptPrivate(referencingPrivate);
Rooted<JSAtom*> specifierAtom(cx, AtomizeString(cx, specifierString));
if (!specifierAtom) {
if (!RejectPromiseWithPendingError(cx, promise)) {
return nullptr;
}
return promise;
}
Rooted<ArrayObject*> assertionArray(cx);
RootedObject moduleRequest(
cx, ModuleRequestObject::create(cx, specifierAtom, assertionArray));
if (!moduleRequest) {
if (!RejectPromiseWithPendingError(cx, promise)) {
return nullptr;
}
return promise;
}
// Step 6. Perform ! HostImportModuleDynamically(null, specifierString,
// innerCapability).
//
// By specification, this is supposed to take ReferencingScriptOrModule as
// null, see first parameter above. However, if we do that, we don't end up
// with a script reference, which is used to figure out what the base-URI
// should be So then we end up using the default one for the module loader;
// which because of the way we set the parent module loader up, means we end
// up having the incorrect base URI, as the module loader ends up just using
// the document's base URI.
//
// I have filed https://github.com/tc39/proposal-shadowrealm/issues/363 to
// discuss this.
if (!importHook(cx, referencingPrivate, moduleRequest, promise)) {
cx->runtime()->releaseScriptPrivate(referencingPrivate);
// If there's no exception pending then the script is terminating
// anyway, so just return nullptr.
if (!cx->isExceptionPending() ||
!RejectPromiseWithPendingError(cx, promise)) {
return nullptr;
}
return promise;
}
// Step 7. Suspend evalContext and remove it from the execution context
// stack. (Implicit)
// Step 8. Resume the context that is now on the top of the execution
// context stack as the running execution context (Implicit)
}
// Step 9. Let steps be the steps of an ExportGetter function as described
// below.
// Step 10. Let onFulfilled be ! CreateBuiltinFunction(steps, 1, "", «
// [[ExportNameString]] », callerRealm).
// The handler can only hold onto a single object, so we pack that into a new
// JS Object, and store there.
RootedObject handlerObject(cx, JS_NewPlainObject(cx));
if (!handlerObject) {
return nullptr;
}
RootedValue calleeRealmValue(cx, PrivateValue(callerRealm));
if (!JS_DefineProperty(cx, handlerObject, "calleeRealm", calleeRealmValue,
JSPROP_READONLY)) {
return nullptr;
}
if (!JS_DefineProperty(cx, handlerObject, "exportNameString", exportName,
JSPROP_READONLY)) {
return nullptr;
}
RootedValue handlerValue(cx, ObjectValue(*handlerObject));
RootedFunction onFulfilled(
cx,
NewHandlerWithExtraValue(
cx,
[](JSContext* cx, unsigned argc, Value* vp) {
// This is the export getter function from
// https://tc39.es/proposal-shadowrealm/#sec-shadowrealmimportvalue
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 1);
RootedObject handlerObject(cx,
&ExtraValueFromHandler(args).toObject());
RootedValue realmValue(cx);
RootedValue exportNameValue(cx);
MOZ_ALWAYS_TRUE(
JS_GetProperty(cx, handlerObject, "calleeRealm", &realmValue));
MOZ_ALWAYS_TRUE(JS_GetProperty(
cx, handlerObject, "exportNameString", &exportNameValue));
// Step 1. Assert: exports is a module namespace exotic object.
RootedValue exportsValue(cx, args.get(0));
MOZ_ASSERT(exportsValue.isObject() &&
exportsValue.toObject().is<ModuleNamespaceObject>());
Rooted<ModuleNamespaceObject*> exports(
cx, &exportsValue.toObject().as<ModuleNamespaceObject>());
// Step 2. Let f be the active function object. (not implemented
// this way)
//
// Step 3. Let string be f.[[ExportNameString]]. Step 4.
// Assert: Type(string) is String.
MOZ_ASSERT(exportNameValue.isString());
RootedString string(cx, exportNameValue.toString());
RootedId stringId(cx);
if (!JS_StringToId(cx, string, &stringId)) {
return false;
}
// Step 5. Let hasOwn be ? HasOwnProperty(exports, string).
bool hasOwn = false;
if (!HasOwnProperty(cx, exports, stringId, &hasOwn)) {
return false;
}
// Step 6. If hasOwn is false, throw a TypeError exception.
if (!hasOwn) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_VALUE_NOT_EXPORTED);
return false;
}
// Step 7. Let value be ? Get(exports, string).
RootedValue value(cx);
if (!JS_GetPropertyById(cx, exports, stringId, &value)) {
return false;
}
// Step 8. Let realm be f.[[Realm]].
Realm* callerRealm = static_cast<Realm*>(realmValue.toPrivate());
// Step 9. Return ? GetWrappedValue(realm, value).
return GetWrappedValue(cx, callerRealm, value, args.rval());
},
promise, handlerValue));
if (!onFulfilled) {
return nullptr;
}
RootedFunction onRejected(cx,
NewHandler(
cx,
[](JSContext* cx, unsigned argc, Value* vp) {
JS_ReportErrorNumberASCII(
cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_IMPORTVALUE_FAILED);
return false;
},
promise));
if (!onFulfilled) {
return nullptr;
}
// Step 11. Set onFulfilled.[[ExportNameString]] to exportNameString.
// Step 12. Let promiseCapability be ! NewPromiseCapability(%Promise%).
// Step 13. Return ! PerformPromiseThen(innerCapability.[[Promise]],
// onFulfilled, callerRealm.[[Intrinsics]].[[%ThrowTypeError%]],
// promiseCapability).
return JS::CallOriginalPromiseThen(cx, promise, onFulfilled, onRejected);
}
// ShadowRealm.prototype.importValue ( specifier, exportName )
// https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.importvalue
static bool ShadowRealm_importValue(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);
// Step 1. Let O be this value (implicit ToObject)
RootedObject obj(cx, ToObject(cx, args.thisv()));
if (!obj) {
return false;
}
// Step 2. Perform ? ValidateShadowRealmObject(O).
Rooted<ShadowRealmObject*> shadowRealm(cx,
ValidateShadowRealmObject(cx, obj));
if (!shadowRealm) {
return false;
}
// Step 3. Let specifierString be ? ToString(specifier).
RootedString specifierString(cx, ToString<CanGC>(cx, args.get(0)));
if (!specifierString) {
return false;
}
// Step 4. If Type(exportName) is not String, throw a TypeError exception.
if (!args.get(1).isString()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_EXPORT_NOT_STRING);
return false;
}
RootedString exportName(cx, args.get(1).toString());
if (!exportName) {
return false;
}
// Step 5. Let callerRealm be the current Realm Record.
Realm* callerRealm = cx->realm();
// Step 6. Let evalRealm be O.[[ShadowRealm]].
Realm* evalRealm = shadowRealm->getShadowRealm();
// Step 7. Let evalContext be O.[[ExecutionContext]]
// (we dont' pass this explicitly, instead using the realm+global to
// represent)
// Step 8. Return ?
// ShadowRealmImportValue(specifierString, exportName,
// callerRealm, evalRealm,
// evalContext).
RootedObject res(cx, ShadowRealmImportValue(cx, specifierString, exportName,
callerRealm, evalRealm));
if (!res) {
return false;
}
args.rval().set(ObjectValue(*res));
return true;
}
static const JSFunctionSpec shadowrealm_methods[] = {
JS_FN("evaluate", ShadowRealm_evaluate, 1, 0),
JS_FN("importValue", ShadowRealm_importValue, 2, 0), JS_FS_END};
static const JSPropertySpec shadowrealm_properties[] = {
JS_STRING_SYM_PS(toStringTag, "ShadowRealm", JSPROP_READONLY), JS_PS_END};
static const ClassSpec ShadowRealmObjectClassSpec = {
GenericCreateConstructor<ShadowRealmObject::construct, 0,
gc::AllocKind::FUNCTION>,
GenericCreatePrototype<ShadowRealmObject>,
nullptr, // Static methods
nullptr, // Static properties
shadowrealm_methods, // Methods
shadowrealm_properties // Properties
};
const JSClass ShadowRealmObject::class_ = {
"ShadowRealm",
JSCLASS_HAS_CACHED_PROTO(JSProto_ShadowRealm) |
JSCLASS_HAS_RESERVED_SLOTS(ShadowRealmObject::SlotCount),
JS_NULL_CLASS_OPS, &ShadowRealmObjectClassSpec};
const JSClass ShadowRealmObject::protoClass_ = {
"ShadowRealm.prototype", JSCLASS_HAS_CACHED_PROTO(JSProto_ShadowRealm),
JS_NULL_CLASS_OPS, &ShadowRealmObjectClassSpec};

View File

@@ -1,37 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef builtin_ShadowRealm_h
#define builtin_ShadowRealm_h
#include "js/Wrapper.h"
#include "vm/GlobalObject.h"
#include "vm/NativeObject.h"
namespace js {
class ShadowRealmObject : public NativeObject {
public:
static const JSClass class_;
static const JSClass protoClass_;
enum { GlobalSlot, SlotCount };
static bool construct(JSContext* cx, unsigned argc, Value* vp);
Realm* getShadowRealm() {
MOZ_ASSERT(getWrappedGlobal());
return getWrappedGlobal()->nonCCWRealm();
}
JSObject* getWrappedGlobal() const {
return &getFixedSlot(GlobalSlot).toObject();
}
};
} // namespace js
#endif

View File

@@ -1,298 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "builtin/WrappedFunctionObject.h"
#include "jsapi.h"
#include "js/CallAndConstruct.h"
#include "js/Class.h"
#include "js/ErrorReport.h"
#include "js/Exception.h"
#include "js/friend/DumpFunctions.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "js/Wrapper.h"
#include "vm/JSFunction.h"
#include "vm/ObjectOperations.h"
#include "vm/JSObject-inl.h"
using namespace js;
using namespace JS;
// GetWrappedValue ( callerRealm: a Realm Record, value: unknown )
bool js::GetWrappedValue(JSContext* cx, Realm* callerRealm, HandleValue value,
MutableHandleValue res) {
// Step 2. Return value (Reordered)
if (!value.isObject()) {
res.set(value);
return true;
}
// Step 1. If Type(value) is Object, then
// a. If IsCallable(value) is false, throw a TypeError exception.
RootedObject objectVal(cx, &value.toObject());
if (!IsCallable(objectVal)) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_INVALID_RETURN);
return false;
}
// b. Return ? WrappedFunctionCreate(callerRealm, value).
return WrappedFunctionCreate(cx, callerRealm, objectVal, res);
}
// [[Call]]
// https://tc39.es/proposal-shadowrealm/#sec-wrapped-function-exotic-objects-call-thisargument-argumentslist
static bool WrappedFunction_Call(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject callee(cx, &args.callee());
MOZ_ASSERT(callee->is<WrappedFunctionObject>());
Handle<WrappedFunctionObject*> F = callee.as<WrappedFunctionObject>();
// 1. Let target be F.[[WrappedTargetFunction]].
RootedObject target(cx, F->getTargetFunction());
// 2. Assert: IsCallable(target) is true.
MOZ_ASSERT(IsCallable(ObjectValue(*target)));
// 3. Let targetRealm be ? GetFunctionRealm(target).
Rooted<Realm*> targetRealm(cx, GetFunctionRealm(cx, target));
if (!targetRealm) {
return false;
}
// 4. Let callerRealm be ? GetFunctionRealm(F).
Rooted<Realm*> callerRealm(cx, GetFunctionRealm(cx, F));
if (!callerRealm) {
return false;
}
// 5. NOTE: Any exception objects produced after this point are associated
// with callerRealm.
RootedValue result(cx);
{
RootedObject global(cx, JS::GetRealmGlobalOrNull(callerRealm));
MOZ_RELEASE_ASSERT(
global, "global is null; executing in a realm that's being GC'd?");
AutoRealm ar(cx, global);
// https://searchfox.org/mozilla-central/source/js/public/CallAndConstruct.h#57-73
// 6. Let wrappedArgs be a new empty List.
RootedValueVector wrappedArgs(cx);
// 7. For each element arg of argumentsList, do
// a. Let wrappedValue be ? GetWrappedValue(targetRealm, arg).
// b. Append wrappedValue to wrappedArgs.
RootedValue element(cx);
for (size_t i = 0; i < args.length(); i++) {
element = args.get(i);
if (!GetWrappedValue(cx, targetRealm, element, &element)) {
return false;
}
if (!wrappedArgs.append(element)) {
return false;
}
}
// 8. Let wrappedThisArgument to ? GetWrappedValue(targetRealm,
// thisArgument).
RootedValue wrappedThisArgument(cx);
if (!GetWrappedValue(cx, targetRealm, args.thisv(), &wrappedThisArgument)) {
return false;
}
// 9. Let result be the Completion Record of Call(target,
// wrappedThisArgument, wrappedArgs).
if (!JS::Call(cx, wrappedThisArgument, target, wrappedArgs, &result)) {
// 11. Else (reordered);
// a. Throw a TypeError exception.
JS_ClearPendingException(cx);
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_WRAPPED_EXECUTION_FAILURE);
return false;
}
// 10. If result.[[Type]] is normal or result.[[Type]] is return, then
// a. Return ? GetWrappedValue(callerRealm, result.[[Value]]).
if (!GetWrappedValue(cx, callerRealm, result, args.rval())) {
return false;
}
}
return true;
}
static bool CopyNameAndLength(JSContext* cx, HandleObject F,
HandleObject Target, char* prefix = nullptr,
unsigned argCount = 0) {
// 1. If argCount is undefined, then set argCount to 0 (implicit)
// 2. Let L be 0.
double L = 0;
// 3. Let targetHasLength be ? HasOwnProperty(Target, "length").
RootedId length(cx, NameToId(cx->names().length));
RootedId name(cx, NameToId(cx->names().name));
// Try to avoid invoking the resolve hook.
if (Target->is<JSFunction>() &&
!Target->as<JSFunction>().hasResolvedLength()) {
RootedValue targetLen(cx);
if (!JSFunction::getUnresolvedLength(cx, Target.as<JSFunction>(),
&targetLen)) {
return false;
}
L = std::max(0.0, targetLen.toNumber() - argCount);
} else {
bool targetHasLength;
if (!HasOwnProperty(cx, Target, length, &targetHasLength)) {
return false;
}
// https://searchfox.org/mozilla-central/source/js/src/vm/JSFunction.cpp#1298
// 4. If targetHasLength is true, then
if (targetHasLength) {
// a. Let targetLen be ? Get(Target, "length").
RootedValue targetLen(cx);
if (!GetProperty(cx, Target, Target, length, &targetLen)) {
return false;
}
// b. If Type(targetLen) is Number, then
// i. If targetLen is +∞𝔽, set L to +∞.
// ii. Else if targetLen is -∞𝔽, set L to 0.
// iii. Else,
// 1. Let targetLenAsInt be ! ToIntegerOrInfinity(targetLen).
// 2. Assert: targetLenAsInt is finite.
// 3. Set L to max(targetLenAsInt - argCount, 0).
if (targetLen.isNumber()) {
L = std::max(0.0, JS::ToInteger(targetLen.toNumber()) - argCount);
}
}
}
// 5. Perform ! SetFunctionLength(F, L).
RootedValue rootedL(cx, DoubleValue(L));
if (!JS_DefinePropertyById(cx, F, length, rootedL, JSPROP_READONLY)) {
return false;
}
// 6. Let targetName be ? Get(Target, "name").
RootedValue targetName(cx);
if (!GetProperty(cx, Target, Target, cx->names().name, &targetName)) {
return false;
}
// 7. If Type(targetName) is not String, set targetName to the empty String.
if (!targetName.isString()) {
targetName = StringValue(cx->runtime()->emptyString);
}
RootedString targetString(cx, targetName.toString());
RootedId targetNameId(cx);
if (!JS_StringToId(cx, targetString, &targetNameId)) {
return false;
}
// 8. Perform ! SetFunctionName(F, targetName, prefix).
// (inlined and specialized from js::SetFunctionName)
Rooted<JSAtom*> funName(cx, IdToFunctionName(cx, targetNameId));
if (!funName) {
return false;
}
RootedValue rootedFunName(cx, StringValue(funName));
return JS_DefinePropertyById(cx, F, name, rootedFunName, JSPROP_READONLY);
}
static const JSClassOps classOps = {
nullptr, // addProperty
nullptr, // delProperty
nullptr, // enumerate
nullptr, // newEnumerate
nullptr, // resolve
nullptr, // mayResolve
nullptr, // finalize
WrappedFunction_Call, // call
nullptr, // construct
nullptr, // trace
};
const JSClass WrappedFunctionObject::class_ = {
"WrappedFunctionObject",
JSCLASS_HAS_CACHED_PROTO(
JSProto_Function) | // MG:XXX: Is this going to correctly set the
// prototype for me?
JSCLASS_HAS_RESERVED_SLOTS(WrappedFunctionObject::SlotCount),
&classOps};
JSObject* GetRealmFunctionPrototype(JSContext* cx, Realm* realm) {
CHECK_THREAD(cx);
Rooted<GlobalObject*> global(cx, realm->maybeGlobal());
MOZ_RELEASE_ASSERT(global);
return GlobalObject::getOrCreateFunctionPrototype(cx, global);
}
// WrappedFunctionCreate ( callerRealm: a Realm Record, Target: a function
// object)
bool js::WrappedFunctionCreate(JSContext* cx, Realm* callerRealm,
HandleObject target, MutableHandleValue res) {
// Ensure that the function object has the correct realm by allocating it
// into that realm.
RootedObject global(cx, JS::GetRealmGlobalOrNull(callerRealm));
MOZ_RELEASE_ASSERT(global,
"global is null; executing in a realm that's being GC'd?");
AutoRealm ar(cx, global);
MOZ_ASSERT(target);
// Target *could* be a function from another realm
RootedObject maybeWrappedTarget(cx, target);
if (!JS_WrapObject(cx, &maybeWrappedTarget)) {
return false;
}
// 1. Let internalSlotsList be the internal slots listed in Table 2, plus
// [[Prototype]] and [[Extensible]].
// 2. Let wrapped be ! MakeBasicObject(internalSlotsList).
// 3. Set wrapped.[[Prototype]] to
// callerRealm.[[Intrinsics]].[[%Function.prototype%]].
RootedObject functionPrototype(cx,
GetRealmFunctionPrototype(cx, callerRealm));
MOZ_ASSERT(cx->compartment() == functionPrototype->compartment());
Rooted<WrappedFunctionObject*> wrapped(
cx,
NewObjectWithGivenProto<WrappedFunctionObject>(cx, functionPrototype));
if (!wrapped) {
return false;
}
// 4. Set wrapped.[[Call]] as described in 2.1 (implicit in JSClass call
// hook)
// 5. Set wrapped.[[WrappedTargetFunction]] to Target.
wrapped->setTargetFunction(*maybeWrappedTarget);
// 6. Set wrapped.[[Realm]] to callerRealm. (implicitly the realm of
// wrapped, which we assured with the AutoRealm
MOZ_ASSERT(wrapped->realm() == callerRealm);
// 7. Let result be CopyNameAndLength(wrapped, Target).
if (!CopyNameAndLength(cx, wrapped, maybeWrappedTarget)) {
// 8. If result is an Abrupt Completion, throw a TypeError exception.
JS_ClearPendingException(cx);
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_SHADOW_REALM_WRAP_FAILURE);
return false;
}
// 9. Return wrapped.
res.set(ObjectValue(*wrapped));
return true;
}

View File

@@ -1,43 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef builtin_WrappedFunctionObject_h
#define builtin_WrappedFunctionObject_h
#include "js/Value.h"
#include "vm/NativeObject.h"
namespace js {
// Implementing Wrapped Function Exotic Objects from the ShadowRealms proposal
// https://tc39.es/proposal-shadowrealm/#sec-wrapped-function-exotic-objects
//
// These are produced as callables are passed across ShadowRealm boundaries,
// preventing functions from piercing the shadow realm barrier.
class WrappedFunctionObject : public NativeObject {
public:
static const JSClass class_;
enum { WrappedTargetFunctionSlot, SlotCount };
JSObject* getTargetFunction() const {
return &getFixedSlot(WrappedTargetFunctionSlot).toObject();
}
void setTargetFunction(JSObject& obj) {
setFixedSlot(WrappedTargetFunctionSlot, ObjectValue(obj));
}
};
bool WrappedFunctionCreate(JSContext* cx, Realm* callerRealm,
HandleObject target, MutableHandleValue res);
bool GetWrappedValue(JSContext* cx, Realm* callerRealm, HandleValue value,
MutableHandleValue res);
} // namespace js
#endif

View File

@@ -4557,16 +4557,6 @@ JS_PUBLIC_API void JS::SetOutOfMemoryCallback(JSContext* cx,
cx->runtime()->oomCallbackData = data;
}
JS_PUBLIC_API void JS::SetShadowRealmInitializeGlobalCallback(
JSContext* cx, JS::GlobalInitializeCallback callback) {
cx->runtime()->shadowRealmInitializeGlobalCallback = callback;
}
JS_PUBLIC_API void JS::SetShadowRealmGlobalCreationCallback(
JSContext* cx, JS::GlobalCreationCallback callback) {
cx->runtime()->shadowRealmGlobalCreationCallback = callback;
}
JS::FirstSubsumedFrame::FirstSubsumedFrame(
JSContext* cx, bool ignoreSelfHostedFrames /* = true */)
: JS::FirstSubsumedFrame(cx, cx->realm()->principals(),

View File

@@ -196,7 +196,6 @@ EXPORTS.js += [
"../public/SavedFrameAPI.h",
"../public/ScalarType.h",
"../public/ScriptPrivate.h",
"../public/ShadowRealmCallbacks.h",
"../public/SharedArrayBuffer.h",
"../public/SliceBudget.h",
"../public/SourceText.h",
@@ -315,7 +314,6 @@ UNIFIED_SOURCES += [
"builtin/Promise.cpp",
"builtin/Reflect.cpp",
"builtin/ReflectParse.cpp",
"builtin/ShadowRealm.cpp",
"builtin/String.cpp",
"builtin/Symbol.cpp",
"builtin/TestingFunctions.cpp",
@@ -323,7 +321,6 @@ UNIFIED_SOURCES += [
"builtin/WeakMapObject.cpp",
"builtin/WeakRefObject.cpp",
"builtin/WeakSetObject.cpp",
"builtin/WrappedFunctionObject.cpp",
"ds/Bitmap.cpp",
"ds/LifoAlloc.cpp",
"jsapi.cpp",

View File

@@ -140,7 +140,6 @@
#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"
@@ -627,7 +626,6 @@ 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
@@ -4248,7 +4246,6 @@ static void SetStandardRealmOptions(JS::RealmOptions& options) {
.setToSourceEnabled(enableToSource)
.setPropertyErrorMessageFixEnabled(enablePropertyErrorMessageFix)
.setIteratorHelpersEnabled(enableIteratorHelpers)
.setShadowRealmsEnabled(enableShadowRealms)
#ifdef NIGHTLY_BUILD
.setArrayGroupingEnabled(enableArrayGrouping)
#endif
@@ -11042,7 +11039,6 @@ 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
@@ -12078,7 +12074,6 @@ 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",
@@ -12641,7 +12636,6 @@ 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;
}

View File

@@ -134,7 +134,6 @@ extern bool enableWeakRefs;
extern bool enableToSource;
extern bool enablePropertyErrorMessageFix;
extern bool enableIteratorHelpers;
extern bool enableShadowRealms;
extern bool enableArrayGrouping;
extern bool enablePrivateClassFields;
extern bool enablePrivateClassMethods;

View File

@@ -1,33 +0,0 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell)
var g = newGlobal({ newCompartment: true });
var sr = g.evaluate(`new ShadowRealm()`);
// sr should be a CCW to a ShadowRealm.
ShadowRealm.prototype.evaluate.call(sr, "var x = 10");
assertEq(sr.evaluate("x"), 10);
// wrappedf should *not* be a CCW, because we're using this realm's ShadowRealm.prototype.evaluate,
// and so the active realm when invoking will be this current realm.
//
// However, the target function (wrappedf's f) comes from another compartment, and will have to be a CCW.
var wrappedf = ShadowRealm.prototype.evaluate.call(sr, "function f() { return 10; }; f");
assertEq(wrappedf(), 10);
var evaluate_from_other_realm = g.evaluate('ShadowRealm.prototype.evaluate');
// wrappedb should be a CCW, since the callee of the .call comes from the other
// compartment.
var wrappedb = evaluate_from_other_realm.call(sr, "function b() { return 12; }; b");
assertEq(wrappedb(), 12);
nukeAllCCWs()
// This throws, but the dead object message is lost and replaced with the wrapped function
// object message.
assertThrowsInstanceOf(() => wrappedf(), TypeError);
assertThrowsInstanceOf(() => wrappedb(), TypeError);
if (typeof reportCompare === 'function')
reportCompare(true, true);

View File

@@ -31,6 +31,7 @@ UNSUPPORTED_FEATURES = set(
"json-modules",
"resizable-arraybuffer",
"Temporal",
"ShadowRealm",
"array-grouping",
"regexp-v-flag",
]
@@ -49,7 +50,6 @@ RELEASE_OR_BETA = set(
SHELL_OPTIONS = {
"import-assertions": "--enable-import-assertions",
"array-find-from-last": "--enable-array-find-last",
"ShadowRealm": "--enable-shadow-realms",
}

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Igalia SL. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) module async -- requires shell-options
// |reftest| skip module async -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) module async -- requires shell-options
// |reftest| skip module async -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) module async -- requires shell-options
// |reftest| skip module async -- ShadowRealm is not supported
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) module async -- requires shell-options
// |reftest| skip module async -- ShadowRealm is not supported
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -1,4 +1,4 @@
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// |reftest| skip -- ShadowRealm is not supported
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@@ -31,7 +31,6 @@
#include "builtin/Object.h"
#include "builtin/RegExp.h"
#include "builtin/SelfHostingDefines.h"
#include "builtin/ShadowRealm.h"
#include "builtin/Stream.h"
#include "builtin/streams/QueueingStrategies.h" // js::{ByteLength,Count}QueueingStrategy
#include "builtin/streams/ReadableStream.h" // js::ReadableStream
@@ -210,9 +209,6 @@ bool GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) {
case JSProto_AsyncIterator:
return !cx->realm()->creationOptions().getIteratorHelpersEnabled();
case JSProto_ShadowRealm:
return !cx->realm()->creationOptions().getShadowRealmsEnabled();
default:
MOZ_CRASH("unexpected JSProtoKey");
}

View File

@@ -348,16 +348,6 @@ class GlobalObject : public NativeObject {
return &global->getPrototype(key);
}
static JS::Handle<JSObject*> getOrCreatePrototypeHandle(JSContext* cx,
JSProtoKey key) {
MOZ_ASSERT(key != JSProto_Null);
Handle<GlobalObject*> global = cx->global();
if (!GlobalObject::ensureConstructor(cx, global, key)) {
return nullptr;
}
return global->getPrototypeHandle(key);
}
JSObject* maybeGetConstructor(JSProtoKey protoKey) const {
MOZ_ASSERT(JSProto_Null < protoKey);
MOZ_ASSERT(protoKey < JSProto_LIMIT);
@@ -387,14 +377,6 @@ class GlobalObject : public NativeObject {
return *maybeGetPrototype(key);
}
JS::Handle<JSObject*> getPrototypeHandle(JSProtoKey protoKey) const {
MOZ_ASSERT(hasPrototype(protoKey));
MOZ_ASSERT(JSProto_Null < protoKey);
MOZ_ASSERT(protoKey < JSProto_LIMIT);
return Handle<JSObject*>::fromMarkedLocation(
&data().builtinConstructors[protoKey].prototype.get());
}
void setPrototype(JSProtoKey key, JSObject* obj) {
MOZ_ASSERT(obj);
data().builtinConstructors[key].prototype = obj;
@@ -489,16 +471,6 @@ class GlobalObject : public NativeObject {
return &global->getPrototype(JSProto_Object);
}
static Handle<JSObject*> getOrCreateObjectPrototypeHandle(
JSContext* cx, Handle<GlobalObject*> global) {
if (!global->functionObjectClassesInitialized()) {
if (!ensureConstructor(cx, global, JSProto_Object)) {
return nullptr;
}
}
return global->getPrototypeHandle(JSProto_Object);
}
static JSObject* getOrCreateFunctionConstructor(
JSContext* cx, Handle<GlobalObject*> global) {
if (!global->functionObjectClassesInitialized()) {

View File

@@ -13,7 +13,6 @@
#include "jsfriendapi.h"
#include "builtin/WrappedFunctionObject.h"
#include "debugger/DebugAPI.h"
#include "debugger/Debugger.h"
#include "gc/Policy.h"
@@ -723,11 +722,6 @@ JS_PUBLIC_API JSObject* JS::GetRealmObjectPrototype(JSContext* cx) {
return GlobalObject::getOrCreateObjectPrototype(cx, cx->global());
}
JS_PUBLIC_API JS::Handle<JSObject*> JS::GetRealmObjectPrototypeHandle(
JSContext* cx) {
return GlobalObject::getOrCreateObjectPrototypeHandle(cx, cx->global());
}
JS_PUBLIC_API JSObject* JS::GetRealmFunctionPrototype(JSContext* cx) {
CHECK_THREAD(cx);
return GlobalObject::getOrCreateFunctionPrototype(cx, cx->global());
@@ -783,12 +777,6 @@ JS_PUBLIC_API Realm* JS::GetFunctionRealm(JSContext* cx, HandleObject objArg) {
continue;
}
// WrappedFunctionObjects also have a [[Realm]] internal slot,
// which is the nonCCWRealm by construction.
if (obj->is<WrappedFunctionObject>()) {
return obj->nonCCWRealm();
}
// Step 4.
if (IsScriptedProxy(obj)) {
// Steps 4.a-b.

View File

@@ -48,7 +48,6 @@
# include "js/Proxy.h" // For AutoEnterPolicy
#endif
#include "js/ScriptPrivate.h"
#include "js/ShadowRealmCallbacks.h"
#include "js/Stack.h"
#include "js/Stream.h" // JS::AbortSignalIsAborted
#include "js/StreamConsumer.h"
@@ -1031,21 +1030,6 @@ struct JSRuntime {
};
ErrorInterceptionSupport errorInterception;
#endif // defined(NIGHTLY_BUILD)
public:
JS::GlobalInitializeCallback getShadowRealmInitializeGlobalCallback() {
return shadowRealmInitializeGlobalCallback;
}
JS::GlobalCreationCallback getShadowRealmGlobalCreationCallback() {
return shadowRealmGlobalCreationCallback;
}
js::MainThreadData<JS::GlobalInitializeCallback>
shadowRealmInitializeGlobalCallback;
js::MainThreadData<JS::GlobalCreationCallback>
shadowRealmGlobalCreationCallback;
};
// Context for sending telemetry to the embedder from any thread, main or

Some files were not shown because too many files have changed in this diff Show More