diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 258012d723a3..1c8c5fe0f49b 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -914,6 +914,9 @@ nsMenuPopupFrame::CreateDismissalListener() NS_IMETHODIMP nsMenuPopupFrame::InstallKeyboardNavigator() { + if (mKeyboardNavigator) + return NS_OK; + nsCOMPtr doc; mContent->GetDocument(*getter_AddRefs(doc)); nsCOMPtr target = do_QueryInterface(doc); @@ -932,6 +935,9 @@ nsMenuPopupFrame::InstallKeyboardNavigator() NS_IMETHODIMP nsMenuPopupFrame::RemoveKeyboardNavigator() { + if (!mKeyboardNavigator) + return NS_OK; + mTarget->RemoveEventListener("keypress", (nsIDOMKeyListener*)mKeyboardNavigator, PR_TRUE); mTarget->RemoveEventListener("keydown", (nsIDOMKeyListener*)mKeyboardNavigator, PR_TRUE); mTarget->RemoveEventListener("keyup", (nsIDOMKeyListener*)mKeyboardNavigator, PR_TRUE);