Bug 1181916. Notify the debugger's onNewGlobalObject hook off a scriptrunner. r=bholley

This commit is contained in:
Boris Zbarsky 2015-07-14 15:28:57 -04:00
parent 9cda36f8a0
commit 039f980b87
2 changed files with 20 additions and 5 deletions

View File

@ -2709,11 +2709,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// We wait to fire the debugger hook until the window is all set up and hooked // We wait to fire the debugger hook until the window is all set up and hooked
// up with the outer. See bug 969156. // up with the outer. See bug 969156.
if (createdInnerWindow) { if (createdInnerWindow) {
// AutoEntryScript required to invoke debugger hook, which is a nsContentUtils::AddScriptRunner(
// Gecko-specific concept at present. NS_NewRunnableMethod(newInnerWindow,
AutoEntryScript aes(newInnerWindow, "nsGlobalWindow report new global"); &nsGlobalWindow::FireOnNewGlobalObject));
JS::Rooted<JSObject*> global(aes.cx(), newInnerWindow->GetWrapper());
JS_FireOnNewGlobalObject(aes.cx(), global);
} }
if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) { if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) {
@ -14167,6 +14165,18 @@ nsGlobalWindow::SetReplaceableWindowCoord(JSContext* aCx,
(this->*aSetter)(value, aError); (this->*aSetter)(value, aError);
} }
void
nsGlobalWindow::FireOnNewGlobalObject()
{
MOZ_ASSERT(IsInnerWindow());
// AutoEntryScript required to invoke debugger hook, which is a
// Gecko-specific concept at present.
AutoEntryScript aes(this, "nsGlobalWindow report new global");
JS::Rooted<JSObject*> global(aes.cx(), GetWrapper());
JS_FireOnNewGlobalObject(aes.cx(), global);
}
#ifdef _WINDOWS_ #ifdef _WINDOWS_
#error "Never include windows.h in this file!" #error "Never include windows.h in this file!"
#endif #endif

View File

@ -1538,6 +1538,11 @@ protected:
// show, in that case we show a separate dialog to ask this question. // show, in that case we show a separate dialog to ask this question.
bool ConfirmDialogIfNeeded(); bool ConfirmDialogIfNeeded();
private:
// Fire the JS engine's onNewGlobalObject hook. Only used on inner windows.
void FireOnNewGlobalObject();
protected:
// When adding new member variables, be careful not to create cycles // When adding new member variables, be careful not to create cycles
// through JavaScript. If there is any chance that a member variable // through JavaScript. If there is any chance that a member variable
// could own objects that are implemented in JavaScript, then those // could own objects that are implemented in JavaScript, then those