diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index e7d33804b557..a44e64f62d0e 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -542,9 +542,10 @@ nsXULElement::GetEventListenerManagerForAttr(nsIEventListenerManager** aManager, if (!doc) return NS_ERROR_UNEXPECTED; // XXX + nsPIDOMWindow *window; nsIContent *root = doc->GetRootContent(); - if ((!root || root == this) && !mNodeInfo->Equals(nsGkAtoms::overlay)) { - nsPIDOMWindow *window = doc->GetInnerWindow(); + if ((!root || root == this) && !mNodeInfo->Equals(nsGkAtoms::overlay) && + (window = doc->GetInnerWindow()) && window->IsInnerWindow()) { nsCOMPtr piTarget = do_QueryInterface(window); if (!piTarget)