Created attachment 559757[details]
Testcase
In another bug, I stated that the bug shown in the testcase should be fixed by bug 682338. I was wrong.
In the testcase, focusing the content-editable, and then right-clicking in the input, you get a context menu whose options reflect the state of the div rather than the input - indeed the actions operate on the div, not the input.
On platforms where the context menu is shown on mouse down, nsXULPopupListener explicitly focuses the target to ensure the context menu commands are dispatched to the correct element. This doesn't need to happen on platforms where the menu is shown on mouse button up, as the target should be focused by the event state manager's PostHandleEvent code.
However, in the testcase, the contenteditable's editor event listeners consume the mouse down event, which prevents the input from getting focused by the esm.
See http://hg.mozilla.org/mozilla-central/file/06b2977afb85/editor/libeditor/html/nsHTMLEditorEventListener.cpp#l244

I can't reproduce this on Mac with a build before bug 682338 was landed on mozilla-central...
(In reply to Graeme McCutcheon from comment #0)
> However, in the testcase, the contenteditable's editor event listeners
> consume the mouse down event, which prevents the input from getting focused
> by the esm.
> See
> http://hg.mozilla.org/mozilla-central/file/06b2977afb85/editor/libeditor/
> html/nsHTMLEditorEventListener.cpp#l244
Hmm, we should probably call IsNodeInActiveEditor there and ignore events on non-editable stuff completely (same thing for MouseUp too). Are you willing to write a patch for that?

Created attachment 614858[details][diff][review]
v1
>(same thing for MouseUp too)
Just MouseDown. A similar check on MouseUp would break object resizing.
I delayed posting this for a few months as I kept running into 597331 and 600570 failures on Win7 on try, but those have since became random-orange bug 718316 with no interference from me. Currently green on try modulo other random-orange.

Context menus are opened on "contextmenu" mouse events. The various nsWindow implementations dispatch them on real mouse clicks, but synthesized events don't unless you specifically ask for it (for example, see openContextMenu in browser/base/tests/test_contextMenu.js)