Closed Bug 1428845 Opened 6 years ago Closed 6 years ago

Use TestUtils.waitForCondition in preferences tests

Categories

(Firefox :: Settings UI, enhancement, P5)

58 Branch
enhancement

Tracking

()

RESOLVED FIXED
Firefox 60
Tracking Status
firefox60 --- fixed

People

(Reporter: johannh, Assigned: rofael, Mentored)

Details

Attachments

(1 file)

There's a waitForCondition function in preferences/in-content/tests/head.js[0] which is not needed because we can simply use TestUtils.waitForCondition[1] instead.

We need to delete the function and replace all its occurrences[2] with TestUtils.waitForCondition.

[0] https://searchfox.org/mozilla-central/rev/f42618c99dcb522fb674221acfbc68c2d92e7936/browser/components/preferences/in-content/tests/head.js#145
[1] https://searchfox.org/mozilla-central/rev/f42618c99dcb522fb674221acfbc68c2d92e7936/testing/modules/TestUtils.jsm#116
[2] https://searchfox.org/mozilla-central/search?q=%5Cswaitforcondition&case=false&regexp=true&path=browser%2Fcomponents%2Fpreferences%2Fin-content%2Ftests
Summary: Use BrowserTestUtils.waitForCondition in preferences tests → Use TestUtils.waitForCondition in preferences tests
I removed [0] and added "TestUtils." to everything in [2]. I ran all the modified tests and didn't get any syntax errors.
Assignee: nobody → me
Status: NEW → ASSIGNED
Comment on attachment 8944595 [details]
Bug 1428845 - Removed duplicate definition of waitForCondition().

https://reviewboard.mozilla.org/r/214758/#review220472

That looks good to me! Thank you! Let's give it a quick try run and land it when that succeeds!
Attachment #8944595 - Flags: review?(jhofmann) → review+
Pushed by jhofmann@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4d03b6d9fff4
Removed duplicate definition of waitForCondition(). r=johannh
Backout by aiakab@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/be344306e4bb
Backed out changeset 4d03b6d9fff4 for failing browser chrome on  browser/components/preferences/in-content/tests/browser_applications_selection.js
Oops...

https://dxr.mozilla.org/mozilla-central/source/browser/components/preferences/in-content/tests/browser_applications_selection.js#36 and https://dxr.mozilla.org/mozilla-central/source/browser/components/preferences/in-content/tests/browser_applications_selection.js#51 try to load the actionsMenu into a var, but it returns null!

Turns out that TestUtils.waitForCondition doesn't resolve anything (https://searchfox.org/mozilla-central/source/testing/modules/TestUtils.jsm#139), whereas the one in head.js (https://searchfox.org/mozilla-central/source/browser/components/preferences/in-content/tests/head.js#151) resolves with the output of the function passed into. 

TestUtils.wfc does run the function passed into it and stores the result in conditionPassed. I'm going to try resolve(conditionPassed) and see if that passes the tests (and doesn't break anything else)
That was exactly the problem! I'm running all of browser/components/preferences/in-content/tests/ right now to check that it didn't unintentionally break something else. I'll push it to review as soon as that's dealt with.
Attachment #8944595 - Flags: review+ → review?(jhofmann)
Comment on attachment 8944595 [details]
Bug 1428845 - Removed duplicate definition of waitForCondition().

https://reviewboard.mozilla.org/r/214758/#review220794

Ah, yeah, that seems like a logical improvement to me, let's see whether it breaks anything. I wonder why the try run didn't fail, though...

In any case, it seems like you'd benefit from having access to the Try server yourself. This page shows you how to get level 1 access: https://wiki.mozilla.org/ReleaseEngineering/TryServer#Getting_access_to_the_Try_Server. I'm happy to vouch for you.

Great work!

::: testing/modules/TestUtils.jsm:113
(Diff revision 2)
>     * @param attempts
>     *        The number of times to poll before giving up and rejecting
>     *        if the condition has not yet returned true. Defaults to 50
>     *        (~5 seconds for 100ms intervals)
>     * @return Promise
>     *        Resolves when condition is true.

Please add a note that it resolves with the return value of the condition function here.
Attachment #8944595 - Flags: review?(jhofmann) → review+
(In reply to Johann Hofmann [:johannh] from comment #9)

Okay, I just pushed that change to review. I also made a request for level 1 access (bug 1432957).

Thanks for the vouch!
Great, let's get this landed!
Pushed by jhofmann@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ef78d4e91a01
Removed duplicate definition of waitForCondition(). r=johannh
https://hg.mozilla.org/mozilla-central/rev/ef78d4e91a01
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: