Bug 981796 - Don't assume that the active global is our global. r=smaug
Without this, grabbing another window's showModalDialog function and calling
it with this being a second window asserts.
MozReview-Commit-ID: GvGUClFwdoN
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10114,18 +10114,22 @@ nsGlobalWindow::ShowModalDialog(JSContex
nsCOMPtr<nsIVariant> retVal =
ShowModalDialog(aUrl, args, aOptions, aSubjectPrincipal, aError);
if (aError.Failed()) {
return;
}
JS::Rooted<JS::Value> result(aCx);
if (retVal) {
+ JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
+ if (!global) {
+ global = FastGetGlobalJSObject();
+ }
aError = nsContentUtils::XPConnect()->VariantToJS(aCx,
- FastGetGlobalJSObject(),
+ global,
retVal, aRetval);
} else {
aRetval.setNull();
}
}
class ChildCommandDispatcher : public Runnable
{