diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index 88846ef4d81..88a58c3f2ec 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -1048,7 +1048,7 @@ PRBool nsCaret::IsMenuPopupHidingCaret() return PR_FALSE; } - if (popupFrame->PopupType() == ePopupTypeMenu) { + if (popupFrame->PopupType() == ePopupTypeMenu && !popupFrame->IsContextMenu()) { // This is an open menu popup. It does not contain the caret (else we'd // have returned above). Even if the caret is in a subsequent popup, // or another document/frame, it should be hidden. diff --git a/mozilla/layout/base/tests/test_bug420499.xul b/mozilla/layout/base/tests/test_bug420499.xul index 93757d166fd..61d3c96ace2 100644 --- a/mozilla/layout/base/tests/test_bug420499.xul +++ b/mozilla/layout/base/tests/test_bug420499.xul @@ -28,7 +28,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=420499 - + + + + + + + + + + @@ -88,8 +97,35 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=420499 function ensureParagraphFocused() { window.removeEventListener("popuphidden", ensureParagraphFocused, false); ok(isCaretVisible(), "Caret should have returned to previous focus"); - SimpleTest.finish(); + window.addEventListener("popupshown", popupMenuShownHandler2, false); + $("contextmenu").openPopup($('text-input'), "topleft" , -1 , -1 , true, true); } + function popupMenuShownHandler2() { + window.removeEventListener("popupshown", popupMenuShownHandler2, false); + ok(isCaretVisible(), "Caret should be visible when context menu open"); + window.addEventListener("popuphidden", ensureParagraphFocused2, false); + document.getElementById("contextmenu").hidePopup(); + } + + function ensureParagraphFocused2() { + window.removeEventListener("popuphidden", ensureParagraphFocused2, false); + ok(isCaretVisible(), "Caret should still be visible"); + window.addEventListener("popupshown", tooltipShownHandler, false); + $("tooltip").openPopup($('text-input'), "topleft" , -1 , -1 , false, true); + } + + function tooltipShownHandler() { + window.removeEventListener("popupshown", tooltipShownHandler, false); + ok(isCaretVisible(), "Caret should be visible when tooltip is visible"); + window.addEventListener("popuphidden", ensureParagraphFocused3, false); + document.getElementById("tooltip").hidePopup(); + } + + function ensureParagraphFocused3() { + window.removeEventListener("popuphidden", ensureParagraphFocused2, false); + ok(isCaretVisible(), "Caret should still be visible"); + SimpleTest.finish(); + } ]]>