Skip to content
This repository was archived by the owner on Aug 4, 2022. It is now read-only.

Commit e0ebf0f

Browse files
committed
Bug 1541600 part 3. Stop using AutoJSContext in GetStateObject. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D26225
1 parent bd1ec72 commit e0ebf0f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

dom/base/Document.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9168,15 +9168,13 @@ nsresult Document::GetStateObject(nsIVariant** aState) {
91689168
// current state object.
91699169

91709170
if (!mStateObjectCached && mStateObjectContainer) {
9171-
AutoJSContext cx;
9172-
nsIGlobalObject* sgo = GetScopeObject();
9173-
NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
9174-
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
9175-
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
9176-
JSAutoRealm ar(cx, global);
9177-
9171+
AutoJSAPI jsapi;
9172+
// Init with null is "OK" in the sense that it will just fail.
9173+
if (!jsapi.Init(GetScopeObject())) {
9174+
return NS_ERROR_UNEXPECTED;
9175+
}
91789176
mStateObjectContainer->DeserializeToVariant(
9179-
cx, getter_AddRefs(mStateObjectCached));
9177+
jsapi.cx(), getter_AddRefs(mStateObjectCached));
91809178
}
91819179

91829180
NS_IF_ADDREF(*aState = mStateObjectCached);

0 commit comments

Comments
 (0)