mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 887334 - Add a JSAutoCompartment to AutoCxPusher. r=luke,gabor
This should hopefully take care of any cases where consumers expect to be in the default compartment.
This commit is contained in:
parent
e90537d5c6
commit
a93493b71d
@ -125,24 +125,29 @@ AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull) : mScriptIsRunning(fal
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
// Enter a request for the duration that the cx is on the stack if non-null.
|
||||
// NB: We call UnmarkGrayContext so that this can obsolete the need for the
|
||||
// old XPCAutoRequest as well.
|
||||
if (cx) {
|
||||
mAutoRequest.construct(cx);
|
||||
xpc_UnmarkGrayContext(cx);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
mPushedContext = cx;
|
||||
mCompartmentDepthOnEntry = cx ? js::GetEnterCompartmentDepth(cx) : 0;
|
||||
#endif
|
||||
|
||||
// Enter a request and a compartment for the duration that the cx is on the
|
||||
// stack if non-null.
|
||||
//
|
||||
// NB: We call UnmarkGrayContext so that this can obsolete the need for the
|
||||
// old XPCAutoRequest as well.
|
||||
if (cx) {
|
||||
mAutoRequest.construct(cx);
|
||||
if (js::GetDefaultGlobalForContext(cx))
|
||||
mAutoCompartment.construct(cx, js::GetDefaultGlobalForContext(cx));
|
||||
xpc_UnmarkGrayContext(cx);
|
||||
}
|
||||
}
|
||||
|
||||
NS_EXPORT
|
||||
AutoCxPusher::~AutoCxPusher()
|
||||
{
|
||||
// Leave the request before popping.
|
||||
// Leave the compartment and request before popping.
|
||||
mAutoCompartment.destroyIfConstructed();
|
||||
mAutoRequest.destroyIfConstructed();
|
||||
|
||||
// When we push a context, we may save the frame chain and pretend like we
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
|
||||
private:
|
||||
mozilla::Maybe<JSAutoRequest> mAutoRequest;
|
||||
mozilla::Maybe<JSAutoCompartment> mAutoCompartment;
|
||||
nsCOMPtr<nsIScriptContext> mScx;
|
||||
bool mScriptIsRunning;
|
||||
#ifdef DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user