Closed Bug 1459998 Opened 6 years ago Closed 6 years ago

Stop using sync helpers in addon manager tests

Categories

(Toolkit :: Add-ons Manager, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: aswan, Assigned: kmag)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Helpers used in addons manager tests including {startup,shutdown,restart}Manager, writeInstallRDFToDir, etc were originally synchronous.  They have been rewritten to be properly asynchronous with awaitPromise() wrappers so every user didn't have to be rewritten at the time, but now its time to go back and convert existing users and remove the sync wrappers.
I've been thinking about just doing a scripted rewrite for this.
Assignee: nobody → kmaglione+bmo
Comment on attachment 8974168 [details]
Bug 1459998: Part 1 - Rewrite tests not to use async helpers.

https://reviewboard.mozilla.org/r/242452/#review248398

thanks!

::: toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js:14
(Diff revision 2)
>  
>  var testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
>  const profileDir = gProfD.clone();
>  profileDir.append("extensions");
>  
> -function run_test() {
> +add_task(async function setup() {

if you just move the call to do_test_pending before the call to promiseStartupManager(), you can leave out add_task()

Its functionally equivalent but simpler to read I think.

::: toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js:45
(Diff revision 2)
>    let unpacked_addon = profileDir.clone();
>    unpacked_addon.append(IGNORE_ID);
>    do_get_file("data/test_delay_update_ignore/bootstrap.js")
>      .copyTo(unpacked_addon, "bootstrap.js");

ugh

::: toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js:195
(Diff revision 2)
>    Assert.ok(addon_upgraded.isCompatible);
>    Assert.ok(!addon_upgraded.appDisabled);
>    Assert.ok(addon_upgraded.isActive);
>    Assert.equal(addon_upgraded.type, "extension");
>  
> -  await shutdownManager();
> +  await await promiseShutdownManager();

i think once is enough.  there are several other instances of this below as well.

::: toolkit/mozapps/extensions/test/xpcshell/test_proxies.js:113
(Diff revision 2)
>  
>    // Check that all add-ons original sources still exist after invalid
>    // add-ons have been removed at startup.
>    checkAddonsExist();
>  
> -  return AddonManager.getAddonsByIDs(ADDONS.map(addon => addon.id)).then(addons => {
> +  return AddonManager.getAddonsByIDs(ADDONS.map(addon => addon.id)).then(async addons => {

why isn't this just
`let addons = await AddonManager.getAddonsByIDs(...);`

::: toolkit/mozapps/extensions/test/xpcshell/test_proxies.js:210
(Diff revision 2)
> -    restartManager();
> -    shutdownManager();
> +    await promiseRestartManager();
> +    await promiseShutdownManager();

whats the point of this?

::: toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js:258
(Diff revision 2)
> +<<<<<<< dest
>    startupManager();
> +=======
> +  await promiseStartupManager(false);
> +>>>>>>> source

fix
Attachment #8974168 - Flags: review?(aswan) → review+
Comment on attachment 8974168 [details]
Bug 1459998: Part 1 - Rewrite tests not to use async helpers.

https://reviewboard.mozilla.org/r/242452/#review248398

> if you just move the call to do_test_pending before the call to promiseStartupManager(), you can leave out add_task()
> 
> Its functionally equivalent but simpler to read I think.

Probably. In general I think we should move tests to add_task style, though, and that's one less step when we eventually get around to converting this file.

> why isn't this just
> `let addons = await AddonManager.getAddonsByIDs(...);`

Don't ask me. I didn't write it.

> whats the point of this?

Make sure nothing disappears after restart, then shut down the manager so we can actually remove things without file locking errors and such.
Comment on attachment 8974169 [details]
Bug 1459998: Part 2 - Cleanup cruft.

https://reviewboard.mozilla.org/r/242454/#review248416
Attachment #8974169 - Flags: review?(aswan) → review+
https://hg.mozilla.org/mozilla-central/rev/641157ac54c2
https://hg.mozilla.org/mozilla-central/rev/4079ea68361c
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Flags: qe-verify-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: