Bug 1276309 part 2. Stop depending on the exact value of nsIScriptContext::GetNativeContext in nsGlobalWindow::FinalClose. r=smaug

This commit is contained in:
Boris Zbarsky 2016-05-27 20:26:56 -04:00
Родитель 7d23da273d
Коммит 84b2945de3
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -8633,13 +8633,14 @@ nsGlobalWindow::FinalClose()
// broken addons. The chrome tests in toolkit/mozapps/downloads are a good
// testing ground.
//
// In particular, if |win|'s JSContext is at the top of the stack, we must
// In particular, if some inner of |win| is the entry global, we must
// complete _two_ round-trips to the event loop before the call to
// ReallyCloseWindow. This allows setTimeout handlers that are set after
// FinalClose() is called to run before the window is torn down.
bool indirect = GetContextInternal() && // Occasionally null. See bug 877390.
(nsContentUtils::GetCurrentJSContext() ==
GetContextInternal()->GetNativeContext());
nsCOMPtr<nsPIDOMWindowInner> entryWindow =
do_QueryInterface(GetEntryGlobal());
bool indirect =
entryWindow && entryWindow->GetOuterWindow() == this->AsOuter();
if (NS_FAILED(nsCloseEvent::PostCloseEvent(this, indirect))) {
ReallyCloseWindow();
} else {