Closed
Bug 1373130
Opened 9 years ago
Closed 8 years ago
[Form Autofill] Explicitly dispatch a notification after "identifyAutofillFields" invoked to ensure the tests have right timing to press down-key to avoid potential timeout
Categories
(Toolkit :: Form Manager, enhancement, P3)
Toolkit
Form Manager
Tracking
()
RESOLVED
FIXED
mozilla58
| Tracking | Status | |
|---|---|---|
| firefox58 | --- | fixed |
People
(Reporter: ralin, Assigned: ralin)
References
(Blocks 1 open bug)
Details
(Whiteboard: [form autofill])
Attachments
(1 file)
Right now, we defer the timing of invoking identifyAutofillFields at the point user "focusin" the element. It's intentional for performance improvement and doesn't harm normal usage. However, in our mochitest/bc tests, there's no delay between "focusin" and doKey("down")[1], and that potentially causes the timeout since no popup would show up until identifyAutofillFields is invoked.
I think we should consider sending out a message like "FormAutofill:FieldsIdentified" to replace current workaround[2] as an accordance for our tests to wait for.
[0] http://searchfox.org/mozilla-central/rev/d67ef71097da4d1aa344c9d9c672e49a7228e765/browser/extensions/formautofill/content/FormAutofillFrameScript.js#51
[1] http://searchfox.org/mozilla-central/rev/c49a70b53f67dd5550eec8a08793805f2aca8d42/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html#107-108
[2] http://searchfox.org/mozilla-central/rev/d67ef71097da4d1aa344c9d9c672e49a7228e765/browser/extensions/formautofill/test/mochitest/formautofill_common.js#14-24
| Assignee | ||
Updated•9 years ago
|
Blocks: fx-form-autofill
Whiteboard: [form autofill]
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 2•9 years ago
|
||
Not sure it's right way to go or is more reliable than setTimeout, will see the result on try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=0c01b9d259891f373e15c8c412b33af9b718a2d5
| Assignee | ||
Comment 3•9 years ago
|
||
Take this bug since identifyAutofillFields is still bothering Bug 1300995 with timeout problem.
Assignee: nobody → ralin
Status: NEW → ASSIGNED
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 5•9 years ago
|
||
A additional try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=a2f6bac14cdc568813ba94749e859a3f069d8989&selectedJob=107484068&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=usercancel&filter-resultStatus=running&filter-resultStatus=pending&filter-resultStatus=runnable
both looks good after patched. Luke could you help me to review this patch? Thanks.
Comment 6•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8878059 [details]
Bug 1373130 - Send message after identifyAutofillFields being invoked to indicate that formautofill is ready to open popup.
https://reviewboard.mozilla.org/r/149472/#review154238
::: browser/extensions/formautofill/test/mochitest/formautofill_common.js:20
(Diff revision 2)
> - input.focus();
> + input.focus();
>
> - // "identifyAutofillFields" is invoked asynchronously in "focusin" event. We
> - // should make sure fields are ready for popup before doing tests.
> - //
> - // TODO: "setTimeout" is used here temporarily because there's no event to
> + if (docIdentified) {
> + resolve(input);
> + } else {
> + formFillChromeScript.addMessageListener("FormAutofillTest:Identified", () => {
I suppose we need to `removeMessageListener` as it should be invoked only once.
::: browser/extensions/formautofill/test/mochitest/formautofill_common.js:23
(Diff revision 2)
> - // figure out a better way after the heuristics land.
> - SimpleTest.requestFlakyTimeout("Guarantee asynchronous identifyAutofillFields is invoked");
> - return new Promise(resolve => setTimeout(() => {
> - resolve(input);
> + resolve(input);
> - }, 500));
> + });
> + docIdentified = true;
Since `docIdentified` actually happens after `FormAutofillTest:Identified`, it should be in the handler.
However, according to your implementation, `FormAutofill:FieldsIdentified` is sent every time upon `focusin`, I think we don't need `docIdentified`.
Attachment #8878059 -
Flags: review?(lchang)
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
Comment 9•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8878059 [details]
Bug 1373130 - Send message after identifyAutofillFields being invoked to indicate that formautofill is ready to open popup.
https://reviewboard.mozilla.org/r/149472/#review154868
::: browser/extensions/formautofill/content/FormAutofillFrameScript.js:52
(Diff revision 4)
> return;
> }
>
> - let doIdentifyAutofillFields =
> - () => setTimeout(() => FormAutofillContent.identifyAutofillFields(doc));
> + let doIdentifyAutofillFields = () => setTimeout(() => {
> + FormAutofillContent.identifyAutofillFields(doc);
> + sendAsyncMessage("FormAutofill:FieldsIdentified");
Please comment on this that it's only used by tests for now.
Attachment #8878059 -
Flags: review?(lchang) → review+
| Assignee | ||
Comment 10•9 years ago
|
||
Thank you Luke,
I was thinking to eliminate the setTimeout workaround in our tests, however, by looking at the latest try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=99d48f9d461dc81321f823a31e1eca73c20cd095, I doubt this is reliable enough. I'd like to leave setTimeout as-is if it doesn't bring up huge impact in the near future.
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 13•8 years ago
|
||
Hi Luke,
Though you've r+'d the patch, could you help me to review again and see if it's still valid? Thanks.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 15•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=c03aa8e523b891c095c35d1c8cf3d0ab63d49863
I think the TH result shows that this patch is reliable enough to settle some intermittent failures, including test_basic_creditcard_autocomplete_form.html.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 17•8 years ago
|
||
Hey Luke,
I've updated the patch according to what we discussed yesterday. Could you help me to review it again? Thanks.
Flags: needinfo?(lchang)
Comment 18•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8878059 [details]
Bug 1373130 - Send message after identifyAutofillFields being invoked to indicate that formautofill is ready to open popup.
https://reviewboard.mozilla.org/r/149472/#review195774
::: browser/extensions/formautofill/test/browser/head.js:103
(Diff revision 8)
> await new Promise(resolve => setTimeout(resolve, ms));
> }
>
> +async function focusAndWaitForFieldsIdentified(browser, selector) {
> + /* eslint no-shadow: ["error", { "allow": ["selector", "focused", "identified"] }] */
> + const {focused, identified} = await ContentTask.spawn(browser, {selector}, async function({selector}) {
nit: `previouslyFocused` and `previouslyIdentified`
::: browser/extensions/formautofill/test/browser/head.js:119
(Diff revision 8)
> +
> + if (identified) {
> + return;
> + }
> +
> + if (!focused) {
It would be clearer to leave some comments explaining `FormAutofill:FieldsIdentified` may not be triggered if an input has been focused previously.
::: browser/extensions/formautofill/test/browser/head.js:127
(Diff revision 8)
> + Services.mm.removeMessageListener("FormAutofill:FieldsIdentified", onIdentified);
> + resolve();
> + });
> + });
> + }
> + // Wait 500ms for identifyAutofillFields if the form hasn't been identified yet.
This comment may need some updates since it's mainly for inputs that were focused previously, isn't it?
::: browser/extensions/formautofill/test/mochitest/formautofill_common.js:19
(Diff revision 8)
> await new Promise(resolve => setTimeout(resolve, ms));
> }
>
> -async function setInput(selector, value) {
> - let input = document.querySelector("input" + selector);
> - input.value = value;
> +async function focusAndWaitForFieldsIdentified(input) {
> + const rootElement = input.form || input.ownerDocument.documentElement;
> + const focused = input != document.activeElement;
nit: `previouslyFocused`
::: browser/extensions/formautofill/test/mochitest/formautofill_common.js:34
(Diff revision 8)
> // "identifyAutofillFields" is invoked asynchronously in "focusin" event. We
> // should make sure fields are ready for popup before doing tests.
> //
> // TODO: "sleep" is used here temporarily because there's no event to
> // notify us of the state of "identifyAutofillFields" for now. We should
> // figure out a better way after the heuristics land.
Comments need to be updated, too.
::: browser/extensions/formautofill/test/mochitest/test_on_address_submission.html:35
(Diff revision 8)
> + return Object.entries(profile)
> + .map(([key, value]) => setInput("#" + key, value))
> + .reduce((p, c) => p.then(c), Promise.resolve());
Since for-loop does well, how about keep using it?
Comment 19•8 years ago
|
||
(In reply to Ray Lin[:ralin] from comment #17)
> I've updated the patch according to what we discussed yesterday. Could you
> help me to review it again? Thanks.
Looks good to me. Only a few comments left. Thanks for addressing this.
Flags: needinfo?(lchang)
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 21•8 years ago
|
||
| mozreview-review-reply | ||
Comment on attachment 8878059 [details]
Bug 1373130 - Send message after identifyAutofillFields being invoked to indicate that formautofill is ready to open popup.
https://reviewboard.mozilla.org/r/149472/#review195774
Thanks for the review, the issues are fixed in the latest patch.
> Since for-loop does well, how about keep using it?
reverted the change, thanks.
| Assignee | ||
Comment 22•8 years ago
|
||
TH result looks good: https://treeherder.mozilla.org/#/jobs?repo=try&revision=64e17044d1e4f99092fb1d03780690384f70cdcb
Thank you Luke for reviewing this.
Keywords: checkin-needed
| Assignee | ||
Comment 23•8 years ago
|
||
Unmark checkin-needed, I didn't notice that: https://treeherder.mozilla.org/logviewer.html#?job_id=138105981&repo=try&lineNumber=2293, let me see why this patch causes new failure only on "test_on_address_submission.html"
Keywords: checkin-needed
| Comment hidden (mozreview-request) |
| Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
Comment 25•8 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/7649437b6b0c
Send message after identifyAutofillFields being invoked to indicate that formautofill is ready to open popup. r=lchang
Keywords: checkin-needed
Comment 26•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox58:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in
before you can comment on or make changes to this bug.
Description
•