Skip to content

Commit b79494e

Browse files
committed
Bug 1479363 part 2 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in dom/bindings. r=bz
1 parent 3bbc9aa commit b79494e

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

dom/bindings/BindingUtils.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ ResolvePrototypeOrConstructor(JSContext* cx, JS::Handle<JSObject*> wrapper,
16521652
{
16531653
JS::Rooted<JSObject*> global(cx, JS::GetNonCCWObjectGlobal(obj));
16541654
{
1655-
JSAutoRealmAllowCCW ar(cx, global);
1655+
JSAutoRealm ar(cx, global);
16561656
ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
16571657
// This function is called when resolving the "constructor" and "prototype"
16581658
// properties of Xrays for DOM prototypes and constructors respectively.
@@ -2297,7 +2297,7 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg, ErrorResult& aErr
22972297
domClass->mGetAssociatedGlobal(aCx, aObj));
22982298
MOZ_ASSERT(JS_IsGlobalObject(newParent));
22992299

2300-
JSAutoRealmAllowCCW oldAr(aCx, oldParent);
2300+
JSAutoRealm oldAr(aCx, oldParent);
23012301

23022302
JS::Compartment* oldCompartment = js::GetObjectCompartment(oldParent);
23032303
JS::Compartment* newCompartment = js::GetObjectCompartment(newParent);
@@ -2317,7 +2317,7 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg, ErrorResult& aErr
23172317
expandoObject = DOMProxyHandler::GetAndClearExpandoObject(aObj);
23182318
}
23192319

2320-
JSAutoRealmAllowCCW newAr(aCx, newParent);
2320+
JSAutoRealm newAr(aCx, newParent);
23212321

23222322
// First we clone the reflector. We get a copy of its properties and clone its
23232323
// expando chain.
@@ -3564,7 +3564,7 @@ GetMaplikeSetlikeBackingObject(JSContext* aCx, JS::Handle<JSObject*> aObj,
35643564
// Since backing object access can happen in non-originating realms,
35653565
// make sure to create the backing object in reflector realm.
35663566
{
3567-
JSAutoRealmAllowCCW ar(aCx, reflector);
3567+
JSAutoRealm ar(aCx, reflector);
35683568
JS::Rooted<JSObject*> newBackingObj(aCx);
35693569
newBackingObj.set(Method(aCx));
35703570
if (NS_WARN_IF(!newBackingObj)) {
@@ -3787,7 +3787,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
37873787
// objects as constructors? Of course it's not clear that the spec check
37883788
// makes sense to start with: https://github.com/whatwg/html/issues/3575
37893789
{
3790-
JSAutoRealmAllowCCW ar(aCx, newTarget);
3790+
JSAutoRealm ar(aCx, newTarget);
37913791
JS::Handle<JSObject*> constructor =
37923792
GetPerInterfaceObjectHandle(aCx, aConstructorId, aCreator,
37933793
true);
@@ -3822,7 +3822,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
38223822
// function should be HTMLElement or XULElement. We want to get the actual
38233823
// functions to compare to from our global's realm, not the caller
38243824
// realm.
3825-
JSAutoRealmAllowCCW ar(aCx, global.Get());
3825+
JSAutoRealm ar(aCx, global.Get());
38263826

38273827
JS::Rooted<JSObject*> constructor(aCx);
38283828
if (ns == kNameSpaceID_XUL) {
@@ -3877,7 +3877,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
38773877

38783878
// We want to get the constructor from our global's realm, not the
38793879
// caller realm.
3880-
JSAutoRealmAllowCCW ar(aCx, global.Get());
3880+
JSAutoRealm ar(aCx, global.Get());
38813881
JS::Rooted<JSObject*> constructor(aCx, cb(aCx));
38823882
if (!constructor) {
38833883
return false;
@@ -3904,7 +3904,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
39043904
// whose target is not same-realm with the proxy, or bound functions, etc).
39053905
// https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
39063906
{
3907-
JSAutoRealmAllowCCW ar(aCx, newTarget);
3907+
JSAutoRealm ar(aCx, newTarget);
39083908
desiredProto = GetPerInterfaceObjectHandle(aCx, aProtoId, aCreator, true);
39093909
if (!desiredProto) {
39103910
return false;
@@ -3929,7 +3929,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
39293929
// Now we go to construct an element. We want to do this in global's
39303930
// realm, not caller realm (the normal constructor behavior),
39313931
// just in case those elements create JS things.
3932-
JSAutoRealmAllowCCW ar(aCx, global.Get());
3932+
JSAutoRealm ar(aCx, global.Get());
39333933

39343934
RefPtr<NodeInfo> nodeInfo =
39353935
doc->NodeInfoManager()->GetNodeInfo(definition->mLocalName,
@@ -3972,7 +3972,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
39723972
JS::Rooted<JSObject*> reflector(aCx, element->GetWrapper());
39733973
if (reflector) {
39743974
// reflector might be in different realm.
3975-
JSAutoRealmAllowCCW ar(aCx, reflector);
3975+
JSAutoRealm ar(aCx, reflector);
39763976
JS::Rooted<JSObject*> givenProto(aCx, desiredProto);
39773977
if (!JS_WrapObject(aCx, &givenProto) ||
39783978
!JS_SetPrototype(aCx, reflector, givenProto)) {
@@ -3987,7 +3987,7 @@ HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
39873987
// Tail end of step 8 and step 13: returning the element. We want to do this
39883988
// part in the global's realm, though in practice it won't matter much
39893989
// because Element always knows which realm it should be created in.
3990-
JSAutoRealmAllowCCW ar(aCx, global.Get());
3990+
JSAutoRealm ar(aCx, global.Get());
39913991
if (!js::IsObjectInContextCompartment(desiredProto, aCx) &&
39923992
!JS_WrapObject(aCx, &desiredProto)) {
39933993
return false;
@@ -4009,7 +4009,7 @@ AssertReflectorHasGivenProto(JSContext* aCx, JSObject* aReflector,
40094009
}
40104010

40114011
JS::Rooted<JSObject*> reflector(aCx, aReflector);
4012-
JSAutoRealmAllowCCW ar(aCx, reflector);
4012+
JSAutoRealm ar(aCx, reflector);
40134013
JS::Rooted<JSObject*> reflectorProto(aCx);
40144014
bool ok = JS_GetPrototype(aCx, reflector, &reflectorProto);
40154015
MOZ_ASSERT(ok);

dom/bindings/BindingUtils.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ DoGetOrCreateDOMReflector(JSContext* cx, T* value,
11171117

11181118
if (wrapBehavior == eDontWrapIntoContextCompartment) {
11191119
if (TypeNeedsOuterization<T>::value) {
1120-
JSAutoRealmAllowCCW ar(cx, obj);
1120+
JSAutoRealm ar(cx, obj);
11211121
return TryToOuterize(rval);
11221122
}
11231123

@@ -1181,9 +1181,9 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
11811181
// We try to wrap in the realm of the underlying object of "scope"
11821182
JS::Rooted<JSObject*> obj(cx);
11831183
{
1184-
// scope for the JSAutoRealmAllowCCW so that we restore the realm
1184+
// scope for the JSAutoRealm so that we restore the realm
11851185
// before we call JS_WrapValue.
1186-
Maybe<JSAutoRealmAllowCCW> ar;
1186+
Maybe<JSAutoRealm> ar;
11871187
// Maybe<Handle> doesn't so much work, and in any case, adding
11881188
// more Maybe (one for a Rooted and one for a Handle) adds more
11891189
// code (and branches!) than just adding a single rooted.
@@ -1234,9 +1234,9 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
12341234
// We try to wrap in the realm of the underlying object of "scope"
12351235
JS::Rooted<JSObject*> obj(cx);
12361236
{
1237-
// scope for the JSAutoRealmAllowCCW so that we restore the realm
1237+
// scope for the JSAutoRealm so that we restore the realm
12381238
// before we call JS_WrapValue.
1239-
Maybe<JSAutoRealmAllowCCW> ar;
1239+
Maybe<JSAutoRealm> ar;
12401240
// Maybe<Handle> doesn't so much work, and in any case, adding
12411241
// more Maybe (one for a Rooted and one for a Handle) adds more
12421242
// code (and branches!) than just adding a single rooted.
@@ -2416,7 +2416,7 @@ XrayGetNativeProto(JSContext* cx, JS::Handle<JSObject*> obj,
24162416
{
24172417
JS::Rooted<JSObject*> global(cx, JS::GetNonCCWObjectGlobal(obj));
24182418
{
2419-
JSAutoRealmAllowCCW ar(cx, global);
2419+
JSAutoRealm ar(cx, global);
24202420
const DOMJSClass* domClass = GetDOMClass(obj);
24212421
if (domClass) {
24222422
ProtoHandleGetter protoGetter = domClass->mGetProto;
@@ -3087,7 +3087,7 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
30873087
return false;
30883088
}
30893089

3090-
JSAutoRealmAllowCCW ar(aCx, aGlobal);
3090+
JSAutoRealm ar(aCx, aGlobal);
30913091

30923092
{
30933093
js::SetReservedSlot(aGlobal, DOM_OBJECT_SLOT, JS::PrivateValue(aNative));

dom/bindings/SimpleGlobalObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ SimpleGlobalObject::Create(GlobalType globalType, JS::Handle<JS::Value> proto)
134134
return nullptr;
135135
}
136136

137-
JSAutoRealmAllowCCW ar(cx, global);
137+
JSAutoRealm ar(cx, global);
138138

139139
// It's important to create the nsIGlobalObject for our new global before we
140140
// start trying to wrap things like the prototype into its compartment,

dom/bindings/TypedArray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ struct TypedArray
172172
Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
173173
const T* data = nullptr) {
174174
JS::Rooted<JSObject*> creatorWrapper(cx);
175-
Maybe<JSAutoRealmAllowCCW> ar;
175+
Maybe<JSAutoRealm> ar;
176176
if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) {
177177
ar.emplace(cx, creatorWrapper);
178178
}

dom/bindings/WebIDLGlobalNameHash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ WebIDLGlobalNameHash::DefineIfEnabled(JSContext* aCx,
309309
if (xpc::WrapperFactory::IsXrayWrapper(aObj)) {
310310
JS::Rooted<JSObject*> constructor(aCx);
311311
{
312-
JSAutoRealmAllowCCW ar(aCx, global);
312+
JSAutoRealm ar(aCx, global);
313313
constructor = FindNamedConstructorForXray(aCx, aId, entry);
314314
}
315315
if (NS_WARN_IF(!constructor)) {

0 commit comments

Comments
 (0)