зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1461292 part 1 - Rename JSAutoCompartment to JSAutoRealm. r=bz,luke
This commit is contained in:
Родитель
bbe16552f5
Коммит
80e44e8003
|
@ -94,7 +94,7 @@ struct DevTools : public ::testing::Test {
|
|||
if (!newGlobal)
|
||||
return nullptr;
|
||||
|
||||
JSAutoCompartment ac(cx, newGlobal);
|
||||
JSAutoRealm ar(cx, newGlobal);
|
||||
|
||||
/* Populate the global object with the standard globals, like Object and
|
||||
Array. */
|
||||
|
|
|
@ -18,7 +18,7 @@ DEF_TEST(DoesCrossCompartmentBoundaries, {
|
|||
ASSERT_TRUE(newGlobal);
|
||||
JSCompartment* newCompartment = nullptr;
|
||||
{
|
||||
JSAutoCompartment ac(cx, newGlobal);
|
||||
JSAutoRealm ar(cx, newGlobal);
|
||||
ASSERT_TRUE(JS_InitStandardClasses(cx, newGlobal));
|
||||
newCompartment = js::GetContextCompartment(cx);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ DEF_TEST(DoesntCrossCompartmentBoundaries, {
|
|||
ASSERT_TRUE(newGlobal);
|
||||
JSCompartment* newCompartment = nullptr;
|
||||
{
|
||||
JSAutoCompartment ac(cx, newGlobal);
|
||||
JSAutoRealm ar(cx, newGlobal);
|
||||
ASSERT_TRUE(JS_InitStandardClasses(cx, newGlobal));
|
||||
newCompartment = js::GetContextCompartment(cx);
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ ChromeUtils::ShallowClone(GlobalObject& aGlobal,
|
|||
return;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
|
||||
if (!JS_Enumerate(cx, obj, &ids) ||
|
||||
!values.reserve(ids.length())) {
|
||||
|
@ -238,14 +238,14 @@ ChromeUtils::ShallowClone(GlobalObject& aGlobal,
|
|||
|
||||
JS::RootedObject obj(cx);
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (aTarget) {
|
||||
JS::RootedObject target(cx, js::CheckedUnwrap(aTarget));
|
||||
if (!target) {
|
||||
js::ReportAccessDenied(cx);
|
||||
return;
|
||||
}
|
||||
ac.emplace(cx, target);
|
||||
ar.emplace(cx, target);
|
||||
}
|
||||
|
||||
obj = JS_NewPlainObject(cx);
|
||||
|
@ -481,7 +481,7 @@ namespace module_getter {
|
|||
|
||||
JS::RootedValue value(aCx);
|
||||
{
|
||||
JSAutoCompartment ac(aCx, moduleExports);
|
||||
JSAutoRealm ar(aCx, moduleExports);
|
||||
|
||||
if (!JS_GetPropertyById(aCx, moduleExports, id, &value)) {
|
||||
return false;
|
||||
|
@ -728,11 +728,11 @@ ChromeUtils::CreateError(const GlobalObject& aGlobal, const nsAString& aMessage,
|
|||
uint32_t line = 0;
|
||||
uint32_t column = 0;
|
||||
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
JS::RootedObject stack(cx);
|
||||
if (aStack) {
|
||||
stack = UncheckedUnwrap(aStack);
|
||||
ac.emplace(cx, stack);
|
||||
ar.emplace(cx, stack);
|
||||
|
||||
if (JS::GetSavedFrameLine(cx, stack, &line) != JS::SavedFrameResult::Ok ||
|
||||
JS::GetSavedFrameColumn(cx, stack, &column) != JS::SavedFrameResult::Ok ||
|
||||
|
|
|
@ -774,11 +774,11 @@ CustomElementRegistry::Define(const nsAString& aName,
|
|||
*/
|
||||
AutoSetRunningFlag as(this);
|
||||
|
||||
{ // Enter constructor's compartment.
|
||||
{ // Enter constructor's realm.
|
||||
/**
|
||||
* 10.1. Let prototype be Get(constructor, "prototype"). Rethrow any exceptions.
|
||||
*/
|
||||
JSAutoCompartment ac(cx, constructor);
|
||||
JSAutoRealm ar(cx, constructor);
|
||||
// The .prototype on the constructor passed could be an "expando" of a
|
||||
// wrapper. So we should get it from wrapper instead of the underlying
|
||||
// object.
|
||||
|
@ -794,7 +794,7 @@ CustomElementRegistry::Define(const nsAString& aName,
|
|||
aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("constructor.prototype"));
|
||||
return;
|
||||
}
|
||||
} // Leave constructor's compartment.
|
||||
} // Leave constructor's realm.
|
||||
|
||||
JS::Rooted<JSObject*> constructorProtoUnwrapped(
|
||||
cx, js::CheckedUnwrap(&constructorPrototype.toObject()));
|
||||
|
@ -806,7 +806,7 @@ CustomElementRegistry::Define(const nsAString& aName,
|
|||
}
|
||||
|
||||
{ // Enter constructorProtoUnwrapped's compartment
|
||||
JSAutoCompartment ac(cx, constructorProtoUnwrapped);
|
||||
JSAutoRealm ar(cx, constructorProtoUnwrapped);
|
||||
|
||||
/**
|
||||
* 10.3. Let lifecycleCallbacks be a map with the four keys
|
||||
|
@ -847,8 +847,8 @@ CustomElementRegistry::Define(const nsAString& aName,
|
|||
* any exceptions from the conversion.
|
||||
*/
|
||||
if (callbacksHolder->mAttributeChangedCallback.WasPassed()) {
|
||||
// Enter constructor's compartment.
|
||||
JSAutoCompartment ac(cx, constructor);
|
||||
// Enter constructor's realm.
|
||||
JSAutoRealm ar(cx, constructor);
|
||||
JS::Rooted<JS::Value> observedAttributesIterable(cx);
|
||||
|
||||
if (!JS_GetProperty(cx, constructor, "observedAttributes",
|
||||
|
@ -897,7 +897,7 @@ CustomElementRegistry::Define(const nsAString& aName,
|
|||
}
|
||||
}
|
||||
}
|
||||
} // Leave constructor's compartment.
|
||||
} // Leave constructor's realm.
|
||||
} // Leave constructorProtoUnwrapped's compartment.
|
||||
} // Unset mIsCustomDefinitionRunning
|
||||
|
||||
|
|
|
@ -3684,11 +3684,11 @@ Element::Animate(const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|||
}
|
||||
|
||||
// Animation constructor follows the standard Xray calling convention and
|
||||
// needs to be called in the target element's compartment.
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
// needs to be called in the target element's realm.
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (js::GetContextCompartment(aContext) !=
|
||||
js::GetObjectCompartment(ownerGlobal->GetGlobalJSObject())) {
|
||||
ac.emplace(aContext, ownerGlobal->GetGlobalJSObject());
|
||||
ar.emplace(aContext, ownerGlobal->GetGlobalJSObject());
|
||||
}
|
||||
|
||||
AnimationTimeline* timeline = referenceElement->OwnerDoc()->Timeline();
|
||||
|
|
|
@ -88,7 +88,7 @@ IntlUtils::GetDisplayNames(const Sequence<nsString>& aLocales,
|
|||
}
|
||||
|
||||
// Return the result as DisplayNameResult.
|
||||
JSAutoCompartment ac(cx, &retVal.toObject());
|
||||
JSAutoRealm ar(cx, &retVal.toObject());
|
||||
if (!aResult.Init(cx, retVal)) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ IntlUtils::GetLocaleInfo(const Sequence<nsString>& aLocales,
|
|||
}
|
||||
|
||||
// Return the result as LocaleInfo.
|
||||
JSAutoCompartment ac(cx, &retVal.toObject());
|
||||
JSAutoRealm ar(cx, &retVal.toObject());
|
||||
if (!aResult.Init(cx, retVal)) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ PostMessageEvent::Run()
|
|||
targetWindow->IsDying())
|
||||
return NS_OK;
|
||||
|
||||
JSAutoCompartment ac(cx, targetWindow->GetWrapper());
|
||||
JSAutoRealm ar(cx, targetWindow->GetWrapper());
|
||||
|
||||
// Ensure that any origin which might have been provided is the origin of this
|
||||
// window's document. Note that we do this *now* instead of when postMessage
|
||||
|
|
|
@ -38,7 +38,7 @@ StructuredCloneBlob::Constructor(GlobalObject& aGlobal, JS::HandleValue aValue,
|
|||
|
||||
RefPtr<StructuredCloneBlob> holder = StructuredCloneBlob::Create();
|
||||
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
JS::RootedValue value(cx, aValue);
|
||||
|
||||
if (aTargetGlobal) {
|
||||
|
@ -49,7 +49,7 @@ StructuredCloneBlob::Constructor(GlobalObject& aGlobal, JS::HandleValue aValue,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ac.emplace(cx, targetGlobal);
|
||||
ar.emplace(cx, targetGlobal);
|
||||
|
||||
if (!JS_WrapValue(cx, &value)) {
|
||||
aRv.NoteJSContextException(cx);
|
||||
|
@ -63,7 +63,7 @@ StructuredCloneBlob::Constructor(GlobalObject& aGlobal, JS::HandleValue aValue,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ac.emplace(cx, obj);
|
||||
ar.emplace(cx, obj);
|
||||
value = JS::ObjectValue(*obj);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ StructuredCloneBlob::Deserialize(JSContext* aCx, JS::HandleObject aTargetScope,
|
|||
}
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(aCx, scope);
|
||||
JSAutoRealm ar(aCx, scope);
|
||||
|
||||
Read(xpc::NativeGlobal(scope), aCx, aResult, aRv);
|
||||
if (aRv.Failed()) {
|
||||
|
|
|
@ -714,7 +714,7 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices)
|
|||
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JSObject*> obj(cx, &aChoices.toObject());
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
|
||||
|
|
|
@ -3123,7 +3123,7 @@ nsContentUtils::SubjectPrincipal()
|
|||
JSCompartment *compartment = js::GetContextCompartment(cx);
|
||||
|
||||
// When an AutoJSAPI is instantiated, we are in a null compartment until the
|
||||
// first JSAutoCompartment, which is kind of a purgatory as far as permissions
|
||||
// first JSAutoRealm, which is kind of a purgatory as far as permissions
|
||||
// go. It would be nice to just hard-abort if somebody does a security check
|
||||
// in this purgatory zone, but that would be too fragile, since it could be
|
||||
// triggered by random IsCallerChrome() checks 20-levels deep.
|
||||
|
@ -7071,7 +7071,7 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
|
|||
|
||||
// We can use the junk scope here, because we're just using it for
|
||||
// regexp evaluation, not actual script execution.
|
||||
JSAutoCompartment ac(cx, xpc::UnprivilegedJunkScope());
|
||||
JSAutoRealm ar(cx, xpc::UnprivilegedJunkScope());
|
||||
|
||||
// The pattern has to match the entire value.
|
||||
aPattern.InsertLiteral(u"^(?:", 0);
|
||||
|
|
|
@ -2624,7 +2624,7 @@ nsDocument::IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject)
|
|||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, aObject);
|
||||
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
JSAutoRealm ar(aCx, obj);
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj));
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
|
||||
|
@ -7092,7 +7092,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
|||
// It's kind of irrelevant, given that we're passing aAllowWrapping =
|
||||
// false, and documents should always insist on being wrapped in an
|
||||
// canonical scope. But we try to pass something sane anyway.
|
||||
JSAutoCompartment ac(cx, GetScopeObject()->GetGlobalJSObject());
|
||||
JSAutoRealm ar(cx, GetScopeObject()->GetGlobalJSObject());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
rv = nsContentUtils::WrapNative(cx, this, this, &v,
|
||||
/* aAllowWrapping = */ false);
|
||||
|
@ -9647,7 +9647,7 @@ nsIDocument::GetStateObject(nsIVariant** aState)
|
|||
NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
|
||||
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
mStateObjectContainer->
|
||||
DeserializeToVariant(cx, getter_AddRefs(mStateObjectCached));
|
||||
|
|
|
@ -1898,7 +1898,7 @@ nsFrameLoader::SetOwnerContent(Element* aContent)
|
|||
|
||||
JS::RootedObject wrapper(jsapi.cx(), GetWrapper());
|
||||
if (wrapper) {
|
||||
JSAutoCompartment ac(jsapi.cx(), wrapper);
|
||||
JSAutoRealm ar(jsapi.cx(), wrapper);
|
||||
IgnoredErrorResult rv;
|
||||
ReparentWrapper(jsapi.cx(), wrapper, rv);
|
||||
Unused << NS_WARN_IF(rv.Failed());
|
||||
|
|
|
@ -1023,9 +1023,9 @@ nsFrameMessageManager::GetInitialProcessData(JSContext* aCx,
|
|||
JS::RootedValue init(aCx, mInitialProcessData);
|
||||
if (mChrome && init.isUndefined()) {
|
||||
// We create the initial object in the junk scope. If we created it in a
|
||||
// normal compartment, that compartment would leak until shutdown.
|
||||
// normal realm, that realm would leak until shutdown.
|
||||
JS::RootedObject global(aCx, xpc::PrivilegedJunkScope());
|
||||
JSAutoCompartment ac(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
|
||||
JS::RootedObject obj(aCx, JS_NewPlainObject(aCx));
|
||||
if (!obj) {
|
||||
|
|
|
@ -4130,7 +4130,7 @@ nsGlobalWindowInner::CallerInnerWindow()
|
|||
// sandboxPrototype. This used to work incidentally for unrelated reasons, but
|
||||
// now we need to do some special handling to support it.
|
||||
if (xpc::IsSandbox(scope)) {
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
JSAutoRealm ar(cx, scope);
|
||||
JS::Rooted<JSObject*> scopeProto(cx);
|
||||
bool ok = JS_GetPrototype(cx, scope, &scopeProto);
|
||||
NS_ENSURE_TRUE(ok, nullptr);
|
||||
|
|
|
@ -793,7 +793,7 @@ nsChromeOuterWindowProxy::singleton;
|
|||
static JSObject*
|
||||
NewOuterWindowProxy(JSContext *cx, JS::Handle<JSObject*> global, bool isChrome)
|
||||
{
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
MOZ_ASSERT(js::GetGlobalForObjectCrossCompartment(global) == global);
|
||||
|
||||
js::WrapperOptions options;
|
||||
|
@ -1535,7 +1535,7 @@ static const JSFunctionSpec EnablePrivilegeSpec[] = {
|
|||
static bool
|
||||
InitializeLegacyNetscapeObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
|
||||
{
|
||||
JSAutoCompartment ac(aCx, aGlobal);
|
||||
JSAutoRealm ar(aCx, aGlobal);
|
||||
|
||||
// Note: MathJax depends on window.netscape being exposed. See bug 791526.
|
||||
JS::Rooted<JSObject*> obj(aCx);
|
||||
|
@ -1872,8 +1872,8 @@ nsGlobalWindowOuter::SetNewDocument(nsIDocument* aDocument,
|
|||
mContext->SetWindowProxy(outerObject);
|
||||
}
|
||||
|
||||
// Enter the new global's compartment.
|
||||
JSAutoCompartment ac(cx, GetWrapperPreserveColor());
|
||||
// Enter the new global's realm.
|
||||
JSAutoRealm ar(cx, GetWrapperPreserveColor());
|
||||
|
||||
{
|
||||
JS::Rooted<JSObject*> outer(cx, GetWrapperPreserveColor());
|
||||
|
@ -1905,7 +1905,7 @@ nsGlobalWindowOuter::SetNewDocument(nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, GetWrapperPreserveColor());
|
||||
JSAutoRealm ar(cx, GetWrapperPreserveColor());
|
||||
|
||||
if (!aState && !reUseInnerWindow) {
|
||||
// Loading a new page and creating a new inner window, *not*
|
||||
|
@ -3808,7 +3808,7 @@ nsGlobalWindowOuter::DispatchResizeEvent(const CSSIntSize& aSize)
|
|||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSAutoCompartment ac(cx, GetWrapperPreserveColor());
|
||||
JSAutoRealm ar(cx, GetWrapperPreserveColor());
|
||||
|
||||
DOMWindowResizeEventDetail detail;
|
||||
detail.mWidth = aSize.width;
|
||||
|
@ -5604,7 +5604,7 @@ nsGlobalWindowOuter::CallerInnerWindow()
|
|||
// sandboxPrototype. This used to work incidentally for unrelated reasons, but
|
||||
// now we need to do some special handling to support it.
|
||||
if (xpc::IsSandbox(scope)) {
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
JSAutoRealm ar(cx, scope);
|
||||
JS::Rooted<JSObject*> scopeProto(cx);
|
||||
bool ok = JS_GetPrototype(cx, scope, &scopeProto);
|
||||
NS_ENSURE_TRUE(ok, nullptr);
|
||||
|
@ -7152,7 +7152,7 @@ nsGlobalWindowOuter::SecurityCheckURL(const char *aURL)
|
|||
}
|
||||
AutoJSContext cx;
|
||||
nsGlobalWindowInner* sourceWin = nsGlobalWindowInner::Cast(sourceWindow);
|
||||
JSAutoCompartment ac(cx, sourceWin->GetGlobalJSObject());
|
||||
JSAutoRealm ar(cx, sourceWin->GetGlobalJSObject());
|
||||
|
||||
// Resolve the baseURI, which could be relative to the calling window.
|
||||
//
|
||||
|
|
|
@ -1276,7 +1276,7 @@ CheckForOutdatedParent(nsINode* aParent, nsINode* aNode, ErrorResult& aError)
|
|||
|
||||
if (js::GetGlobalForObjectCrossCompartment(existingObj) !=
|
||||
global->GetGlobalJSObject()) {
|
||||
JSAutoCompartment ac(cx, existingObj);
|
||||
JSAutoRealm ar(cx, existingObj);
|
||||
ReparentWrapper(cx, existingObj, aError);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -793,7 +793,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports* aArgs,
|
|||
NS_ASSERTION(prim == nullptr,
|
||||
"Don't pass nsISupportsPrimitives - use nsIVariant!");
|
||||
#endif
|
||||
JSAutoCompartment ac(cx, aScope);
|
||||
JSAutoRealm ar(cx, aScope);
|
||||
rv = nsContentUtils::WrapNative(cx, arg, thisVal);
|
||||
}
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
|||
|
||||
JS::Rooted<JSObject*> scope(cx, GetWindowProxy());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
JSAutoRealm ar(cx, scope);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, data, iid, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -1119,7 +1119,7 @@ nsJSContext::InitClasses(JS::Handle<JSObject*> aGlobalObj)
|
|||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSAutoCompartment ac(cx, aGlobalObj);
|
||||
JSAutoRealm ar(cx, aGlobalObj);
|
||||
|
||||
// Attempt to initialize profiling functions
|
||||
::JS_DefineProfilingFunctions(cx, aGlobalObj);
|
||||
|
|
|
@ -142,7 +142,7 @@ nsJSUtils::ExecutionContext::ExecutionContext(JSContext* aCx,
|
|||
__LINE__, js::ProfileEntry::Category::JS),
|
||||
#endif
|
||||
mCx(aCx)
|
||||
, mCompartment(aCx, aGlobal)
|
||||
, mRealm(aCx, aGlobal)
|
||||
, mRetValue(aCx)
|
||||
, mScopeChain(aCx)
|
||||
, mRv(NS_OK)
|
||||
|
|
|
@ -77,8 +77,8 @@ public:
|
|||
|
||||
JSContext* mCx;
|
||||
|
||||
// Handles switching to our global's compartment.
|
||||
JSAutoCompartment mCompartment;
|
||||
// Handles switching to our global's realm.
|
||||
JSAutoRealm mRealm;
|
||||
|
||||
// Set to a valid handle if a return value is expected.
|
||||
JS::Rooted<JS::Value> mRetValue;
|
||||
|
|
|
@ -584,7 +584,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
|||
JS::Rooted<JSObject*> wrapper(cx);
|
||||
if ((wrapper = aNode->GetWrapper())) {
|
||||
MOZ_ASSERT(IsDOMObject(wrapper));
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JSAutoRealm ar(cx, wrapper);
|
||||
ReparentWrapper(cx, wrapper, aError);
|
||||
if (aError.Failed()) {
|
||||
if (wasRegistered) {
|
||||
|
|
|
@ -3563,12 +3563,12 @@ nsObjectLoadingContent::SetupProtoChain(JSContext* aCx,
|
|||
return;
|
||||
}
|
||||
|
||||
// We get called on random compartments here for some reason
|
||||
// (perhaps because WrapObject can happen on a random compartment?)
|
||||
// so make sure to enter the compartment of aObject.
|
||||
// We get called on random realms here for some reason
|
||||
// (perhaps because WrapObject can happen on a random realm?)
|
||||
// so make sure to enter the realm of aObject.
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
|
||||
JSAutoCompartment ac(aCx, aObject);
|
||||
JSAutoRealm ar(aCx, aObject);
|
||||
|
||||
RefPtr<nsNPAPIPluginInstance> pi;
|
||||
nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi));
|
||||
|
@ -3673,10 +3673,9 @@ nsObjectLoadingContent::GetPluginJSObject(JSContext *cx,
|
|||
JS::MutableHandle<JSObject*> plugin_obj,
|
||||
JS::MutableHandle<JSObject*> plugin_proto)
|
||||
{
|
||||
// NB: We need an AutoEnterCompartment because we can be called from
|
||||
// nsPluginFrame when the plugin loads after the JS object for our content
|
||||
// node has been created.
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
// NB: We need a JSAutoRealm because we can be called from nsPluginFrame when
|
||||
// the plugin loads after the JS object for our content node has been created.
|
||||
JSAutoRealm ar(cx, obj);
|
||||
|
||||
if (plugin_inst) {
|
||||
plugin_inst->GetJSObject(cx, plugin_obj.address());
|
||||
|
@ -3707,7 +3706,7 @@ nsObjectLoadingContent::TeardownProtoChain()
|
|||
MOZ_ASSERT(obj);
|
||||
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
|
||||
// Loop over the DOM element's JS object prototype chain and remove
|
||||
// all JS objects of the class sNPObjectJSWrapperClass
|
||||
|
|
|
@ -1608,7 +1608,7 @@ ResolvePrototypeOrConstructor(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
|||
{
|
||||
JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj));
|
||||
{
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
|
||||
// This function is called when resolving the "constructor" and "prototype"
|
||||
// properties of Xrays for DOM prototypes and constructors respectively.
|
||||
|
@ -2254,7 +2254,7 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg, ErrorResult& aErr
|
|||
domClass->mGetAssociatedGlobal(aCx, aObj));
|
||||
MOZ_ASSERT(JS_IsGlobalObject(newParent));
|
||||
|
||||
JSAutoCompartment oldAc(aCx, oldParent);
|
||||
JSAutoRealm oldAr(aCx, oldParent);
|
||||
|
||||
JSCompartment* oldCompartment = js::GetObjectCompartment(oldParent);
|
||||
JSCompartment* newCompartment = js::GetObjectCompartment(newParent);
|
||||
|
@ -2274,7 +2274,7 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg, ErrorResult& aErr
|
|||
expandoObject = DOMProxyHandler::GetAndClearExpandoObject(aObj);
|
||||
}
|
||||
|
||||
JSAutoCompartment newAc(aCx, newParent);
|
||||
JSAutoRealm newAr(aCx, newParent);
|
||||
|
||||
// First we clone the reflector. We get a copy of its properties and clone its
|
||||
// expando chain.
|
||||
|
@ -3510,10 +3510,10 @@ GetMaplikeSetlikeBackingObject(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
|||
JS::Rooted<JS::Value> slotValue(aCx);
|
||||
slotValue = js::GetReservedSlot(reflector, aSlotIndex);
|
||||
if (slotValue.isUndefined()) {
|
||||
// Since backing object access can happen in non-originating compartments,
|
||||
// make sure to create the backing object in reflector compartment.
|
||||
// Since backing object access can happen in non-originating realms,
|
||||
// make sure to create the backing object in reflector realm.
|
||||
{
|
||||
JSAutoCompartment ac(aCx, reflector);
|
||||
JSAutoRealm ar(aCx, reflector);
|
||||
JS::Rooted<JSObject*> newBackingObj(aCx);
|
||||
newBackingObj.set(Method(aCx));
|
||||
if (NS_WARN_IF(!newBackingObj)) {
|
||||
|
@ -3736,7 +3736,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
|
|||
// objects as constructors? Of course it's not clear that the spec check
|
||||
// makes sense to start with: https://github.com/whatwg/html/issues/3575
|
||||
{
|
||||
JSAutoCompartment ac(aCx, newTarget);
|
||||
JSAutoRealm ar(aCx, newTarget);
|
||||
JS::Handle<JSObject*> constructor =
|
||||
GetPerInterfaceObjectHandle(aCx, aConstructorId, aCreator,
|
||||
true);
|
||||
|
@ -3769,9 +3769,9 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
|
|||
// Step 4.
|
||||
// If the definition is for an autonomous custom element, the active
|
||||
// function should be HTMLElement or XULElement. We want to get the actual
|
||||
// functions to compare to from our global's compartment, not the caller
|
||||
// compartment.
|
||||
JSAutoCompartment ac(aCx, global.Get());
|
||||
// functions to compare to from our global's realm, not the caller
|
||||
// realm.
|
||||
JSAutoRealm ar(aCx, global.Get());
|
||||
|
||||
JS::Rooted<JSObject*> constructor(aCx);
|
||||
if (ns == kNameSpaceID_XUL) {
|
||||
|
@ -3811,9 +3811,9 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
|
|||
return ThrowErrorMessage(aCx, MSG_ILLEGAL_CONSTRUCTOR);
|
||||
}
|
||||
|
||||
// We want to get the constructor from our global's compartment, not the
|
||||
// caller compartment.
|
||||
JSAutoCompartment ac(aCx, global.Get());
|
||||
// We want to get the constructor from our global's realm, not the
|
||||
// caller realm.
|
||||
JSAutoRealm ar(aCx, global.Get());
|
||||
JS::Rooted<JSObject*> constructor(aCx, cb(aCx));
|
||||
if (!constructor) {
|
||||
return false;
|
||||
|
@ -3833,22 +3833,22 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
|
|||
// Step 7.
|
||||
if (!desiredProto) {
|
||||
// This fallback behavior is designed to match analogous behavior for the
|
||||
// JavaScript built-ins. So we enter the compartment of our underlying
|
||||
// newTarget object and fall back to the prototype object from that global.
|
||||
// JavaScript built-ins. So we enter the realm of our underlying newTarget
|
||||
// object and fall back to the prototype object from that global.
|
||||
// XXX The spec says to use GetFunctionRealm(), which is not actually
|
||||
// the same thing as what we have here (e.g. in the case of scripted callable proxies
|
||||
// whose target is not same-compartment with the proxy, or bound functions, etc).
|
||||
// whose target is not same-realm with the proxy, or bound functions, etc).
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
|
||||
{
|
||||
JSAutoCompartment ac(aCx, newTarget);
|
||||
JSAutoRealm ar(aCx, newTarget);
|
||||
desiredProto = GetPerInterfaceObjectHandle(aCx, aProtoId, aCreator, true);
|
||||
if (!desiredProto) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// desiredProto is in the compartment of the underlying newTarget object.
|
||||
// Wrap it into the context compartment.
|
||||
// desiredProto is in the realm of the underlying newTarget object.
|
||||
// Wrap it into the context realm.
|
||||
if (!JS_WrapObject(aCx, &desiredProto)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3863,9 +3863,9 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
|
|||
if (constructionStack.IsEmpty()) {
|
||||
// Step 8.
|
||||
// Now we go to construct an element. We want to do this in global's
|
||||
// compartment, not caller compartment (the normal constructor behavior),
|
||||
// realm, not caller realm (the normal constructor behavior),
|
||||
// just in case those elements create JS things.
|
||||
JSAutoCompartment ac(aCx, global.Get());
|
||||
JSAutoRealm ar(aCx, global.Get());
|
||||
|
||||
RefPtr<NodeInfo> nodeInfo =
|
||||
doc->NodeInfoManager()->GetNodeInfo(definition->mLocalName,
|
||||
|
@ -3907,8 +3907,8 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
|
|||
// that proto).
|
||||
JS::Rooted<JSObject*> reflector(aCx, element->GetWrapper());
|
||||
if (reflector) {
|
||||
// reflector might be in different compartment.
|
||||
JSAutoCompartment ac(aCx, reflector);
|
||||
// reflector might be in different realm.
|
||||
JSAutoRealm ar(aCx, reflector);
|
||||
JS::Rooted<JSObject*> givenProto(aCx, desiredProto);
|
||||
if (!JS_WrapObject(aCx, &givenProto) ||
|
||||
!JS_SetPrototype(aCx, reflector, givenProto)) {
|
||||
|
@ -3921,9 +3921,9 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
|
|||
}
|
||||
|
||||
// Tail end of step 8 and step 13: returning the element. We want to do this
|
||||
// part in the global's compartment, though in practice it won't matter much
|
||||
// because Element always knows which compartment it should be created in.
|
||||
JSAutoCompartment ac(aCx, global.Get());
|
||||
// part in the global's realm, though in practice it won't matter much
|
||||
// because Element always knows which realm it should be created in.
|
||||
JSAutoRealm ar(aCx, global.Get());
|
||||
if (!js::IsObjectInContextCompartment(desiredProto, aCx) &&
|
||||
!JS_WrapObject(aCx, &desiredProto)) {
|
||||
return false;
|
||||
|
@ -3945,11 +3945,11 @@ AssertReflectorHasGivenProto(JSContext* aCx, JSObject* aReflector,
|
|||
}
|
||||
|
||||
JS::Rooted<JSObject*> reflector(aCx, aReflector);
|
||||
JSAutoCompartment ac(aCx, reflector);
|
||||
JSAutoRealm ar(aCx, reflector);
|
||||
JS::Rooted<JSObject*> reflectorProto(aCx);
|
||||
bool ok = JS_GetPrototype(aCx, reflector, &reflectorProto);
|
||||
MOZ_ASSERT(ok);
|
||||
// aGivenProto may not be in the right compartment here, so we
|
||||
// aGivenProto may not be in the right realm here, so we
|
||||
// have to wrap it to compare.
|
||||
JS::Rooted<JSObject*> givenProto(aCx, aGivenProto);
|
||||
ok = JS_WrapObject(aCx, &givenProto);
|
||||
|
|
|
@ -1128,7 +1128,7 @@ DoGetOrCreateDOMReflector(JSContext* cx, T* value,
|
|||
|
||||
if (wrapBehavior == eDontWrapIntoContextCompartment) {
|
||||
if (TypeNeedsOuterization<T>::value) {
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
return TryToOuterize(rval);
|
||||
}
|
||||
|
||||
|
@ -1188,12 +1188,12 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
|
|||
{
|
||||
static_assert(IsRefcounted<T>::value, "Don't pass owned classes in here.");
|
||||
MOZ_ASSERT(value);
|
||||
// We try to wrap in the compartment of the underlying object of "scope"
|
||||
// We try to wrap in the realm of the underlying object of "scope"
|
||||
JS::Rooted<JSObject*> obj(cx);
|
||||
{
|
||||
// scope for the JSAutoCompartment so that we restore the compartment
|
||||
// scope for the JSAutoRealm so that we restore the realm
|
||||
// before we call JS_WrapValue.
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
// Maybe<Handle> doesn't so much work, and in any case, adding
|
||||
// more Maybe (one for a Rooted and one for a Handle) adds more
|
||||
// code (and branches!) than just adding a single rooted.
|
||||
|
@ -1203,7 +1203,7 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
|
|||
scope = js::CheckedUnwrap(scope, /* stopAtWindowProxy = */ false);
|
||||
if (!scope)
|
||||
return false;
|
||||
ac.emplace(cx, scope);
|
||||
ar.emplace(cx, scope);
|
||||
if (!JS_WrapObject(cx, &proto)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1239,12 +1239,12 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
|
|||
if (!value) {
|
||||
MOZ_CRASH("Don't try to wrap null objects");
|
||||
}
|
||||
// We try to wrap in the compartment of the underlying object of "scope"
|
||||
// We try to wrap in the realm of the underlying object of "scope"
|
||||
JS::Rooted<JSObject*> obj(cx);
|
||||
{
|
||||
// scope for the JSAutoCompartment so that we restore the compartment
|
||||
// scope for the JSAutoRealm so that we restore the realm
|
||||
// before we call JS_WrapValue.
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
// Maybe<Handle> doesn't so much work, and in any case, adding
|
||||
// more Maybe (one for a Rooted and one for a Handle) adds more
|
||||
// code (and branches!) than just adding a single rooted.
|
||||
|
@ -1254,7 +1254,7 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
|
|||
scope = js::CheckedUnwrap(scope, /* stopAtWindowProxy = */ false);
|
||||
if (!scope)
|
||||
return false;
|
||||
ac.emplace(cx, scope);
|
||||
ar.emplace(cx, scope);
|
||||
if (!JS_WrapObject(cx, &proto)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2510,7 +2510,7 @@ XrayGetNativeProto(JSContext* cx, JS::Handle<JSObject*> obj,
|
|||
{
|
||||
JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj));
|
||||
{
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
const DOMJSClass* domClass = GetDOMClass(obj);
|
||||
if (domClass) {
|
||||
ProtoHandleGetter protoGetter = domClass->mGetProto;
|
||||
|
@ -3151,7 +3151,7 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
|
|||
return false;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(aCx, aGlobal);
|
||||
JSAutoRealm ar(aCx, aGlobal);
|
||||
|
||||
{
|
||||
js::SetReservedSlot(aGlobal, DOM_OBJECT_SLOT, JS::PrivateValue(aNative));
|
||||
|
@ -3340,7 +3340,7 @@ WrappedJSToDictionary(JSContext* aCx, nsISupports* aObject, T& aDictionary)
|
|||
return false;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
JSAutoRealm ar(aCx, obj);
|
||||
JS::Rooted<JS::Value> v(aCx, JS::ObjectValue(*obj));
|
||||
return aDictionary.Init(aCx, v);
|
||||
}
|
||||
|
|
|
@ -246,12 +246,12 @@ CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
|
|||
mAsyncStackSetter.emplace(cx, *mAsyncStack, aExecutionReason);
|
||||
}
|
||||
|
||||
// Enter the compartment of our callback, so we can actually work with it.
|
||||
// Enter the realm of our callback, so we can actually work with it.
|
||||
//
|
||||
// Note that if the callback is a wrapper, this will not be the same
|
||||
// compartment that we ended up in with mAutoEntryScript above, because the
|
||||
// realm that we ended up in with mAutoEntryScript above, because the
|
||||
// entry point is based off of the unwrapped callback (realCallback).
|
||||
mAc.emplace(cx, *mRootedCallable);
|
||||
mAr.emplace(cx, *mRootedCallable);
|
||||
|
||||
// And now we're ready to go.
|
||||
mCx = cx;
|
||||
|
@ -302,12 +302,12 @@ CallbackObject::CallSetup::ShouldRethrowException(JS::Handle<JS::Value> aExcepti
|
|||
|
||||
CallbackObject::CallSetup::~CallSetup()
|
||||
{
|
||||
// To get our nesting right we have to destroy our JSAutoCompartment first.
|
||||
// To get our nesting right we have to destroy our JSAutoRealm first.
|
||||
// In particular, we want to do this before we try reporting any exceptions,
|
||||
// so we end up reporting them while in the compartment of our entry point,
|
||||
// so we end up reporting them while in the realm of our entry point,
|
||||
// not whatever cross-compartment wrappper mCallback might be.
|
||||
// Be careful: the JSAutoCompartment might not have been constructed at all!
|
||||
mAc.reset();
|
||||
// Be careful: the JSAutoRealm might not have been constructed at all!
|
||||
mAr.reset();
|
||||
|
||||
// Now, if we have a JSContext, report any pending errors on it, unless we
|
||||
// were told to re-throw them.
|
||||
|
@ -332,7 +332,7 @@ CallbackObject::CallSetup::~CallSetup()
|
|||
// Either we're supposed to report our exceptions, or we're supposed to
|
||||
// re-throw them but we failed to get the exception value. Either way,
|
||||
// we'll just report the pending exception, if any, once ~mAutoEntryScript
|
||||
// runs. Note that we've already run ~mAc, effectively, so we don't have
|
||||
// runs. Note that we've already run ~mAr, effectively, so we don't have
|
||||
// to worry about ordering here.
|
||||
if (mErrorResult.IsJSContextException()) {
|
||||
// XXXkhuey bug 1117269. When this is fixed, please consider fixing
|
||||
|
@ -376,7 +376,7 @@ CallbackObjectHolderBase::ToXPCOMCallback(CallbackObject* aCallback,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, callback);
|
||||
JSAutoRealm ar(cx, callback);
|
||||
RefPtr<nsXPCWrappedJS> wrappedJS;
|
||||
nsresult rv =
|
||||
nsXPCWrappedJS::GetNewOrUsed(callback, aIID, getter_AddRefs(wrappedJS));
|
||||
|
|
|
@ -337,11 +337,11 @@ protected:
|
|||
Maybe<JS::Rooted<JSObject*>> mAsyncStack;
|
||||
Maybe<JS::AutoSetAsyncStackForNewCalls> mAsyncStackSetter;
|
||||
|
||||
// Can't construct a JSAutoCompartment without a JSContext either. Also,
|
||||
// Put mAc after mAutoEntryScript so that we exit the compartment before
|
||||
// we pop the JSContext. Though in practice we'll often manually order
|
||||
// those two things.
|
||||
Maybe<JSAutoCompartment> mAc;
|
||||
// Can't construct a JSAutoRealm without a JSContext either. Also,
|
||||
// Put mAr after mAutoEntryScript so that we exit the realm before we
|
||||
// pop the script settings stack. Though in practice we'll often manually
|
||||
// order those two things.
|
||||
Maybe<JSAutoRealm> mAr;
|
||||
|
||||
// An ErrorResult to possibly re-throw exceptions on and whether
|
||||
// we should re-throw them.
|
||||
|
|
|
@ -3745,7 +3745,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
|
|||
return true;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
$*{declareProto}
|
||||
|
||||
$*{createObject}
|
||||
|
@ -3906,9 +3906,9 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
|||
$*{failureCode}
|
||||
}
|
||||
|
||||
// aReflector is a new global, so has a new compartment. Enter it
|
||||
// aReflector is a new global, so has a new realm. Enter it
|
||||
// before doing anything with it.
|
||||
JSAutoCompartment ac(aCx, aReflector);
|
||||
JSAutoRealm ar(aCx, aReflector);
|
||||
|
||||
if (!DefineProperties(aCx, aReflector, ${properties}, ${chromeProperties})) {
|
||||
$*{failureCode}
|
||||
|
@ -3993,7 +3993,7 @@ class CGClearCachedValueMethod(CGAbstractMethod):
|
|||
"""
|
||||
JS::Rooted<JS::Value> temp(aCx);
|
||||
JSJitGetterCallArgs args(&temp);
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
JSAutoRealm ar(aCx, obj);
|
||||
if (!get_${name}(aCx, obj, aObject, args)) {
|
||||
js::SetReservedSlot(obj, ${slotIndex}, oldValue);
|
||||
return false;
|
||||
|
@ -5388,12 +5388,12 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
|
||||
templateBody = fill(
|
||||
"""
|
||||
{ // Scope for our GlobalObject, FastErrorResult, JSAutoCompartment,
|
||||
{ // Scope for our GlobalObject, FastErrorResult, JSAutoRealm,
|
||||
// etc.
|
||||
|
||||
JS::Rooted<JSObject*> globalObj(cx);
|
||||
$*{getPromiseGlobal}
|
||||
JSAutoCompartment ac(cx, globalObj);
|
||||
JSAutoRealm ar(cx, globalObj);
|
||||
GlobalObject promiseGlobal(cx, globalObj);
|
||||
if (promiseGlobal.Failed()) {
|
||||
$*{exceptionCode}
|
||||
|
@ -7636,8 +7636,8 @@ class CGPerSignatureCall(CGThing):
|
|||
# JSAPI types, present. Effectively, we're emulating a
|
||||
# CrossCompartmentWrapper, but working with the C++ types, not the
|
||||
# original list of JS::Values.
|
||||
cgThings.append(CGGeneric("Maybe<JSAutoCompartment> ac;\n"))
|
||||
xraySteps.append(CGGeneric("ac.emplace(cx, obj);\n"))
|
||||
cgThings.append(CGGeneric("Maybe<JSAutoRealm> ar;\n"))
|
||||
xraySteps.append(CGGeneric("ar.emplace(cx, obj);\n"))
|
||||
xraySteps.append(CGGeneric(dedent(
|
||||
"""
|
||||
if (!JS_WrapObject(cx, &desiredProto)) {
|
||||
|
@ -7847,17 +7847,17 @@ class CGPerSignatureCall(CGThing):
|
|||
"""
|
||||
{
|
||||
JS::Rooted<JSObject*> conversionScope(cx, ${conversionScope});
|
||||
JSAutoCompartment ac(cx, conversionScope);
|
||||
JSAutoRealm ar(cx, conversionScope);
|
||||
do { // block we break out of when done wrapping
|
||||
$*{wrapCode}
|
||||
} while (false);
|
||||
$*{postConversionSteps}
|
||||
}
|
||||
{ // And now store things in the compartment of our slotStorage.
|
||||
JSAutoCompartment ac(cx, slotStorage);
|
||||
{ // And now store things in the realm of our slotStorage.
|
||||
JSAutoRealm ar(cx, slotStorage);
|
||||
$*{slotStorageSteps}
|
||||
}
|
||||
// And now make sure args.rval() is in the caller compartment
|
||||
// And now make sure args.rval() is in the caller realm.
|
||||
return ${maybeWrap}(cx, args.rval());
|
||||
""",
|
||||
conversionScope=conversionScope,
|
||||
|
@ -10860,7 +10860,7 @@ class CGResolveOwnPropertyViaResolve(CGAbstractBindingMethod):
|
|||
// then use the fact that it created the objects as a flag
|
||||
// to avoid re-resolving the properties if someone deletes
|
||||
// them.
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
JS_MarkCrossZoneId(cx, id);
|
||||
JS::Rooted<JS::PropertyDescriptor> objDesc(cx);
|
||||
if (!self->DoResolve(cx, obj, id, &objDesc)) {
|
||||
|
@ -11555,7 +11555,7 @@ class CGDeleteNamedProperty(CGAbstractStaticMethod):
|
|||
MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(xray));
|
||||
MOZ_ASSERT(js::IsProxy(proxy));
|
||||
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy));
|
||||
JSAutoCompartment ac(cx, proxy);
|
||||
JSAutoRealm ar(cx, proxy);
|
||||
bool deleteSucceeded = false;
|
||||
bool found = false;
|
||||
$*{namedBody}
|
||||
|
@ -12754,7 +12754,7 @@ class CGDictionary(CGThing):
|
|||
// side-effects, followed by a call to JS::ToJSONMaybeSafely,
|
||||
// which likewise guarantees no side-effects for the sorts of
|
||||
// things we will pass it.
|
||||
JSAutoCompartment ac(cx, UnprivilegedJunkScopeOrWorkerGlobal());
|
||||
JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
if (!ToObjectInternal(cx, &val)) {
|
||||
return false;
|
||||
|
@ -15306,7 +15306,7 @@ class CGJSImplClass(CGBindingImplClass):
|
|||
}
|
||||
|
||||
// Now define it on our chrome object
|
||||
JSAutoCompartment ac(aCx, mImpl->CallbackOrNull());
|
||||
JSAutoRealm ar(aCx, mImpl->CallbackOrNull());
|
||||
if (!JS_WrapObject(aCx, &obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -16684,7 +16684,7 @@ class CGMaplikeOrSetlikeHelperFunctionGenerator(CallbackMember):
|
|||
// It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here because
|
||||
// all we want is to wrap into _some_ scope and then unwrap to find
|
||||
// the reflector, and wrapping has no side-effects.
|
||||
JSAutoCompartment tempCompartment(cx, UnprivilegedJunkScopeOrWorkerGlobal());
|
||||
JSAutoRealm tempRealm(cx, UnprivilegedJunkScopeOrWorkerGlobal());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
if(!ToJSValue(cx, self, &v)) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
|
@ -16694,7 +16694,7 @@ class CGMaplikeOrSetlikeHelperFunctionGenerator(CallbackMember):
|
|||
// similarly across method generators, it's called obj here.
|
||||
JS::Rooted<JSObject*> obj(cx);
|
||||
obj = js::UncheckedUnwrap(&v.toObject(), /* stopAtWindowProxy = */ false);
|
||||
JSAutoCompartment reflectorCompartment(cx, obj);
|
||||
JSAutoRealm reflectorRealm(cx, obj);
|
||||
""" % self.getDefaultRetval())
|
||||
|
||||
def getArgs(self, returnType, argList):
|
||||
|
|
|
@ -134,7 +134,7 @@ SimpleGlobalObject::Create(GlobalType globalType, JS::Handle<JS::Value> proto)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
// It's important to create the nsIGlobalObject for our new global before we
|
||||
// start trying to wrap things like the prototype into its compartment,
|
||||
|
|
|
@ -47,7 +47,7 @@ WriteStructuredCloneImageData(JSContext* aCx, JSStructuredCloneWriter* aWriter,
|
|||
uint32_t height = aImageData->Height();
|
||||
JS::Rooted<JSObject*> dataArray(aCx, aImageData->GetDataObject());
|
||||
|
||||
JSAutoCompartment ac(aCx, dataArray);
|
||||
JSAutoRealm ar(aCx, dataArray);
|
||||
JS::Rooted<JS::Value> arrayValue(aCx, JS::ObjectValue(*dataArray));
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_IMAGEDATA, 0) &&
|
||||
JS_WriteUint32Pair(aWriter, width, height) &&
|
||||
|
|
|
@ -172,9 +172,9 @@ public:
|
|||
Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
|
||||
const T* data = nullptr) {
|
||||
JS::Rooted<JSObject*> creatorWrapper(cx);
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) {
|
||||
ac.emplace(cx, creatorWrapper);
|
||||
ar.emplace(cx, creatorWrapper);
|
||||
}
|
||||
|
||||
return CreateCommon(cx, length, data);
|
||||
|
|
|
@ -308,7 +308,7 @@ WebIDLGlobalNameHash::DefineIfEnabled(JSContext* aCx,
|
|||
if (xpc::WrapperFactory::IsXrayWrapper(aObj)) {
|
||||
JS::Rooted<JSObject*> constructor(aCx);
|
||||
{
|
||||
JSAutoCompartment ac(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
constructor = FindNamedConstructorForXray(aCx, aId, entry);
|
||||
}
|
||||
if (NS_WARN_IF(!constructor)) {
|
||||
|
|
|
@ -146,7 +146,7 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
|
|||
}
|
||||
|
||||
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
if (!ToJSValue(cx, detail, &val)) {
|
||||
MOZ_CRASH("Failed to convert dictionary to JS::Value due to OOM.");
|
||||
return BrowserElementParent::OPEN_WINDOW_IGNORED;
|
||||
|
|
|
@ -67,7 +67,7 @@ WebGLContext::WebGLObjectAsJSValue(JSContext* cx, const WebGLObjectType* object,
|
|||
MOZ_ASSERT(this == object->mContext);
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
JS::Rooted<JSObject*> wrapper(cx, GetWrapper());
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JSAutoRealm ar(cx, wrapper);
|
||||
if (!dom::GetOrCreateDOMReflector(cx, const_cast<WebGLObjectType*>(object), &v)) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return JS::NullValue();
|
||||
|
|
|
@ -198,7 +198,7 @@ OpenWindow(const ClientOpenWindowArgs& aArgs,
|
|||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, sandbox);
|
||||
JSAutoRealm ar(cx, sandbox);
|
||||
|
||||
// ContentProcess
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch =
|
||||
|
|
|
@ -643,7 +643,7 @@ private:
|
|||
// don't need a proxy here.
|
||||
global = js::UncheckedUnwrap(global);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
// We don't need to set a parent object in mCallData bacause there are not
|
||||
// DOM objects exposed to worklet.
|
||||
|
@ -758,7 +758,7 @@ protected:
|
|||
// We don't need a proxy here.
|
||||
global = js::UncheckedUnwrap(global);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
RunConsole(cx, nullptr, nullptr);
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ private:
|
|||
// don't need a proxy here.
|
||||
global = js::UncheckedUnwrap(global);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
// We don't need to set a parent object in mCallData bacause there are not
|
||||
// DOM objects exposed to worklet.
|
||||
|
@ -1904,7 +1904,7 @@ Console::PopulateConsoleNotificationInTheTargetScope(JSContext* aCx,
|
|||
aData->mCountValue);
|
||||
}
|
||||
|
||||
JSAutoCompartment ac2(aCx, targetScope);
|
||||
JSAutoRealm ar2(aCx, targetScope);
|
||||
|
||||
if (NS_WARN_IF(!ToJSValue(aCx, event, aEventValue))) {
|
||||
return false;
|
||||
|
@ -2670,7 +2670,7 @@ Console::RetrieveConsoleEvents(JSContext* aCx, nsTArray<JS::Value>& aEvents,
|
|||
JS::Rooted<JS::Value> value(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> sequenceScope(aCx, mCallDataStorage[i]->mGlobal);
|
||||
JSAutoCompartment ac(aCx, sequenceScope);
|
||||
JSAutoRealm ar(aCx, sequenceScope);
|
||||
|
||||
Sequence<JS::Value> sequence;
|
||||
SequenceRooter<JS::Value> arguments(aCx, &sequence);
|
||||
|
|
|
@ -80,7 +80,7 @@ ConsoleUtils::ReportForServiceWorkerScopeInternal(const nsAString& aScope,
|
|||
// We don't need a proxy here.
|
||||
global = js::UncheckedUnwrap(global);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
RootedDictionary<ConsoleEvent> event(cx);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ TextEncoder::Encode(JSContext* aCx,
|
|||
return;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(aCx, aObj);
|
||||
JSAutoRealm ar(aCx, aObj);
|
||||
JSObject* outView = Uint8Array::Create(
|
||||
aCx, utf8.Length(), reinterpret_cast<const uint8_t*>(utf8.BeginReading()));
|
||||
if (!outView) {
|
||||
|
|
|
@ -1025,11 +1025,11 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||
// where mTarget is a Window.
|
||||
//
|
||||
// The wrapScope doesn't really matter here, because the target will create
|
||||
// its reflector in the proper scope, and then we'll enter that compartment.
|
||||
// its reflector in the proper scope, and then we'll enter that realm.
|
||||
JS::Rooted<JSObject*> wrapScope(cx, global->GetGlobalJSObject());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, wrapScope);
|
||||
JSAutoRealm ar(cx, wrapScope);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, mTarget, &v,
|
||||
/* aAllowWrapping = */ false);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -1038,9 +1038,9 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||
}
|
||||
|
||||
JS::Rooted<JSObject*> target(cx, &v.toObject());
|
||||
JSAutoCompartment ac(cx, target);
|
||||
JSAutoRealm ar(cx, target);
|
||||
|
||||
// Now that we've entered the compartment we actually care about, create our
|
||||
// Now that we've entered the realm we actually care about, create our
|
||||
// scope chain. Note that we start with |element|, not aElement, because
|
||||
// mTarget is different from aElement in the <body> case, where mTarget is a
|
||||
// Window, and in that case we do not want the scope chain to include the body
|
||||
|
|
|
@ -152,8 +152,8 @@ NS_IMETHODIMP
|
|||
EventListenerInfo::GetListenerObject(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aObject)
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
GetJSVal(aCx, ac, aObject);
|
||||
Maybe<JSAutoRealm> ar;
|
||||
GetJSVal(aCx, ar, aObject);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -165,12 +165,12 @@ NS_IMPL_ISUPPORTS(EventListenerService, nsIEventListenerService)
|
|||
|
||||
bool
|
||||
EventListenerInfo::GetJSVal(JSContext* aCx,
|
||||
Maybe<JSAutoCompartment>& aAc,
|
||||
Maybe<JSAutoRealm>& aAr,
|
||||
JS::MutableHandle<JS::Value> aJSVal)
|
||||
{
|
||||
if (mScriptedListener) {
|
||||
aJSVal.setObject(*mScriptedListener);
|
||||
aAc.emplace(aCx, mScriptedListener);
|
||||
aAr.emplace(aCx, mScriptedListener);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -184,9 +184,9 @@ EventListenerInfo::ToSource(nsAString& aResult)
|
|||
aResult.SetIsVoid(true);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
if (GetJSVal(cx, ac, &v)) {
|
||||
if (GetJSVal(cx, ar, &v)) {
|
||||
JSString* str = JS_ValueToSource(cx, v);
|
||||
if (str) {
|
||||
nsAutoJSString autoStr;
|
||||
|
|
|
@ -61,7 +61,7 @@ protected:
|
|||
virtual ~EventListenerInfo();
|
||||
|
||||
bool GetJSVal(JSContext* aCx,
|
||||
Maybe<JSAutoCompartment>& aAc,
|
||||
Maybe<JSAutoRealm>& aAr,
|
||||
JS::MutableHandle<JS::Value> aJSVal);
|
||||
|
||||
nsString mType;
|
||||
|
|
|
@ -1451,7 +1451,7 @@ nsHTMLDocument::Open(JSContext* cx,
|
|||
nsCOMPtr<nsIScriptGlobalObject> newScope(do_QueryReferent(mScopeObject));
|
||||
JS::Rooted<JSObject*> wrapper(cx, GetWrapper());
|
||||
if (oldScope && newScope != oldScope && wrapper) {
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JSAutoRealm ar(cx, wrapper);
|
||||
mozilla::dom::ReparentWrapper(cx, wrapper, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
|
|
|
@ -1467,7 +1467,7 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
nsresult rv = DeserializeIndexValue(cx, &value);
|
||||
|
@ -1589,7 +1589,7 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
nsresult rv = DeserializeUpgradeValue(cx, &value);
|
||||
|
|
|
@ -316,13 +316,13 @@ IDBRequest::SetResultCallback(ResultCallback* aCallback)
|
|||
}
|
||||
|
||||
AutoJSAPI autoJS;
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
|
||||
if (GetScriptOwner()) {
|
||||
// If we have a script owner we want the SafeJSContext and then to enter the
|
||||
// script owner's compartment.
|
||||
// script owner's realm.
|
||||
autoJS.Init();
|
||||
ac.emplace(autoJS.cx(), GetScriptOwner());
|
||||
ar.emplace(autoJS.cx(), GetScriptOwner());
|
||||
} else {
|
||||
// Otherwise our owner is a window and we use that to initialize.
|
||||
MOZ_ASSERT(GetOwner());
|
||||
|
|
|
@ -472,7 +472,7 @@ ConsoleListener::Observe(nsIConsoleMessage* aMessage)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (stack.isObject()) {
|
||||
JSAutoCompartment ac(cx, &stack.toObject());
|
||||
JSAutoRealm ar(cx, &stack.toObject());
|
||||
|
||||
StructuredCloneData data;
|
||||
ErrorResult err;
|
||||
|
|
|
@ -535,7 +535,7 @@ AudioContext::DecodeAudioData(const ArrayBuffer& aBuffer,
|
|||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSAutoCompartment ac(cx, aBuffer.Obj());
|
||||
JSAutoRealm ar(cx, aBuffer.Obj());
|
||||
|
||||
promise = Promise::Create(parentObject, aRv);
|
||||
if (aRv.Failed()) {
|
||||
|
|
|
@ -859,7 +859,7 @@ TCPSocket::Send(JSContext* aCx,
|
|||
}
|
||||
} else {
|
||||
JS::Rooted<JSObject*> obj(aCx, aData.Obj());
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
JSAutoRealm ar(aCx, obj);
|
||||
JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*obj));
|
||||
|
||||
stream = do_CreateInstance("@mozilla.org/io/arraybuffer-input-stream;1");
|
||||
|
|
|
@ -738,7 +738,7 @@ nsJSObjWrapper::NP_HasMethod(NPObject *npobj, NPIdentifier id)
|
|||
|
||||
nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
|
||||
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
JSAutoRealm ar(cx, npjsobj->mJSObj);
|
||||
MarkCrossZoneNPIdentifier(cx, id);
|
||||
|
||||
AutoJSExceptionSuppressor suppressor(aes, npjsobj);
|
||||
|
@ -778,7 +778,7 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
|
|||
nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
|
||||
|
||||
JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
|
||||
JSAutoCompartment ac(cx, jsobj);
|
||||
JSAutoRealm ar(cx, jsobj);
|
||||
MarkCrossZoneNPIdentifier(cx, method);
|
||||
JS::Rooted<JS::Value> fv(cx);
|
||||
|
||||
|
@ -871,7 +871,7 @@ nsJSObjWrapper::NP_HasProperty(NPObject *npobj, NPIdentifier npid)
|
|||
|
||||
AutoJSExceptionSuppressor suppressor(aes, npjsobj);
|
||||
JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
|
||||
JSAutoCompartment ac(cx, jsobj);
|
||||
JSAutoRealm ar(cx, jsobj);
|
||||
MarkCrossZoneNPIdentifier(cx, npid);
|
||||
|
||||
NS_ASSERTION(NPIdentifierIsInt(npid) || NPIdentifierIsString(npid),
|
||||
|
@ -908,7 +908,7 @@ nsJSObjWrapper::NP_GetProperty(NPObject *npobj, NPIdentifier id,
|
|||
nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
|
||||
|
||||
AutoJSExceptionSuppressor suppressor(aes, npjsobj);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
JSAutoRealm ar(cx, npjsobj->mJSObj);
|
||||
MarkCrossZoneNPIdentifier(cx, id);
|
||||
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
|
@ -945,7 +945,7 @@ nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier npid,
|
|||
|
||||
AutoJSExceptionSuppressor suppressor(aes, npjsobj);
|
||||
JS::Rooted<JSObject*> jsObj(cx, npjsobj->mJSObj);
|
||||
JSAutoCompartment ac(cx, jsObj);
|
||||
JSAutoRealm ar(cx, jsObj);
|
||||
MarkCrossZoneNPIdentifier(cx, npid);
|
||||
|
||||
JS::Rooted<JS::Value> v(cx, NPVariantToJSVal(npp, cx, value));
|
||||
|
@ -983,7 +983,7 @@ nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier npid)
|
|||
AutoJSExceptionSuppressor suppressor(aes, npjsobj);
|
||||
JS::ObjectOpResult result;
|
||||
JS::Rooted<JSObject*> obj(cx, npjsobj->mJSObj);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
MarkCrossZoneNPIdentifier(cx, npid);
|
||||
|
||||
NS_ASSERTION(NPIdentifierIsInt(npid) || NPIdentifierIsString(npid),
|
||||
|
@ -1037,7 +1037,7 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
|
|||
|
||||
AutoJSExceptionSuppressor suppressor(aes, npjsobj);
|
||||
JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
|
||||
JSAutoCompartment ac(cx, jsobj);
|
||||
JSAutoRealm ar(cx, jsobj);
|
||||
|
||||
JS::Rooted<JS::IdVector> ida(cx, JS::IdVector(cx));
|
||||
if (!JS_Enumerate(cx, jsobj, &ida)) {
|
||||
|
@ -1179,7 +1179,7 @@ GetNPObjectWrapper(JSContext *cx, JS::Handle<JSObject*> aObj, bool wrapResult =
|
|||
return obj;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
if (!::JS_GetPrototype(cx, obj, &obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ already_AddRefed<Promise>
|
|||
Promise::Resolve(nsIGlobalObject* aGlobal, JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
|
||||
{
|
||||
JSAutoCompartment ac(aCx, aGlobal->GetGlobalJSObject());
|
||||
JSAutoRealm ar(aCx, aGlobal->GetGlobalJSObject());
|
||||
JS::Rooted<JSObject*> p(aCx,
|
||||
JS::CallOriginalPromiseResolve(aCx, aValue));
|
||||
if (!p) {
|
||||
|
@ -117,7 +117,7 @@ already_AddRefed<Promise>
|
|||
Promise::Reject(nsIGlobalObject* aGlobal, JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
|
||||
{
|
||||
JSAutoCompartment ac(aCx, aGlobal->GetGlobalJSObject());
|
||||
JSAutoRealm ar(aCx, aGlobal->GetGlobalJSObject());
|
||||
JS::Rooted<JSObject*> p(aCx,
|
||||
JS::CallOriginalPromiseReject(aCx, aValue));
|
||||
if (!p) {
|
||||
|
|
|
@ -279,7 +279,7 @@ PromiseDebugging::FlushUncaughtRejectionsInternal()
|
|||
|
||||
obs->OnLeftUncaught(promise, IgnoreErrors());
|
||||
}
|
||||
JSAutoCompartment ac(cx, promise);
|
||||
JSAutoRealm ar(cx, promise);
|
||||
Promise::ReportRejectedPromise(cx, promise);
|
||||
}
|
||||
storage->mUncaughtRejections.clear();
|
||||
|
|
|
@ -379,7 +379,7 @@ AutoJSAPI::InitInternal(nsIGlobalObject* aGlobalObject, JSObject* aGlobal,
|
|||
// particular, we do not expose this data to anyone, which is very
|
||||
// important; otherwise it could be a cross-origin information leak.
|
||||
exnObj = js::UncheckedUnwrap(exnObj);
|
||||
JSAutoCompartment ac(aCx, exnObj);
|
||||
JSAutoRealm ar(aCx, exnObj);
|
||||
|
||||
nsAutoJSString stack, filename, name, message;
|
||||
int32_t line;
|
||||
|
@ -558,7 +558,7 @@ AutoJSAPI::ReportException()
|
|||
|
||||
// AutoJSAPI uses a JSAutoNullableCompartment, and may be in a null
|
||||
// compartment when the destructor is called. However, the JS engine
|
||||
// requires us to be in a compartment when we fetch the pending exception.
|
||||
// requires us to be in a realm when we fetch the pending exception.
|
||||
// In this case, we enter the privileged junk scope and don't dispatch any
|
||||
// error events.
|
||||
JS::Rooted<JSObject*> errorGlobal(cx(), JS::CurrentGlobalOrNull(cx()));
|
||||
|
@ -569,7 +569,7 @@ AutoJSAPI::ReportException()
|
|||
errorGlobal = GetCurrentThreadWorkerGlobal();
|
||||
}
|
||||
}
|
||||
JSAutoCompartment ac(cx(), errorGlobal);
|
||||
JSAutoRealm ar(cx(), errorGlobal);
|
||||
JS::Rooted<JS::Value> exn(cx());
|
||||
js::ErrorReport jsReport(cx());
|
||||
if (StealException(&exn) &&
|
||||
|
@ -820,8 +820,8 @@ AutoSlowOperation::CheckForInterrupt()
|
|||
{
|
||||
// For now we support only main thread!
|
||||
if (mIsMainThread) {
|
||||
// JS_CheckForInterrupt expects us to be in a compartment.
|
||||
JSAutoCompartment ac(cx(), xpc::UnprivilegedJunkScope());
|
||||
// JS_CheckForInterrupt expects us to be in a realm.
|
||||
JSAutoRealm ar(cx(), xpc::UnprivilegedJunkScope());
|
||||
JS_CheckForInterrupt(cx());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -609,7 +609,7 @@ ServiceWorkerPrivate::SendMessageEvent(ipc::StructuredCloneData&& aData,
|
|||
// don't need a proxy here.
|
||||
global = js::UncheckedUnwrap(global);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> messageData(cx);
|
||||
aData.Read(cx, &messageData, rv);
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
JS::Rooted<JSObject*> global(aCx, globalScope->GetWrapper());
|
||||
|
||||
ErrorResult rv;
|
||||
JSAutoCompartment ac(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
workerinternals::LoadMainScript(aWorkerPrivate, mScriptURL,
|
||||
DebuggerScript, rv);
|
||||
rv.WouldReportJSException();
|
||||
|
|
|
@ -465,12 +465,12 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
// This is a little dumb, but aCx is in the null compartment here because we
|
||||
// This is a little dumb, but aCx is in the null realm here because we
|
||||
// set it up that way in our Run(), since we had not created the global at
|
||||
// that point yet. So we need to enter the compartment of our global,
|
||||
// that point yet. So we need to enter the realm of our global,
|
||||
// because setting a pending exception on aCx involves wrapping into its
|
||||
// current compartment. Luckily we have a global now.
|
||||
JSAutoCompartment ac(aCx, globalScope->GetGlobalJSObject());
|
||||
JSAutoRealm ar(aCx, globalScope->GetGlobalJSObject());
|
||||
if (rv.MaybeSetPendingException(aCx)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3218,7 +3218,7 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
|
|||
|
||||
InitializeGCTimers();
|
||||
|
||||
Maybe<JSAutoCompartment> workerCompartment;
|
||||
Maybe<JSAutoRealm> workerCompartment;
|
||||
|
||||
for (;;) {
|
||||
WorkerStatus currentStatus, previousStatus;
|
||||
|
@ -3332,7 +3332,7 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
|
|||
MOZ_ASSERT(globalScope);
|
||||
|
||||
// Now *might* be a good time to GC. Let the JS engine make the decision.
|
||||
JSAutoCompartment ac(aCx, globalScope->GetGlobalJSObject());
|
||||
JSAutoRealm ar(aCx, globalScope->GetGlobalJSObject());
|
||||
JS_MaybeGC(aCx);
|
||||
}
|
||||
} else if (normalRunnablesPending) {
|
||||
|
@ -3342,7 +3342,7 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
|
|||
normalRunnablesPending = NS_HasPendingEvents(mThread);
|
||||
if (normalRunnablesPending && GlobalScope()) {
|
||||
// Now *might* be a good time to GC. Let the JS engine make the decision.
|
||||
JSAutoCompartment ac(aCx, GlobalScope()->GetGlobalJSObject());
|
||||
JSAutoRealm ar(aCx, GlobalScope()->GetGlobalJSObject());
|
||||
JS_MaybeGC(aCx);
|
||||
}
|
||||
}
|
||||
|
@ -5297,7 +5297,7 @@ WorkerPrivate::GetOrCreateGlobalScope(JSContext* aCx)
|
|||
JS::Rooted<JSObject*> global(aCx);
|
||||
NS_ENSURE_TRUE(globalScope->WrapGlobalObject(aCx, &global), nullptr);
|
||||
|
||||
JSAutoCompartment ac(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
|
||||
// RegisterBindings() can spin a nested event loop so we have to set mScope
|
||||
// before calling it, and we have to make sure to unset mScope if it fails.
|
||||
|
@ -5327,7 +5327,7 @@ WorkerPrivate::CreateDebuggerGlobalScope(JSContext* aCx)
|
|||
JS::Rooted<JSObject*> global(aCx);
|
||||
NS_ENSURE_TRUE(globalScope->WrapGlobalObject(aCx, &global), nullptr);
|
||||
|
||||
JSAutoCompartment ac(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
|
||||
// RegisterDebuggerBindings() can spin a nested event loop so we have to set
|
||||
// mDebuggerScope before calling it, and we have to make sure to unset
|
||||
|
|
|
@ -272,7 +272,7 @@ WorkerRunnable::Run()
|
|||
"ScriptExecutorRunnable");
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(mWorkerPrivate->GetJSContext()));
|
||||
// We can't enter a useful compartment on the JSContext here; just pass it
|
||||
// We can't enter a useful realm on the JSContext here; just pass it
|
||||
// in as-is.
|
||||
PostRun(mWorkerPrivate->GetJSContext(), mWorkerPrivate, false);
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -344,18 +344,18 @@ WorkerRunnable::Run()
|
|||
MOZ_ASSERT_IF(!targetIsWorkerThread && !isMainThread,
|
||||
mWorkerPrivate->IsDedicatedWorker() && globalObject);
|
||||
|
||||
// If we're on the parent thread we might be in a null compartment in the
|
||||
// If we're on the parent thread we might be in a null realm in the
|
||||
// situation described above when globalObject is null. Make sure to enter
|
||||
// the compartment of the worker's reflector if there is one. There might
|
||||
// the realm of the worker's reflector if there is one. There might
|
||||
// not be one if we're just starting to compile the script for this worker.
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (!targetIsWorkerThread &&
|
||||
mWorkerPrivate->IsDedicatedWorker() &&
|
||||
mWorkerPrivate->ParentEventTargetRef()->GetWrapper()) {
|
||||
JSObject* wrapper = mWorkerPrivate->ParentEventTargetRef()->GetWrapper();
|
||||
|
||||
// If we're on the parent thread and have a reflector and a globalObject,
|
||||
// then the compartments of cx, globalObject, and the worker's reflector
|
||||
// then the realms of cx, globalObject, and the worker's reflector
|
||||
// should all match.
|
||||
MOZ_ASSERT_IF(globalObject,
|
||||
js::GetObjectCompartment(wrapper) ==
|
||||
|
@ -365,15 +365,15 @@ WorkerRunnable::Run()
|
|||
js::GetObjectCompartment(globalObject->GetGlobalJSObject()));
|
||||
|
||||
// If we're on the parent thread and have a reflector, then our
|
||||
// JSContext had better be either in the null compartment (and hence
|
||||
// have no globalObject) or in the compartment of our reflector.
|
||||
// JSContext had better be either in the null realm (and hence
|
||||
// have no globalObject) or in the realm of our reflector.
|
||||
MOZ_ASSERT(!js::GetContextCompartment(cx) ||
|
||||
js::GetObjectCompartment(wrapper) ==
|
||||
js::GetContextCompartment(cx),
|
||||
"Must either be in the null compartment or in our reflector "
|
||||
"compartment");
|
||||
|
||||
ac.emplace(cx, wrapper);
|
||||
ar.emplace(cx, wrapper);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!jsapi->HasException());
|
||||
|
|
|
@ -1013,7 +1013,7 @@ WorkerDebuggerGlobalScope::LoadSubScript(JSContext* aCx,
|
|||
{
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (aSandbox.WasPassed()) {
|
||||
JS::Rooted<JSObject*> sandbox(aCx, js::CheckedUnwrap(aSandbox.Value()));
|
||||
if (!IsWorkerDebuggerSandbox(sandbox)) {
|
||||
|
@ -1021,7 +1021,7 @@ WorkerDebuggerGlobalScope::LoadSubScript(JSContext* aCx,
|
|||
return;
|
||||
}
|
||||
|
||||
ac.emplace(aCx, sandbox);
|
||||
ar.emplace(aCx, sandbox);
|
||||
}
|
||||
|
||||
nsTArray<nsString> urls;
|
||||
|
|
|
@ -377,7 +377,7 @@ ExecutionRunnable::RunOnWorkletThread()
|
|||
MOZ_ASSERT(workletThread);
|
||||
|
||||
JSContext* cx = workletThread->GetJSContext();
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoRequest areq(cx);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
|
@ -399,7 +399,7 @@ ExecutionRunnable::RunOnWorkletThread()
|
|||
compileOptions.setIsRunOnce(true);
|
||||
compileOptions.setNoScriptRval(true);
|
||||
|
||||
JSAutoCompartment comp(cx, globalObj);
|
||||
JSAutoRealm ar(cx, globalObj);
|
||||
|
||||
JS::SourceBufferHolder buffer(mScriptBuffer.release(), mScriptLength,
|
||||
JS::SourceBufferHolder::GiveOwnership);
|
||||
|
@ -538,7 +538,7 @@ Worklet::CreateGlobalScope(JSContext* aCx, WorkletType aWorkletType)
|
|||
JS::Rooted<JSObject*> global(aCx);
|
||||
NS_ENSURE_TRUE(scope->WrapGlobalObject(aCx, &global), nullptr);
|
||||
|
||||
JSAutoCompartment ac(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
|
||||
// Init Web IDL bindings
|
||||
if (!RegisterWorkletBindings(aCx, global)) {
|
||||
|
|
|
@ -640,7 +640,7 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,
|
|||
// the XBL scope, we'll end up with the global of the reflector.
|
||||
JS::Rooted<JSObject*> xblScope(cx, xpc::GetXBLScopeOrGlobal(cx, jsobj));
|
||||
NS_ENSURE_TRUE(xblScope, NS_ERROR_UNEXPECTED);
|
||||
JSAutoCompartment ac(cx, xblScope);
|
||||
JSAutoRealm ar(cx, xblScope);
|
||||
bool ok = JS_WrapObject(cx, &jsobj);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
MOZ_ASSERT_IF(js::IsWrapper(jsobj), xpc::IsXrayWrapper(jsobj));
|
||||
|
|
|
@ -737,7 +737,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
|||
// that was...
|
||||
|
||||
// Find the right prototype.
|
||||
JSAutoCompartment ac(cx, scriptObject);
|
||||
JSAutoRealm ar(cx, scriptObject);
|
||||
|
||||
JS::Rooted<JSObject*> base(cx, scriptObject);
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
|
@ -895,7 +895,7 @@ GetOrCreateMapEntryForPrototype(JSContext *cx, JS::Handle<JSObject*> proto)
|
|||
MOZ_ASSERT(js::GetGlobalForObjectCrossCompartment(scope) == scope);
|
||||
|
||||
JS::Rooted<JSObject*> wrappedProto(cx, proto);
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
JSAutoRealm ar(cx, scope);
|
||||
if (!JS_WrapObject(cx, &wrappedProto)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -974,14 +974,14 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
|
|||
if (parent_proto) {
|
||||
holder = GetOrCreateMapEntryForPrototype(cx, parent_proto);
|
||||
} else {
|
||||
JSAutoCompartment innerAC(cx, xblScope);
|
||||
JSAutoRealm innerAR(cx, xblScope);
|
||||
holder = GetOrCreateClassObjectMap(cx, xblScope, "__ContentClassObjectMap__");
|
||||
}
|
||||
if (NS_WARN_IF(!holder)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
js::AssertSameCompartment(holder, xblScope);
|
||||
JSAutoCompartment ac(cx, holder);
|
||||
JSAutoRealm ar(cx, holder);
|
||||
|
||||
// Look up the class on the property holder. The only properties on the
|
||||
// holder should be class objects. If we don't find the class object, we need
|
||||
|
@ -999,9 +999,9 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
|
|||
MOZ_ASSERT(cachedBinding == aProtoBinding);
|
||||
} else {
|
||||
|
||||
// We need to create the prototype. First, enter the compartment where it's
|
||||
// We need to create the prototype. First, enter the realm where it's
|
||||
// going to live, and create it.
|
||||
JSAutoCompartment ac2(cx, global);
|
||||
JSAutoRealm ar2(cx, global);
|
||||
proto = JS_NewObjectWithGivenProto(cx, &gPrototypeJSClass, parent_proto);
|
||||
if (!proto) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -1018,9 +1018,9 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
|
|||
NS_ADDREF(docInfo);
|
||||
JS_SetReservedSlot(proto, 0, JS::PrivateValue(aProtoBinding));
|
||||
|
||||
// Next, enter the compartment of the property holder, wrap the proto, and
|
||||
// Next, enter the realm of the property holder, wrap the proto, and
|
||||
// stick it on.
|
||||
JSAutoCompartment ac3(cx, holder);
|
||||
JSAutoRealm ar3(cx, holder);
|
||||
if (!JS_WrapObject(cx, &proto) ||
|
||||
!JS_DefineUCProperty(cx, holder, aClassName.get(), -1, proto,
|
||||
JSPROP_READONLY | JSPROP_PERMANENT))
|
||||
|
@ -1029,9 +1029,9 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
|
|||
}
|
||||
}
|
||||
|
||||
// Whew. We have the proto. Wrap it back into the compartment of |obj|,
|
||||
// Whew. We have the proto. Wrap it back into the realm of |obj|,
|
||||
// splice it in, and return it.
|
||||
JSAutoCompartment ac4(cx, obj);
|
||||
JSAutoRealm ar4(cx, obj);
|
||||
if (!JS_WrapObject(cx, &proto) || !JS_SetPrototype(cx, obj, proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ nsXBLBinding::LookupMember(JSContext* aCx, JS::Handle<jsid> aId,
|
|||
|
||||
// Enter the xbl scope and invoke the internal version.
|
||||
{
|
||||
JSAutoCompartment ac(aCx, xblScope);
|
||||
JSAutoRealm ar(aCx, xblScope);
|
||||
JS::Rooted<jsid> id(aCx, aId);
|
||||
if (!LookupMemberInternal(aCx, name, id, aDesc, xblScope)) {
|
||||
return false;
|
||||
|
|
|
@ -80,14 +80,14 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
|||
// bother about the field accessors here, since we don't use/support those
|
||||
// for in-content bindings.
|
||||
|
||||
// First, start by entering the compartment of the XBL scope. This may or may
|
||||
// not be the same compartment as globalObject.
|
||||
// First, start by entering the realm of the XBL scope. This may or may
|
||||
// not be the same realm as globalObject.
|
||||
JS::Rooted<JSObject*> globalObject(cx,
|
||||
GetGlobalForObjectCrossCompartment(targetClassObject));
|
||||
JS::Rooted<JSObject*> scopeObject(cx, xpc::GetXBLScopeOrGlobal(cx, globalObject));
|
||||
NS_ENSURE_TRUE(scopeObject, NS_ERROR_OUT_OF_MEMORY);
|
||||
MOZ_ASSERT(js::GetGlobalForObjectCrossCompartment(scopeObject) == scopeObject);
|
||||
JSAutoCompartment ac(cx, scopeObject);
|
||||
JSAutoRealm ar(cx, scopeObject);
|
||||
|
||||
// Determine the appropriate property holder.
|
||||
//
|
||||
|
@ -164,7 +164,7 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
|||
}
|
||||
|
||||
// From here on out, work in the scope of the bound element.
|
||||
JSAutoCompartment ac2(cx, targetClassObject);
|
||||
JSAutoRealm ar2(cx, targetClassObject);
|
||||
|
||||
// Install all of our field accessors.
|
||||
for (nsXBLProtoImplField* curr = mFields;
|
||||
|
@ -206,7 +206,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
|||
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
// Make sure the interface object is created before the prototype object
|
||||
// so that XULElement is hidden from content. See bug 909340.
|
||||
bool defineOnGlobal = dom::XULElementBinding::ConstructorEnabled(cx, global);
|
||||
|
@ -217,7 +217,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> value(cx, &v.toObject());
|
||||
JSAutoCompartment ac2(cx, value);
|
||||
JSAutoRealm ar2(cx, value);
|
||||
|
||||
// All of the above code was just obtaining the bound element's script object and its immediate
|
||||
// concrete base class. We need to alter the object so that our concrete class is interposed
|
||||
|
|
|
@ -175,15 +175,15 @@ InstallXBLField(JSContext* cx,
|
|||
|
||||
// Because of the possibility (due to XBL binding inheritance, because each
|
||||
// XBL binding lives in its own global object) that |this| might be in a
|
||||
// different compartment from the callee (not to mention that this method can
|
||||
// different realm from the callee (not to mention that this method can
|
||||
// be called with an arbitrary |this| regardless of how insane XBL is), and
|
||||
// because in this method we've entered |this|'s compartment (see in
|
||||
// Field[GS]etter where we attempt a cross-compartment call), we must enter
|
||||
// the callee's compartment to access its reserved slots.
|
||||
// because in this method we've entered |this|'s realm (see in
|
||||
// Field[GS]etter where we attempt a cross-realm call), we must enter
|
||||
// the callee's realm to access its reserved slots.
|
||||
nsXBLPrototypeBinding* protoBinding;
|
||||
nsAutoJSString fieldName;
|
||||
{
|
||||
JSAutoCompartment ac(cx, callee);
|
||||
JSAutoRealm ar(cx, callee);
|
||||
|
||||
JS::Rooted<JSObject*> xblProto(cx);
|
||||
xblProto = &js::GetFunctionNativeReserved(callee, XBLPROTO_SLOT).toObject();
|
||||
|
@ -195,10 +195,10 @@ InstallXBLField(JSContext* cx,
|
|||
|
||||
MOZ_ALWAYS_TRUE(JS_ValueToId(cx, name, idp));
|
||||
|
||||
// If a separate XBL scope is being used, the callee is not same-compartment
|
||||
// If a separate XBL scope is being used, the callee is not same-realm
|
||||
// with the xbl prototype, and the object is a cross-compartment wrapper.
|
||||
xblProto = js::UncheckedUnwrap(xblProto);
|
||||
JSAutoCompartment ac2(cx, xblProto);
|
||||
JSAutoRealm ar2(cx, xblProto);
|
||||
JS::Value slotVal = ::JS_GetReservedSlot(xblProto, 0);
|
||||
protoBinding = static_cast<nsXBLPrototypeBinding*>(slotVal.toPrivate());
|
||||
MOZ_ASSERT(protoBinding);
|
||||
|
@ -226,7 +226,7 @@ FieldGetterImpl(JSContext *cx, const JS::CallArgs& args)
|
|||
|
||||
JS::Rooted<JSObject*> thisObj(cx, &thisv.toObject());
|
||||
|
||||
// We should be in the compartment of |this|. If we got here via nativeCall,
|
||||
// We should be in the realm of |this|. If we got here via nativeCall,
|
||||
// |this| is not same-compartment with |callee|, and it's possible via
|
||||
// asymmetric security semantics that |args.calleev()| is actually a security
|
||||
// wrapper. In this case, we know we want to do an unsafe unwrap, and
|
||||
|
@ -262,7 +262,7 @@ FieldSetterImpl(JSContext *cx, const JS::CallArgs& args)
|
|||
|
||||
JS::Rooted<JSObject*> thisObj(cx, &thisv.toObject());
|
||||
|
||||
// We should be in the compartment of |this|. If we got here via nativeCall,
|
||||
// We should be in the realm of |this|. If we got here via nativeCall,
|
||||
// |this| is not same-compartment with |callee|, and it's possible via
|
||||
// asymmetric security semantics that |args.calleev()| is actually a security
|
||||
// wrapper. In this case, we know we want to do an unsafe unwrap, and
|
||||
|
@ -328,7 +328,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx,
|
|||
// see through any SOWs on their targets.
|
||||
|
||||
// First, enter the XBL scope, and compile the functions there.
|
||||
JSAutoCompartment ac(aCx, scopeObject);
|
||||
JSAutoRealm ar(aCx, scopeObject);
|
||||
JS::Rooted<JS::Value> wrappedClassObj(aCx, JS::ObjectValue(*aTargetClassObject));
|
||||
if (!JS_WrapValue(aCx, &wrappedClassObj))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -355,7 +355,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx,
|
|||
|
||||
// Now, re-enter the class object's scope, wrap the getters/setters, and define
|
||||
// them there.
|
||||
JSAutoCompartment ac2(aCx, aTargetClassObject);
|
||||
JSAutoRealm ar2(aCx, aTargetClassObject);
|
||||
if (!JS_WrapObject(aCx, &get) || !JS_WrapObject(aCx, &set)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ nsXBLProtoImplField::InstallField(JS::Handle<JSObject*> aBoundNode,
|
|||
// We are going to run script via EvaluateString, so we need a script entry
|
||||
// point, but as this is XBL related it does not appear in the HTML spec.
|
||||
// We need an actual JSContext to do GetXBLScopeOrGlobal, and it needs to
|
||||
// be in the compartment of globalObject. But we want our XBL execution scope
|
||||
// be in the realm of globalObject. But we want our XBL execution scope
|
||||
// to be our entry global.
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(globalObject)) {
|
||||
|
@ -450,13 +450,13 @@ nsXBLProtoImplField::InstallField(JS::Handle<JSObject*> aBoundNode,
|
|||
if (rv == NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW) {
|
||||
// Report the exception now, before we try using the JSContext for
|
||||
// the JS_DefineUCProperty call. Note that this reports in our current
|
||||
// compartment, which is the XBL scope.
|
||||
// realm, which is the XBL scope.
|
||||
aes.ReportException();
|
||||
}
|
||||
|
||||
// Now, enter the node's compartment, wrap the eval result, and define it on
|
||||
// Now, enter the node's realm, wrap the eval result, and define it on
|
||||
// the bound node.
|
||||
JSAutoCompartment ac2(cx, aBoundNode);
|
||||
JSAutoRealm ar2(cx, aBoundNode);
|
||||
nsDependentString name(mName);
|
||||
if (!JS_WrapValue(cx, &result) ||
|
||||
!::JS_DefineUCProperty(cx, aBoundNode,
|
||||
|
|
|
@ -188,7 +188,7 @@ nsXBLProtoImplMethod::CompileMember(AutoJSAPI& jsapi, const nsString& aClassStr,
|
|||
}
|
||||
|
||||
JSContext *cx = jsapi.cx();
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JSAutoRealm ar(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(),
|
||||
uncompiledMethod->mBodyText.GetLineNumber());
|
||||
|
|
|
@ -189,7 +189,7 @@ nsXBLProtoImplProperty::CompileMember(AutoJSAPI& jsapi, const nsString& aClassSt
|
|||
if (getterText && getterText->GetText()) {
|
||||
nsDependentString getter(getterText->GetText());
|
||||
if (!getter.IsEmpty()) {
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JSAutoRealm ar(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(), getterText->GetLineNumber());
|
||||
nsCString name = NS_LITERAL_CSTRING("get_") + NS_ConvertUTF16toUTF8(mName);
|
||||
|
@ -234,7 +234,7 @@ nsXBLProtoImplProperty::CompileMember(AutoJSAPI& jsapi, const nsString& aClassSt
|
|||
if (setterText && setterText->GetText()) {
|
||||
nsDependentString setter(setterText->GetText());
|
||||
if (!setter.IsEmpty()) {
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JSAutoRealm ar(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(), setterText->GetLineNumber());
|
||||
nsCString name = NS_LITERAL_CSTRING("set_") + NS_ConvertUTF16toUTF8(mName);
|
||||
|
|
|
@ -354,7 +354,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
|
|||
|
||||
// First, enter our XBL scope. This is where the generic handler should have
|
||||
// been compiled, above.
|
||||
JSAutoCompartment ac(cx, scopeObject);
|
||||
JSAutoRealm ar(cx, scopeObject);
|
||||
JS::Rooted<JSObject*> genericHandler(cx, handler.get());
|
||||
bool ok = JS_WrapObject(cx, &genericHandler);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -425,7 +425,7 @@ nsXBLPrototypeHandler::EnsureEventHandler(AutoJSAPI& jsapi, nsAtom* aName,
|
|||
&argNames);
|
||||
|
||||
// Compile the event handler in the xbl scope.
|
||||
JSAutoCompartment ac(cx, scopeObject);
|
||||
JSAutoRealm ar(cx, scopeObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(bindingURI.get(), mLineNumber);
|
||||
|
||||
|
@ -440,7 +440,7 @@ nsXBLPrototypeHandler::EnsureEventHandler(AutoJSAPI& jsapi, nsAtom* aName,
|
|||
|
||||
// Wrap the handler into the content scope, since we're about to stash it
|
||||
// on the DOM window and such.
|
||||
JSAutoCompartment ac2(cx, globalObject);
|
||||
JSAutoRealm ar2(cx, globalObject);
|
||||
bool ok = JS_WrapObject(cx, &handlerFun);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
aHandler.set(handlerFun);
|
||||
|
|
|
@ -3232,7 +3232,7 @@ XULDocument::ExecuteScript(nsXULPrototypeScript *aScript)
|
|||
NS_ENSURE_TRUE(xpc::Scriptability::Get(global).Allowed(), NS_OK);
|
||||
|
||||
JS::ExposeObjectToActiveJS(global);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
// The script is in the compilation scope. Clone it into the target scope
|
||||
// and execute it. On failure, ~AutoScriptEntry will handle exceptions, so
|
||||
|
|
|
@ -387,7 +387,7 @@ XPCShellEnvironment::~XPCShellEnvironment()
|
|||
Rooted<JSObject*> global(cx, GetGlobalObject());
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
JS_SetAllNonReservedSlotsToUndefined(cx, global);
|
||||
}
|
||||
mGlobalHolder.reset();
|
||||
|
@ -448,7 +448,7 @@ XPCShellEnvironment::Init()
|
|||
NS_ERROR("Failed to get global JSObject!");
|
||||
return false;
|
||||
}
|
||||
JSAutoCompartment ac(cx, globalObj);
|
||||
JSAutoRealm ar(cx, globalObj);
|
||||
|
||||
backstagePass->SetGlobalObject(globalObj);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ JSDebugger::AddClass(JS::Handle<JS::Value> global, JSContext* cx)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
if (JS_GetGlobalForObject(cx, obj) != obj) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ class Logging
|
|||
JS::RootedObject obj(cx);
|
||||
obj = shared->objects_.find(id);
|
||||
if (obj) {
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
objDesc = js::ObjectClassName(cx, obj);
|
||||
} else {
|
||||
objDesc = "<dead object>";
|
||||
|
|
|
@ -73,7 +73,7 @@ JavaScriptParent::allowMessage(JSContext* cx)
|
|||
nsIGlobalObject* global = dom::GetIncumbentGlobal();
|
||||
JS::Rooted<JSObject*> jsGlobal(cx, global ? global->GetGlobalJSObject() : nullptr);
|
||||
if (jsGlobal) {
|
||||
JSAutoCompartment ac(cx, jsGlobal);
|
||||
JSAutoRealm ar(cx, jsGlobal);
|
||||
|
||||
if (!xpc::CompartmentPrivate::Get(jsGlobal)->allowCPOWs) {
|
||||
if (ForbidUnsafeBrowserCPOWs() && !isSafe) {
|
||||
|
|
|
@ -536,10 +536,10 @@ JavaScriptShared::findObjectById(JSContext* cx, const ObjectId& objId)
|
|||
// from the other process point to objects in this scope. From there, they
|
||||
// can access objects in other compartments using cross-compartment
|
||||
// wrappers.
|
||||
JSAutoCompartment ac(cx, scopeForTargetObjects());
|
||||
JSAutoRealm ar(cx, scopeForTargetObjects());
|
||||
if (objId.hasXrayWaiver()) {
|
||||
{
|
||||
JSAutoCompartment ac2(cx, obj);
|
||||
JSAutoRealm ar2(cx, obj);
|
||||
obj = js::ToWindowProxyIfWindow(obj);
|
||||
MOZ_ASSERT(obj);
|
||||
}
|
||||
|
|
|
@ -1187,7 +1187,7 @@ WrapperOwner::fromRemoteObjectVariant(JSContext* cx, const RemoteObject& objVar)
|
|||
|
||||
// All CPOWs live in the privileged junk scope.
|
||||
RootedObject junkScope(cx, xpc::PrivilegedJunkScope());
|
||||
JSAutoCompartment ac(cx, junkScope);
|
||||
JSAutoRealm ar(cx, junkScope);
|
||||
RootedValue v(cx, UndefinedValue());
|
||||
// We need to setLazyProto for the getPrototype/getPrototypeIfOrdinary
|
||||
// hooks.
|
||||
|
|
|
@ -162,7 +162,7 @@ const WHITELIST_TYPES: &'static [&'static str] = &[
|
|||
"JS::HandleValue",
|
||||
"JS::HandleValueArray",
|
||||
"JS::IsAcceptableThis",
|
||||
"JSAutoCompartment",
|
||||
"JSAutoRealm",
|
||||
"JSAutoStructuredCloneBuffer",
|
||||
"JSClass",
|
||||
"JSClassOps",
|
||||
|
|
|
@ -3,7 +3,7 @@ use jsapi::root::*;
|
|||
use std::ptr;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AutoCompartment(JSAutoCompartment);
|
||||
pub struct AutoCompartment(JSAutoRealm);
|
||||
|
||||
impl AutoCompartment {
|
||||
#[cfg(feature = "debugmozjs")]
|
||||
|
@ -16,7 +16,7 @@ impl AutoCompartment {
|
|||
};
|
||||
|
||||
AutoCompartment(
|
||||
JSAutoCompartment::new(
|
||||
JSAutoRealm::new(
|
||||
cx,
|
||||
target,
|
||||
&mut notifier as *mut _))
|
||||
|
@ -27,7 +27,7 @@ impl AutoCompartment {
|
|||
target: *mut JSObject)
|
||||
-> AutoCompartment
|
||||
{
|
||||
AutoCompartment(JSAutoCompartment::new(cx, target))
|
||||
AutoCompartment(JSAutoRealm::new(cx, target))
|
||||
}
|
||||
|
||||
#[cfg(feature = "debugmozjs")]
|
||||
|
@ -40,7 +40,7 @@ impl AutoCompartment {
|
|||
};
|
||||
|
||||
AutoCompartment(
|
||||
JSAutoCompartment::new1(
|
||||
JSAutoRealm::new1(
|
||||
cx,
|
||||
target,
|
||||
&mut notifier as *mut _))
|
||||
|
@ -51,6 +51,6 @@ impl AutoCompartment {
|
|||
target: *mut JSScript)
|
||||
-> AutoCompartment
|
||||
{
|
||||
AutoCompartment(JSAutoCompartment::new1(cx, target))
|
||||
AutoCompartment(JSAutoRealm::new1(cx, target))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -609,7 +609,7 @@ impl GCMethods for JS::Value {
|
|||
// ___________________________________________________________________________
|
||||
// Implementations for various things in jsapi.rs
|
||||
|
||||
impl Drop for JSAutoCompartment {
|
||||
impl Drop for JSAutoRealm {
|
||||
fn drop(&mut self) {
|
||||
unsafe { JS_LeaveCompartment(self.cx_, self.oldCompartment_); }
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ DataViewObject::constructWrapped(JSContext* cx, HandleObject bufobj, const CallA
|
|||
|
||||
RootedObject dv(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, unwrapped);
|
||||
JSAutoRealm ar(cx, unwrapped);
|
||||
|
||||
Rooted<ArrayBufferObjectMaybeShared*> buffer(cx);
|
||||
buffer = &unwrapped->as<ArrayBufferObjectMaybeShared>();
|
||||
|
|
|
@ -1694,9 +1694,9 @@ CallObjFunc(RetT(*ObjFunc)(JSContext*, HandleObject), JSContext* cx, HandleObjec
|
|||
RootedObject unwrappedObj(cx);
|
||||
unwrappedObj = UncheckedUnwrap(obj);
|
||||
|
||||
// Enter the compartment of the backing object before calling functions on
|
||||
// Enter the realm of the backing object before calling functions on
|
||||
// it.
|
||||
JSAutoCompartment ac(cx, unwrappedObj);
|
||||
JSAutoRealm ar(cx, unwrappedObj);
|
||||
return ObjFunc(cx, unwrappedObj);
|
||||
}
|
||||
|
||||
|
@ -1711,7 +1711,7 @@ CallObjFunc(bool(*ObjFunc)(JSContext *cx, HandleObject obj, HandleValue key, boo
|
|||
// Always unwrap, in case this is an xray or cross-compartment wrapper.
|
||||
RootedObject unwrappedObj(cx);
|
||||
unwrappedObj = UncheckedUnwrap(obj);
|
||||
JSAutoCompartment ac(cx, unwrappedObj);
|
||||
JSAutoRealm ar(cx, unwrappedObj);
|
||||
|
||||
// If we're working with a wrapped map/set, rewrap the key into the
|
||||
// compartment of the unwrapped map/set.
|
||||
|
@ -1739,7 +1739,7 @@ CallObjFunc(bool(*ObjFunc)(JSContext* cx, Iter kind,
|
|||
{
|
||||
// Retrieve the iterator while in the unwrapped map/set's compartment,
|
||||
// otherwise we'll crash on a compartment assert.
|
||||
JSAutoCompartment ac(cx, unwrappedObj);
|
||||
JSAutoRealm ar(cx, unwrappedObj);
|
||||
if (!ObjFunc(cx, iterType, unwrappedObj, rval))
|
||||
return false;
|
||||
}
|
||||
|
@ -1773,12 +1773,12 @@ JS::MapGet(JSContext* cx, HandleObject obj, HandleValue key, MutableHandleValue
|
|||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, key, rval);
|
||||
|
||||
// Unwrap the object, and enter its compartment. If object isn't wrapped,
|
||||
// Unwrap the object, and enter its realm. If object isn't wrapped,
|
||||
// this is essentially a noop.
|
||||
RootedObject unwrappedObj(cx);
|
||||
unwrappedObj = UncheckedUnwrap(obj);
|
||||
{
|
||||
JSAutoCompartment ac(cx, unwrappedObj);
|
||||
JSAutoRealm ar(cx, unwrappedObj);
|
||||
RootedValue wrappedKey(cx, key);
|
||||
|
||||
// If we passed in a wrapper, wrap our key into its compartment now.
|
||||
|
@ -1809,7 +1809,7 @@ JS::MapSet(JSContext *cx, HandleObject obj, HandleValue key, HandleValue val)
|
|||
RootedObject unwrappedObj(cx);
|
||||
unwrappedObj = UncheckedUnwrap(obj);
|
||||
{
|
||||
JSAutoCompartment ac(cx, unwrappedObj);
|
||||
JSAutoRealm ar(cx, unwrappedObj);
|
||||
|
||||
// If we passed in a wrapper, wrap both key and value before adding to
|
||||
// the map
|
||||
|
@ -1890,7 +1890,7 @@ JS::SetAdd(JSContext *cx, HandleObject obj, HandleValue key)
|
|||
RootedObject unwrappedObj(cx);
|
||||
unwrappedObj = UncheckedUnwrap(obj);
|
||||
{
|
||||
JSAutoCompartment ac(cx, unwrappedObj);
|
||||
JSAutoRealm ar(cx, unwrappedObj);
|
||||
|
||||
// If we passed in a wrapper, wrap key before adding to the set
|
||||
RootedValue wrappedKey(cx, key);
|
||||
|
|
|
@ -1971,7 +1971,7 @@ PerformPromiseAll(JSContext *cx, JS::ForOfIterator& iterator, HandleObject C,
|
|||
// PromiseAllResolveElement.
|
||||
RootedObject valuesArray(cx);
|
||||
if (unwrappedPromiseObj) {
|
||||
JSAutoCompartment ac(cx, unwrappedPromiseObj);
|
||||
JSAutoRealm ar(cx, unwrappedPromiseObj);
|
||||
valuesArray = NewDenseFullyAllocatedArray(cx, 0);
|
||||
} else {
|
||||
valuesArray = NewDenseFullyAllocatedArray(cx, 0);
|
||||
|
@ -2030,10 +2030,10 @@ PerformPromiseAll(JSContext *cx, JS::ForOfIterator& iterator, HandleObject C,
|
|||
}
|
||||
|
||||
// Step h.
|
||||
{ // Scope for the JSAutoCompartment we need to work with valuesArray. We
|
||||
{ // Scope for the JSAutoRealm we need to work with valuesArray. We
|
||||
// mostly do this for performance; we could go ahead and do the define via
|
||||
// a cross-compartment proxy instead...
|
||||
JSAutoCompartment ac(cx, valuesArray);
|
||||
JSAutoRealm ar(cx, valuesArray);
|
||||
indexId = INT_TO_JSID(index);
|
||||
if (!DefineDataProperty(cx, valuesArray, indexId, UndefinedHandleValue))
|
||||
return false;
|
||||
|
|
|
@ -201,7 +201,7 @@ var ignoreFunctions = {
|
|||
// These are a little overzealous -- these destructors *can* GC if they end
|
||||
// up wrapping a pending exception. See bug 898815 for the heavyweight fix.
|
||||
"void js::AutoCompartment::~AutoCompartment(int32)" : true,
|
||||
"void JSAutoCompartment::~JSAutoCompartment(int32)" : true,
|
||||
"void JSAutoRealm::~JSAutoRealm(int32)" : true,
|
||||
|
||||
// Similar to heap snapshot mock classes, and GTests below. This posts a
|
||||
// synchronous runnable when a GTest fails, and we are pretty sure that the
|
||||
|
|
|
@ -53,7 +53,7 @@ jsfuzz_createGlobal(JSContext* cx, JSPrincipals* principals)
|
|||
if (!newGlobal)
|
||||
return nullptr;
|
||||
|
||||
JSAutoCompartment ac(cx, newGlobal);
|
||||
JSAutoRealm ar(cx, newGlobal);
|
||||
|
||||
// Populate the global object with the standard globals like Object and
|
||||
// Array.
|
||||
|
|
|
@ -82,13 +82,13 @@ main(int argc, const char** argv)
|
|||
checkBool(JS::InitSelfHostedCode(cx));
|
||||
JS::SetWarningReporter(cx, reportWarning);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoRequest areq(cx);
|
||||
|
||||
/* Create the global object. */
|
||||
JS::CompartmentOptions options;
|
||||
RootedObject global(cx, checkPtr(JS_NewGlobalObject(cx, &global_class,
|
||||
nullptr, JS::FireOnNewGlobalHook, options)));
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
/* Populate the global object with the standard globals,
|
||||
like Object and Array. */
|
||||
|
|
|
@ -19,7 +19,7 @@ const js::Class OuterWrapperClass = PROXY_CLASS_DEF(
|
|||
static JSObject*
|
||||
wrap(JSContext* cx, JS::HandleObject toWrap, JS::HandleObject target)
|
||||
{
|
||||
JSAutoCompartment ac(cx, target);
|
||||
JSAutoRealm ar(cx, target);
|
||||
JS::RootedObject wrapper(cx, toWrap);
|
||||
if (!JS_WrapObject(cx, &wrapper))
|
||||
return nullptr;
|
||||
|
@ -80,7 +80,7 @@ BEGIN_TEST(testBug604087)
|
|||
|
||||
JS::RootedObject next(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, compartment2);
|
||||
JSAutoRealm ar(cx, compartment2);
|
||||
next = js::Wrapper::New(cx, compartment2, &js::Wrapper::singleton, options);
|
||||
CHECK(next);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ BEGIN_TEST(test_CallNonGenericMethodOnProxy)
|
|||
CHECK(globalB);
|
||||
|
||||
// ...and enter it.
|
||||
JSAutoCompartment enter(cx, globalB);
|
||||
JSAutoRealm enter(cx, globalB);
|
||||
JS::RootedObject customB(cx, JS_NewObject(cx, &CustomClass));
|
||||
CHECK(customB);
|
||||
JS_SetReservedSlot(customB, CUSTOM_SLOT, Int32Value(42));
|
||||
|
|
|
@ -38,7 +38,7 @@ CallTrusted(JSContext* cx, unsigned argc, JS::Value* vp)
|
|||
|
||||
bool ok = false;
|
||||
{
|
||||
JSAutoCompartment ac(cx, trusted_glob);
|
||||
JSAutoRealm ar(cx, trusted_glob);
|
||||
JS::RootedValue funVal(cx, JS::ObjectValue(*trusted_fun));
|
||||
ok = JS_CallFunctionValue(cx, nullptr, funVal, JS::HandleValueArray::empty(), args.rval());
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ BEGIN_TEST(testChromeBuffer)
|
|||
JS::ContextOptions oldOptions = JS::ContextOptionsRef(cx);
|
||||
JS::ContextOptionsRef(cx).setIon(false).setBaseline(false);
|
||||
{
|
||||
JSAutoCompartment ac(cx, trusted_glob);
|
||||
JSAutoRealm ar(cx, trusted_glob);
|
||||
const char* paramName = "x";
|
||||
const char* bytes = "return x ? 1 + trusted(x-1) : 0";
|
||||
JS::CompileOptions options(cx);
|
||||
|
@ -110,7 +110,7 @@ BEGIN_TEST(testChromeBuffer)
|
|||
*/
|
||||
{
|
||||
{
|
||||
JSAutoCompartment ac(cx, trusted_glob);
|
||||
JSAutoRealm ar(cx, trusted_glob);
|
||||
const char* paramName = "untrusted";
|
||||
const char* bytes = "try { "
|
||||
" untrusted(); "
|
||||
|
@ -156,7 +156,7 @@ BEGIN_TEST(testChromeBuffer)
|
|||
|
||||
{
|
||||
{
|
||||
JSAutoCompartment ac(cx, trusted_glob);
|
||||
JSAutoRealm ar(cx, trusted_glob);
|
||||
const char* bytes = "return 42";
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine("", 0);
|
||||
|
|
|
@ -31,7 +31,7 @@ BEGIN_TEST(test_cloneScript)
|
|||
|
||||
// compile for A
|
||||
{
|
||||
JSAutoCompartment a(cx, A);
|
||||
JSAutoRealm a(cx, A);
|
||||
JS::RootedFunction fun(cx);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(__FILE__, 1);
|
||||
|
@ -43,7 +43,7 @@ BEGIN_TEST(test_cloneScript)
|
|||
|
||||
// clone into B
|
||||
{
|
||||
JSAutoCompartment b(cx, B);
|
||||
JSAutoRealm b(cx, B);
|
||||
CHECK(JS::CloneFunctionObject(cx, obj));
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ BEGIN_TEST(test_cloneScriptWithPrincipals)
|
|||
|
||||
// Compile in A
|
||||
{
|
||||
JSAutoCompartment a(cx, A);
|
||||
JSAutoRealm a(cx, A);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(__FILE__, 1);
|
||||
JS::RootedFunction fun(cx);
|
||||
|
@ -131,7 +131,7 @@ BEGIN_TEST(test_cloneScriptWithPrincipals)
|
|||
|
||||
// Clone into B
|
||||
{
|
||||
JSAutoCompartment b(cx, B);
|
||||
JSAutoRealm b(cx, B);
|
||||
JS::RootedObject cloned(cx);
|
||||
CHECK(cloned = JS::CloneFunctionObject(cx, obj));
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ BEGIN_TEST(testDebugger_newScriptHook)
|
|||
JS::FireOnNewGlobalHook, options));
|
||||
CHECK(g);
|
||||
{
|
||||
JSAutoCompartment ae(cx, g);
|
||||
JSAutoRealm ae(cx, g);
|
||||
CHECK(JS_InitStandardClasses(cx, g));
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ bool testIndirectEval(JS::HandleObject scope, const char* code)
|
|||
EXEC("hits = 0;");
|
||||
|
||||
{
|
||||
JSAutoCompartment ae(cx, scope);
|
||||
JSAutoRealm ae(cx, scope);
|
||||
JSString* codestr = JS_NewStringCopyZ(cx, code);
|
||||
CHECK(codestr);
|
||||
JS::RootedValue arg(cx, JS::StringValue(codestr));
|
||||
|
|
|
@ -33,7 +33,7 @@ BEGIN_TEST(testRedefineGlobalEval)
|
|||
if (!g)
|
||||
return false;
|
||||
|
||||
JSAutoCompartment ac(cx, g);
|
||||
JSAutoRealm ar(cx, g);
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
CHECK(JS_GetProperty(cx, g, "Object", &v));
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ BEGIN_TEST(testGCGrayMarking)
|
|||
#endif /* JS_GC_ZEAL */
|
||||
|
||||
CHECK(InitGlobals());
|
||||
JSAutoCompartment ac(cx, global1);
|
||||
JSAutoRealm ar(cx, global1);
|
||||
|
||||
InitGrayRootTracer();
|
||||
|
||||
|
@ -657,7 +657,7 @@ GetCrossCompartmentWrapper(JSObject* target)
|
|||
{
|
||||
MOZ_ASSERT(target->compartment() == global1->compartment());
|
||||
JS::RootedObject obj(cx, target);
|
||||
JSAutoCompartment ac(cx, global2);
|
||||
JSAutoRealm ar(cx, global2);
|
||||
if (!JS_WrapObject(cx, &obj))
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ ConstructCCW(JSContext* cx, const JSClass* globalClasp,
|
|||
|
||||
// Define an object in compartment 2, that is wrapped by a CCW into compartment 1.
|
||||
{
|
||||
JSAutoCompartment ac(cx, global2);
|
||||
JSAutoRealm ar(cx, global2);
|
||||
wrappee.set(JS_NewPlainObject(cx));
|
||||
if (wrappee->compartment() != global2->compartment()) {
|
||||
fprintf(stderr, "wrappee in wrong compartment");
|
||||
|
|
|
@ -46,7 +46,7 @@ eval(const char* asciiChars, bool mutedErrors, JS::MutableHandleValue rval)
|
|||
JS::RootedObject global(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
||||
JS::FireOnNewGlobalHook, globalOptions));
|
||||
CHECK(global);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
CHECK(JS_InitStandardClasses(cx, global));
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ testPreserveJitCode(bool preserveJitCode, unsigned remainingIonScripts)
|
|||
|
||||
RootedObject global(cx, createTestGlobal(preserveJitCode));
|
||||
CHECK(global);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
// The Ion JIT may be unavailable due to --disable-ion or lack of support
|
||||
// for this platform.
|
||||
|
|
|
@ -185,7 +185,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, CloneAndExecuteScript)
|
|||
{
|
||||
JS::RootedObject global2(cx, createGlobal());
|
||||
CHECK(global2);
|
||||
JSAutoCompartment ac(cx, global2);
|
||||
JSAutoRealm ar(cx, global2);
|
||||
CHECK(JS_WrapValue(cx, &fortyTwo));
|
||||
CHECK(JS_SetProperty(cx, global, "val", fortyTwo));
|
||||
JS::RootedValue value2(cx);
|
||||
|
|
|
@ -19,7 +19,7 @@ BEGIN_TEST(testStructuredClone_object)
|
|||
JS::RootedValue v1(cx);
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, g1);
|
||||
JSAutoRealm ar(cx, g1);
|
||||
JS::RootedValue prop(cx, JS::Int32Value(1337));
|
||||
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
|
@ -29,7 +29,7 @@ BEGIN_TEST(testStructuredClone_object)
|
|||
}
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, g2);
|
||||
JSAutoRealm ar(cx, g2);
|
||||
JS::RootedValue v2(cx);
|
||||
|
||||
CHECK(JS_StructuredClone(cx, v1, &v2, nullptr, nullptr));
|
||||
|
@ -57,7 +57,7 @@ BEGIN_TEST(testStructuredClone_string)
|
|||
JS::RootedValue v1(cx);
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, g1);
|
||||
JSAutoRealm ar(cx, g1);
|
||||
JS::RootedValue prop(cx, JS::Int32Value(1337));
|
||||
|
||||
v1 = JS::StringValue(JS_NewStringCopyZ(cx, "Hello World!"));
|
||||
|
@ -66,7 +66,7 @@ BEGIN_TEST(testStructuredClone_string)
|
|||
}
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, g2);
|
||||
JSAutoRealm ar(cx, g2);
|
||||
JS::RootedValue v2(cx);
|
||||
|
||||
CHECK(JS_StructuredClone(cx, v1, &v2, nullptr, nullptr));
|
||||
|
@ -93,7 +93,7 @@ BEGIN_TEST(testStructuredClone_externalArrayBuffer)
|
|||
JS::RootedValue v1(cx);
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, g1);
|
||||
JSAutoRealm ar(cx, g1);
|
||||
|
||||
JS::RootedObject obj(cx, JS_NewExternalArrayBuffer(cx, data.len(), data.contents(),
|
||||
&ExternalData::freeCallback, &data));
|
||||
|
@ -104,7 +104,7 @@ BEGIN_TEST(testStructuredClone_externalArrayBuffer)
|
|||
}
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, g2);
|
||||
JSAutoRealm ar(cx, g2);
|
||||
JS::RootedValue v2(cx);
|
||||
|
||||
CHECK(JS_StructuredClone(cx, v1, &v2, nullptr, nullptr));
|
||||
|
@ -269,7 +269,7 @@ BEGIN_TEST(testStructuredClone_SavedFrame)
|
|||
JS::RootedObject g(cx, JS_NewGlobalObject(cx, getGlobalClass(), pp->principals,
|
||||
JS::FireOnNewGlobalHook, options));
|
||||
CHECK(g);
|
||||
JSAutoCompartment ac(cx, g);
|
||||
JSAutoRealm ar(cx, g);
|
||||
|
||||
CHECK(js::DefineTestingFunctions(cx, g, false, false));
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ BEGIN_TEST(test_ubiNodeZone)
|
|||
{
|
||||
// ... and then enter global2's zone and create a string and script
|
||||
// there, too.
|
||||
JSAutoCompartment ac(cx, global2);
|
||||
JSAutoRealm ar(cx, global2);
|
||||
|
||||
RootedString string2(cx, JS_NewStringCopyZ(cx, "A million household uses!"));
|
||||
CHECK(string2);
|
||||
|
@ -129,14 +129,14 @@ BEGIN_TEST(test_ubiNodeCompartment)
|
|||
|
||||
JS::CompileOptions options(cx);
|
||||
|
||||
// Create a script in the original compartment...
|
||||
// Create a script in the original realm...
|
||||
RootedScript script1(cx);
|
||||
CHECK(JS::Compile(cx, options, "", 0, &script1));
|
||||
|
||||
{
|
||||
// ... and then enter global2's compartment and create a script
|
||||
// ... and then enter global2's realm and create a script
|
||||
// there, too.
|
||||
JSAutoCompartment ac(cx, global2);
|
||||
JSAutoRealm ar(cx, global2);
|
||||
|
||||
RootedScript script2(cx);
|
||||
CHECK(JS::Compile(cx, options, "", 0, &script2));
|
||||
|
|
|
@ -86,7 +86,7 @@ BEGIN_TEST(testWeakMap_keyDelegates)
|
|||
|
||||
JS::RootedObject delegateRoot(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, delegate);
|
||||
JSAutoRealm ar(cx, delegate);
|
||||
delegateRoot = JS_NewPlainObject(cx);
|
||||
CHECK(delegateRoot);
|
||||
JS::RootedValue delegateValue(cx, JS::ObjectValue(*delegate));
|
||||
|
@ -185,13 +185,13 @@ JSObject* newCCW(JS::HandleObject sourceZone, JS::HandleObject destZone)
|
|||
*/
|
||||
JS::RootedObject object(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, destZone);
|
||||
JSAutoRealm ar(cx, destZone);
|
||||
object = JS_NewPlainObject(cx);
|
||||
if (!object)
|
||||
return nullptr;
|
||||
}
|
||||
{
|
||||
JSAutoCompartment ac(cx, sourceZone);
|
||||
JSAutoRealm ar(cx, sourceZone);
|
||||
if (!JS_WrapObject(cx, &object))
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ JSObject* JSAPITest::createGlobal(JSPrincipals* principals)
|
|||
if (!newGlobal)
|
||||
return nullptr;
|
||||
|
||||
JSAutoCompartment ac(cx, newGlobal);
|
||||
JSAutoRealm ar(cx, newGlobal);
|
||||
|
||||
// Populate the global object with the standard globals like Object and
|
||||
// Array.
|
||||
|
|
|
@ -693,8 +693,8 @@ JS_LeaveCompartment(JSContext* cx, JSCompartment* oldCompartment)
|
|||
cx->leaveCompartment(oldCompartment);
|
||||
}
|
||||
|
||||
JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSObject* target
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
JSAutoRealm::JSAutoRealm(JSContext* cx, JSObject* target
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
: cx_(cx),
|
||||
oldCompartment_(cx->compartment())
|
||||
{
|
||||
|
@ -703,8 +703,8 @@ JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSObject* target
|
|||
cx_->enterCompartmentOf(target);
|
||||
}
|
||||
|
||||
JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSScript* target
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
JSAutoRealm::JSAutoRealm(JSContext* cx, JSScript* target
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
: cx_(cx),
|
||||
oldCompartment_(cx->compartment())
|
||||
{
|
||||
|
@ -713,7 +713,7 @@ JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSScript* target
|
|||
cx_->enterCompartmentOf(target);
|
||||
}
|
||||
|
||||
JSAutoCompartment::~JSAutoCompartment()
|
||||
JSAutoRealm::~JSAutoRealm()
|
||||
{
|
||||
cx_->leaveCompartment(oldCompartment_);
|
||||
}
|
||||
|
|
|
@ -1249,25 +1249,25 @@ extern JS_PUBLIC_API(bool)
|
|||
JS_RefreshCrossCompartmentWrappers(JSContext* cx, JS::Handle<JSObject*> obj);
|
||||
|
||||
/*
|
||||
* At any time, a JSContext has a current (possibly-nullptr) compartment.
|
||||
* Compartments are described in:
|
||||
* At any time, a JSContext has a current (possibly-nullptr) realm.
|
||||
* Realms are described in:
|
||||
*
|
||||
* developer.mozilla.org/en-US/docs/SpiderMonkey/SpiderMonkey_compartments
|
||||
*
|
||||
* The current compartment of a context may be changed. The preferred way to do
|
||||
* this is with JSAutoCompartment:
|
||||
* The current realm of a context may be changed. The preferred way to do
|
||||
* this is with JSAutoRealm:
|
||||
*
|
||||
* void foo(JSContext* cx, JSObject* obj) {
|
||||
* // in some compartment 'c'
|
||||
* // in some realm 'r'
|
||||
* {
|
||||
* JSAutoCompartment ac(cx, obj); // constructor enters
|
||||
* // in the compartment of 'obj'
|
||||
* JSAutoRealm ar(cx, obj); // constructor enters
|
||||
* // in the realm of 'obj'
|
||||
* } // destructor leaves
|
||||
* // back in compartment 'c'
|
||||
* // back in realm 'r'
|
||||
* }
|
||||
*
|
||||
* For more complicated uses that don't neatly fit in a C++ stack frame, the
|
||||
* compartment can entered and left using separate function calls:
|
||||
* realm can be entered and left using separate function calls:
|
||||
*
|
||||
* void foo(JSContext* cx, JSObject* obj) {
|
||||
* // in 'oldCompartment'
|
||||
|
@ -1282,20 +1282,18 @@ JS_RefreshCrossCompartmentWrappers(JSContext* cx, JS::Handle<JSObject*> obj);
|
|||
* JS_EnterCompartment call may be passed as the 'oldCompartment' argument of
|
||||
* the corresponding JS_LeaveCompartment call.
|
||||
*
|
||||
* Entering a compartment roots the compartment and its global object for the
|
||||
* lifetime of the JSAutoCompartment.
|
||||
* Entering a realm roots the realm and its global object for the lifetime of
|
||||
* the JSAutoRealm.
|
||||
*/
|
||||
|
||||
class MOZ_RAII JS_PUBLIC_API(JSAutoCompartment)
|
||||
class MOZ_RAII JS_PUBLIC_API(JSAutoRealm)
|
||||
{
|
||||
JSContext* cx_;
|
||||
JSCompartment* oldCompartment_;
|
||||
public:
|
||||
JSAutoCompartment(JSContext* cx, JSObject* target
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
JSAutoCompartment(JSContext* cx, JSScript* target
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
~JSAutoCompartment();
|
||||
JSAutoRealm(JSContext* cx, JSObject* target MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
JSAutoRealm(JSContext* cx, JSScript* target MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
~JSAutoRealm();
|
||||
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
|
|
@ -851,7 +851,7 @@ FormatFrame(JSContext* cx, const FrameIter& iter, JS::UniqueChars&& inBuf, int n
|
|||
jsbytecode* pc = iter.pc();
|
||||
|
||||
RootedObject envChain(cx, iter.environmentChain(cx));
|
||||
JSAutoCompartment ac(cx, envChain);
|
||||
JSAutoRealm ar(cx, envChain);
|
||||
|
||||
const char* filename = script->filename();
|
||||
unsigned lineno = PCToLineNumber(script, pc);
|
||||
|
|
|
@ -726,7 +726,7 @@ ShellInterruptCallback(JSContext* cx)
|
|||
if (sc->haveInterruptFunc) {
|
||||
bool wasAlreadyThrowing = cx->isExceptionPending();
|
||||
JS::AutoSaveExceptionState savedExc(cx);
|
||||
JSAutoCompartment ac(cx, &sc->interruptFunc.toObject());
|
||||
JSAutoRealm ar(cx, &sc->interruptFunc.toObject());
|
||||
RootedValue rval(cx);
|
||||
|
||||
// Report any exceptions thrown by the JS interrupt callback, but do
|
||||
|
@ -1944,7 +1944,7 @@ Evaluate(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
RootedScript script(cx);
|
||||
|
||||
{
|
||||
|
@ -2013,7 +2013,7 @@ Evaluate(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
if (!JS_ExecuteScript(cx, envChain, script, args.rval())) {
|
||||
if (catchTermination && !JS_IsExceptionPending(cx)) {
|
||||
JSAutoCompartment ac1(cx, callerGlobal);
|
||||
JSAutoRealm ar1(cx, callerGlobal);
|
||||
JSString* str = JS_NewStringCopyZ(cx, "terminated");
|
||||
if (!str)
|
||||
return false;
|
||||
|
@ -3017,7 +3017,7 @@ DisassembleToSprinter(JSContext* cx, unsigned argc, Value* vp, Sprinter* sprinte
|
|||
/* Without arguments, disassemble the current script. */
|
||||
RootedScript script(cx, GetTopScript(cx));
|
||||
if (script) {
|
||||
JSAutoCompartment ac(cx, script);
|
||||
JSAutoRealm ar(cx, script);
|
||||
if (!Disassemble(cx, script, p.lines, sprinter))
|
||||
return false;
|
||||
if (!SrcNotes(cx, script, sprinter))
|
||||
|
@ -3280,12 +3280,12 @@ Clone(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
RootedObject funobj(cx);
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
RootedObject obj(cx, args[0].isPrimitive() ? nullptr : &args[0].toObject());
|
||||
|
||||
if (obj && obj->is<CrossCompartmentWrapperObject>()) {
|
||||
obj = UncheckedUnwrap(obj);
|
||||
ac.emplace(cx, obj);
|
||||
ar.emplace(cx, obj);
|
||||
args[0].setObject(*obj);
|
||||
}
|
||||
if (obj && obj->is<JSFunction>()) {
|
||||
|
@ -3432,7 +3432,7 @@ NewSandbox(JSContext* cx, bool lazy)
|
|||
return nullptr;
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
if (!lazy && !JS_InitStandardClasses(cx, obj))
|
||||
return nullptr;
|
||||
|
||||
|
@ -3498,12 +3498,12 @@ EvalInContext(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
DescribeScriptedCaller(cx, &filename, &lineno);
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
unsigned flags;
|
||||
JSObject* unwrapped = UncheckedUnwrap(sobj, true, &flags);
|
||||
if (flags & Wrapper::CROSS_COMPARTMENT) {
|
||||
sobj = unwrapped;
|
||||
ac.emplace(cx, sobj);
|
||||
ar.emplace(cx, sobj);
|
||||
}
|
||||
|
||||
sobj = ToWindowIfWindowProxy(sobj);
|
||||
|
@ -3601,7 +3601,7 @@ WorkerMain(void* arg)
|
|||
EnvironmentPreparer environmentPreparer(cx);
|
||||
|
||||
do {
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoRequest areq(cx);
|
||||
|
||||
JS::CompartmentOptions compartmentOptions;
|
||||
SetStandardCompartmentOptions(compartmentOptions);
|
||||
|
@ -3610,7 +3610,7 @@ WorkerMain(void* arg)
|
|||
if (!global)
|
||||
break;
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine("<string>", 1)
|
||||
|
@ -5100,7 +5100,7 @@ DecompileThisScript(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, iter.script());
|
||||
JSAutoRealm ar(cx, iter.script());
|
||||
|
||||
RootedScript script(cx, iter.script());
|
||||
JSString* result = JS_DecompileScript(cx, script);
|
||||
|
@ -7580,11 +7580,11 @@ PrintStackTrace(JSContext* cx, HandleValue exn)
|
|||
if (!exn.isObject())
|
||||
return false;
|
||||
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
RootedObject exnObj(cx, &exn.toObject());
|
||||
if (IsCrossCompartmentWrapper(exnObj)) {
|
||||
exnObj = UncheckedUnwrap(exnObj);
|
||||
ac.emplace(cx, exnObj);
|
||||
ar.emplace(cx, exnObj);
|
||||
}
|
||||
|
||||
// Ignore non-ErrorObject thrown by |throw| statement.
|
||||
|
@ -8210,7 +8210,7 @@ NewGlobalObject(JSContext* cx, JS::CompartmentOptions& options,
|
|||
return nullptr;
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, glob);
|
||||
JSAutoRealm ar(cx, glob);
|
||||
|
||||
#ifndef LAZY_STANDARD_CLASSES
|
||||
if (!JS_InitStandardClasses(cx, glob))
|
||||
|
@ -8803,7 +8803,7 @@ Shell(JSContext* cx, OptionParser* op, char** envp)
|
|||
if (op->getBoolOption("no-cgc"))
|
||||
nocgc.emplace(cx);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoRequest areq(cx);
|
||||
|
||||
if (op->getBoolOption("fuzzing-safe"))
|
||||
fuzzingSafe = true;
|
||||
|
@ -8819,7 +8819,7 @@ Shell(JSContext* cx, OptionParser* op, char** envp)
|
|||
if (!glob)
|
||||
return 1;
|
||||
|
||||
JSAutoCompartment ac(cx, glob);
|
||||
JSAutoRealm ar(cx, glob);
|
||||
|
||||
ShellContext* sc = GetShellContext(cx);
|
||||
int result = EXIT_SUCCESS;
|
||||
|
|
|
@ -9295,7 +9295,7 @@ DebuggerObject::promiseDependentPromisesGetter(JSContext* cx, unsigned argc, Val
|
|||
|
||||
Rooted<GCVector<Value>> values(cx, GCVector<Value>(cx));
|
||||
{
|
||||
JSAutoCompartment ac(cx, promise);
|
||||
JSAutoRealm ar(cx, promise);
|
||||
if (!promise->dependentPromises(cx, &values))
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1152,7 +1152,7 @@ JS_CopyPropertyFrom(JSContext* cx, HandleId id, HandleObject target,
|
|||
desc.attributesRef() &= ~JSPROP_PERMANENT;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, target);
|
||||
JSAutoRealm ar(cx, target);
|
||||
cx->markId(id);
|
||||
RootedId wrappedId(cx, id);
|
||||
if (!cx->compartment()->wrap(cx, &desc))
|
||||
|
@ -1164,7 +1164,7 @@ JS_CopyPropertyFrom(JSContext* cx, HandleId id, HandleObject target,
|
|||
JS_FRIEND_API(bool)
|
||||
JS_CopyPropertiesFrom(JSContext* cx, HandleObject target, HandleObject obj)
|
||||
{
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
|
||||
AutoIdVector props(cx);
|
||||
if (!GetPropertyKeys(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, &props))
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче