Closed Bug 470845 Opened 16 years ago Closed 15 years ago

Create infrastructure to test processing of native mouse events

Categories

(Core :: Widget, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a1

People

(Reporter: smichaud, Assigned: mstange)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

In order to write a reasonable variety of mochitests/chrometests for widget bugs, we need to be able to allow them to synthesize native mouse events. This would presumably be parallel to the support we already have for synthesizing native key events in nsIDomUtils::SendNativeMouseEvent() and nsIWidget::SynthesizeNativeKeyEvent().
> This would presumably be parallel to the support we already have for > synthesizing native key events in nsIDomUtils::SendNativeMouseEvent() > and nsIWidget::SynthesizeNativeKeyEvent(). See bug 431503.
Blocks: 419466
nsDOMWindowUtils::SendMouseEvent synthesizes nsIWidget-level events. Do you need to synthesize actual Cocoa mouse events for some reason?
(In reply to comment #2) > Do you need to synthesize actual Cocoa mouse events for some reason? Yes. To allow us to write mochitests (or chrome tests and so on) for bugs where the bug was caused by native mouse events being (somehow) mishandled. I should think the need for this is ... well, obvious :-) Or am I missing something?
The only additional code you can test with real Cocoa events is the code that converts Cocoa events to nsMouseEvent events ... or code that only understands Cocoa events, perhaps Mac native menus or something. Is that what you have in mind?
The only specific examples I had in mind are focus bugs like bug 428405 and bug 403232. In these cases, it's not so much the native mouse event itself that's mishandled, but the (OS-defined and OS-implemented) consequences of that event that are mishandled -- the OS changes the keyboard focus from NSView object to another, but problems arise in Gecko if this is allowed to happen. I was able to reproduce bug 428405 using only (native) keyboard events -- so it wasn't impossible to write a mochitest for that bug. But that won't always be the case (especially considering that the OS expects a left mouse-down to change the focus). It wouldn't be hard to write an nsIWidget::SynthesizeNativeMouseEvent() for OS X -- I could do it myself. I don't (off the top of my head) know how to write one for Windows or Linux. But even nsIWidget::SynthesizeNativeKeyEvent() is still only implemented on OS X and Windows (not yet on Linux).
Blocks: 119061
Attached patch v1 (obsolete) — Splinter Review
Assignee: nobody → mstange
Status: NEW → ASSIGNED
Attachment #400835 - Flags: superreview?(roc)
Attachment #400835 - Flags: review?(joshmoz)
Blocks: 515003
+ return frame->GetView()->GetNearestWidget(nsnull); frame->GetWindow() + if (mWindow) { + nsIDocShell *docShell = mWindow->GetDocShell(); + if (docShell) { + nsCOMPtr<nsIPresShell> presShell; + docShell->GetPresShell(getter_AddRefs(presShell)); + if (presShell) { + nsCOMPtr<nsIContent> content = do_QueryInterface(aElement); + nsIFrame* frame = presShell->GetPrimaryFrameFor(content); Why not just do content->GetCurrentDoc() (null check) ->GetPrimaryPresShell() etc? Suppose we want to make test_native_mouse.xul work cross-platform. What would we have to do? Seems to me we might want some kind of cross-platform wrapper around sendNativeMouseEvent in EventUtils.js so that the message and modifiers can be abstracted.
Attached patch v2Splinter Review
(In reply to comment #9) > Suppose we want to make test_native_mouse.xul work cross-platform. What would > we have to do? I don't think test_native_mouse.xul should be cross-platform; it's very platform-specific by design. E.g. it tests not sending most mouse events to background windows, which is a Mac-ism, and it's simulating OS quirks like sending events to a window that's not under the mouse. I've renamed it to test_native_mouse_mac.xul I don't know how mouse events work on other platforms and if they also have an event redirection setup; if they do, maybe we can add a shared test. > Seems to me we might want some kind of cross-platform wrapper > around sendNativeMouseEvent in EventUtils.js so that the message and modifiers > can be abstracted. Maybe, but I think we can think about that when we add support for other platforms. :)
Attachment #400835 - Attachment is obsolete: true
Attachment #400895 - Flags: superreview?(roc)
Attachment #400895 - Flags: review?(joshmoz)
Attachment #400835 - Flags: superreview?(roc)
Attachment #400835 - Flags: review?(joshmoz)
Attachment #400895 - Flags: superreview?(roc) → superreview+
Comment on attachment 400895 [details] [diff] [review] v2 I think I'll combine this with bug 515003. I've noticed that some comments in the test are not correct, and I don't want to go through the hassle of moving those correction back into this patch.
Attachment #400895 - Flags: review?(joshmoz)
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: