mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 733606 - Only call FinishInitForWrappedGlobal when we just created a global. r=mrbkap
Without this patch, we call the above when restoring things out of the bfcache, which is bad. It must be called exactly once.
This commit is contained in:
parent
4f3a1a6f62
commit
e6b5d5e506
@ -1950,6 +1950,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
nsGlobalWindow *currentInner = GetCurrentInnerWindowInternal();
|
||||
|
||||
nsRefPtr<nsGlobalWindow> newInnerWindow;
|
||||
bool createdInnerWindow = false;
|
||||
|
||||
bool thisChrome = IsChromeWindow();
|
||||
|
||||
@ -2028,6 +2029,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
"Failed to get script global and holder");
|
||||
|
||||
mCreatingInnerWindow = false;
|
||||
createdInnerWindow = true;
|
||||
Thaw();
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -2108,6 +2110,19 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
}
|
||||
}
|
||||
|
||||
// If we created a new inner window above, we need to do the last little bit
|
||||
// of initialization now that the dust has settled.
|
||||
if (createdInnerWindow) {
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
nsresult rv = xpc->GetWrappedNativeOfJSObject(cx, newInnerWindow->mJSObject,
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
|
||||
rv = wrapper->FinishInitForWrappedGlobal();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, mJSObject)) {
|
||||
NS_ERROR("unable to enter a compartment");
|
||||
|
@ -2314,19 +2314,11 @@ nsresult
|
||||
nsJSContext::SetOuterObject(JSObject* aOuterObject)
|
||||
{
|
||||
// Force our context's global object to be the outer.
|
||||
// NB: JS_SetGlobalObject sets mContext->compartment.
|
||||
JS_SetGlobalObject(mContext, aOuterObject);
|
||||
|
||||
// NB: JS_SetGlobalObject sets mContext->compartment.
|
||||
// Set up the prototype for the outer object.
|
||||
JSObject *inner = JS_GetParent(aOuterObject);
|
||||
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
nsresult rv = xpc->GetWrappedNativeOfJSObject(mContext, inner,
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
|
||||
|
||||
wrapper->FinishInitForWrappedGlobal();
|
||||
JS_SetPrototype(mContext, aOuterObject, JS_GetPrototype(inner));
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user