Closed
Bug 418859
Opened 17 years ago
Closed 7 years ago
synthesizeMouse() doesn't work with <input> textboxes and <input type='file'> (in mochitests)
Categories
(Testing :: Mochitest, defect)
Testing
Mochitest
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: smichaud, Unassigned)
Details
Attachments
(8 files, 4 obsolete files)
I can't get the synthesizeMouse() function (in EventUtils.js) to work
properly with html <input> controls of type "text" (when writing a
mochitest).
Martijn has already reported one problem with synthesizeMouse() at bug
418745, but that's not the only problem.
Even when I work around bug 418745, I can't ever get synthesizeMouse()
to focus an <input> control of type "text" by synthesizing a click on
it.
synthesizeMouse() seems to work fine with a XUL textbox element, though.
I will attach example mochitests that illustrate what I've just said.
Reporter | ||
Comment 1•17 years ago
|
||
Reporter | ||
Comment 2•17 years ago
|
||
Reporter | ||
Comment 3•17 years ago
|
||
Reporter | ||
Comment 4•17 years ago
|
||
Comment 5•17 years ago
|
||
Steven, in your first 3 mochitests you're calling testSwitchTabs which don't exist, but testTextboxClick exists or vice versa. Isn't that the problem you're seeing?
(the "Simple *.xul mochitest that works fine" testcase doesn't seem to have that problem)
Comment 6•17 years ago
|
||
Ok, this is basically variation A without depending on mochikit. But it uses enhanced privileges, so you still need to download it to your computer to be able to test it.
This shows 'false' where one would expect 'true' to appear.
Comment 7•17 years ago
|
||
Doing <body onload="setTimeout(testTextboxClick, 0)"> instead of <body onload="testTextboxClick()"> makes it show 'true'.
So apparently, you need to do it with a timer to do this kind of stuff correctly.
Comment 8•17 years ago
|
||
And I can see the same problem with a xul document, so this isn't limited to html only.
So my guess is that this is an event handling problem.
Comment 9•17 years ago
|
||
testcase5 is probably correct behaviour. One can't focus a textbox unless the window is also focused. As the window is not focused until after the load event, changing 'onload' to 'onfocus' will cause the test to work fine. This is probably the issue with the other tests as well.
Comment 10•17 years ago
|
||
Well, using the .focus() methode just works fine.
Comment 11•17 years ago
|
||
Ok, sorry, I guess I advised Steven wrongly to not use 'onfocus'.
It all seems a bit fragile, though, it means that whenever the window becomes unfocused for some reason, the testcases would fail.
Reporter | ||
Comment 12•17 years ago
|
||
Here are my four testcases again, with the dumb mistakes fixed
(hopefully) and onload= changed to onfocus=.
Interestingly, I still get the same results with them. But I also get
the results that Martijn reports with his testcase5 and testcase6.
More on this in a later comment.
Attachment #304770 -
Attachment is obsolete: true
Reporter | ||
Comment 13•17 years ago
|
||
Attachment #304771 -
Attachment is obsolete: true
Reporter | ||
Comment 14•17 years ago
|
||
Attachment #304772 -
Attachment is obsolete: true
Reporter | ||
Comment 15•17 years ago
|
||
Attachment #304773 -
Attachment is obsolete: true
Reporter | ||
Comment 16•17 years ago
|
||
By the way, I find that my *.xul test (attachment 305013 [details]), though it
works with onfocus="testTextboxClick();", works better with
onfocus="setTimeout(testTextboxClick, 0);"
In both cases the test passes. But only in the second case does the
text-input cursor start blinking in the <textbox> element.
Comment 17•17 years ago
|
||
(In reply to comment #12)
> Interestingly, I still get the same results with them. But I also get
You mean they still don't work for you when using 'onfocus' instead of 'onload'?
Reporter | ||
Comment 18•17 years ago
|
||
Like I said above, I get the same results as Martijn with his
testcase5 and testcase6. It's particularly strange that his testcase6
works while my Variation C fails.
I notice that my Variation C (like all mochitests) rewrites the page
above the <input> control to show its results, but Martijn's testcase6
rewrites the page below the <input> control. Could this be what makes
the difference?
> You mean they still don't work for you when using 'onfocus' instead of
> 'onload'?
Yes.
Reporter | ||
Comment 19•17 years ago
|
||
> I notice that my Variation C (like all mochitests) rewrites the page
> above the <input> control to show its results, but Martijn's
> testcase6 rewrites the page below the <input> control. Could this
> be what makes the difference?
On second thought I think it's more likely that there's a subtle
problem with SimpleTest.finish() -- possibly a timing problem.
Reporter | ||
Comment 20•17 years ago
|
||
Or with SimpleTest.waitForExplicitFinish().
Reporter | ||
Updated•17 years ago
|
Attachment #305012 -
Attachment mime type: text/html → text/plain
Comment 21•17 years ago
|
||
As far as I can tell, variation A rev1 and variation B rev1 still use the load event handler (addLoadEvent), which doesn't work as Neil explained in comment 9 (although I still find it strange that it shouldn't work, fwiw).
variation C rev1 works fine for me (after rewriting it into a testcase that doesn't need MochiKit).
What I noticed as a problem, with the onfocus event handler on the body, that when the focus is somewhere in chrome, the focus event handler isn't called on the body.
I still find this relying on focus events to fire quite fragile.
Comment 22•17 years ago
|
||
(In reply to comment #21)
> What I noticed as a problem, with the onfocus event handler on the body, that
> when the focus is somewhere in chrome, the focus event handler isn't called on
> the body.
> I still find this relying on focus events to fire quite fragile.
I filed bug 419061 for this.
Reporter | ||
Comment 23•17 years ago
|
||
> variation C rev1 works fine for me (after rewriting it into a
> testcase that doesn't need MochiKit).
What's wierd (to me) is that it works without MochiKit but doesn't
work with MochiKit.
Comment 24•17 years ago
|
||
(In reply to comment #23)
> > variation C rev1 works fine for me (after rewriting it into a
> > testcase that doesn't need MochiKit).
>
> What's wierd (to me) is that it works without MochiKit but doesn't
> work with MochiKit.
Ah, I see. I guess that could happen, when one of the previous MochiKit testcases has moved focus to chrome, which means you would hit bug 419061. But this is just speculation, of course.
Does the Mochikit testcase work when you only run that one MochiKit testcase, instead of the whole Mochikit testcase group?
Reporter | ||
Comment 25•17 years ago
|
||
> Does the Mochikit testcase work when you only run that one MochiKit
> testcase, instead of the whole Mochikit testcase group?
All my tests of my mochitest examples have been of those tests by
themselves (using the --test-path=[testname] parameter of
runtests.pl). I've never run them with other mochitests.
Reporter | ||
Comment 26•17 years ago
|
||
To be more explicit, I always ran each test by itself.
Updated•16 years ago
|
Component: Testing → Mochitest
Product: Core → Testing
QA Contact: testing → mochitest
Version: Trunk → unspecified
Comment 27•15 years ago
|
||
I got the exact same issue. I wrote a mochitest which should pass IMO but doesn't.
Comment 28•15 years ago
|
||
Btw, synthesizeMouse doesn't work for clicking on a input type form control. I had to simulate a SPACE key to have a file picker showing in bug 377624.
Summary: synthesizeMouse() doesn't work with <input> textboxes (in mochitests) → synthesizeMouse() doesn't work with <input> textboxes and <input type='file'> (in mochitests)
Comment 29•15 years ago
|
||
CC'ing people who may be interested by this issue.
Comment 30•15 years ago
|
||
It would be interesting if someone could debug this by putting a breakpoint here <http://mxr.mozilla.org/mozilla-central/source/dom/base/nsDOMWindowUtils.cpp#228> and working down the call stack from there to see what's happening. I don't have the cycles to do that right now. Mounir, do you think that's the sort of thing you might be interested to work on?
Comment 31•15 years ago
|
||
(In reply to comment #30)
> It would be interesting if someone could debug this by putting a breakpoint
> here
> <http://mxr.mozilla.org/mozilla-central/source/dom/base/nsDOMWindowUtils.cpp#228>
> and working down the call stack from there to see what's happening. I don't
> have the cycles to do that right now. Mounir, do you think that's the sort of
> thing you might be interested to work on?
I've not so much cycles to dedicate to this bug too. However, I would like to see this fixed so I may want to look at that if I want to change my mind from my current work.
If someone wants to work on this, feel free to take the bug.
Comment 32•14 years ago
|
||
FWIW, this test seems to be simulating a click on a file control:
<http://mxr.mozilla.org/mozilla-central/source/layout/forms/test/bug536567_subframe.html?force=1#65>
Comment 33•7 years ago
|
||
Mass closing mochitest bugs that haven't had activity in the past 5 years. Please re-open or file a new bug with modern context if this is still relevant.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•