diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index c8e54abcf08..99a47c13a15 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2268,9 +2268,11 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext& aPresContext, //Capturing stage if (NS_EVENT_FLAG_BUBBLE != aFlags) { nsIScriptGlobalObject* mGlobal; - if (NS_OK == mScriptContextOwner->GetScriptGlobalObject(&mGlobal)) { - mGlobal->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus); - NS_RELEASE(mGlobal); + if (mScriptContextOwner != nsnull) { + if (NS_OK == mScriptContextOwner->GetScriptGlobalObject(&mGlobal)) { + mGlobal->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus); + NS_RELEASE(mGlobal); + } } } diff --git a/layout/base/src/nsDocument.cpp b/layout/base/src/nsDocument.cpp index c8e54abcf08..99a47c13a15 100644 --- a/layout/base/src/nsDocument.cpp +++ b/layout/base/src/nsDocument.cpp @@ -2268,9 +2268,11 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext& aPresContext, //Capturing stage if (NS_EVENT_FLAG_BUBBLE != aFlags) { nsIScriptGlobalObject* mGlobal; - if (NS_OK == mScriptContextOwner->GetScriptGlobalObject(&mGlobal)) { - mGlobal->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus); - NS_RELEASE(mGlobal); + if (mScriptContextOwner != nsnull) { + if (NS_OK == mScriptContextOwner->GetScriptGlobalObject(&mGlobal)) { + mGlobal->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus); + NS_RELEASE(mGlobal); + } } }