Closed Bug 1441531 Opened 2 years ago Closed 2 years ago

browser_markup_load_01.js fails when converting waitForMultipleChildrenUpdates from Task.jsm to async/await


(DevTools :: Inspector, defect)

Not set


(firefox60 fixed)

Firefox 60
Tracking Status
firefox60 --- fixed


(Reporter: ochameau, Assigned: yulia)




(1 file, 1 obsolete file)

Here is an easy way to reproduce the exception:

$ ./mach mochitest devtools/client/inspector/markup/test/browser_markup_load_01.js

TEST-UNEXPECTED-FAIL | devtools/client/inspector/markup/test/browser_markup_load_01.js | Uncaught exception - at chrome://mochitests/content/browser/devtools/client/inspector/test/head.js:537 - TypeError: inspector.markup is null
Stack trace:
    _run@resource://devtools/shared/base-loader.js -> resource://devtools/shared/task.js:310:39
    TaskImpl@resource://devtools/shared/base-loader.js -> resource://devtools/shared/task.js:272:3
    asyncFunction@resource://devtools/shared/base-loader.js -> resource://devtools/shared/task.js:246:14

And a try run highlighting the failures with this patch:

Be careful about bug 1441528, waitForMultipleChildrenUpdates is duplicated right now, but browser_markup_load_01.js ends up using the one from devtools/client/inspector/test/head.js
Assignee: nobody → ystartsev
Comment on attachment 8954691 [details]
Bug 1441531 - Convert waitForMultipleChildrenUpdates from Task.jsm to async/await.

Code analysis found 1 defect in this patch:
 - 1 defect found by mozlint

You can run this analysis locally with:
 - `./mach lint path/to/file` (JS/Python)

If you see a problem in this automated review, please report it here:

::: devtools/client/inspector/test/head.js:542
(Diff revision 1)
>    // As long as child updates are queued up while we wait for an update already
>    // wait again
>    if (inspector.markup._queuedChildUpdates &&
>          inspector.markup._queuedChildUpdates.size) {
> -    yield waitForChildrenUpdated(inspector);
> -    return yield waitForMultipleChildrenUpdates(inspector);
> +    await waitForChildrenUpdated(inspector);
> +    return await waitForMultipleChildrenUpdates(inspector);

Error: Redundant use of `await` on a return value. [eslint: no-return-await]
It looks like what is happening here is that task.jsm is lazy and async/await is eager. This also sheds some light on why we might have had issues in other task.jsm replacements. We can see that here:

>  let multipleChildrenUpdates = waitForMultipleChildrenUpdates(inspector);
>  yield chooseWithInspectElementContextMenu("img", tab);
>  info("Wait for load");
>  yield pageLoaded;
>  info("Wait for markup-loaded after element inspection");
>  yield markupLoaded;
>  info("Wait for multiple children updates after element inspection");
>  yield multipleChildrenUpdates;

In the previous version of the code, waitForMultipleChildrenUpdates would be setup on line 52 (the first line above), but it would not execute anything until line 61 (the last line). We can see this because `inspector.markup` which is used in waitForMultipleChildrenUpdates is null before `yield markupLoaded` completes. Given that this is the case, we might want to remove line 52, and replace line 61 with `yield waitForMultipleChildrenUpdates(inspector)` and it would be equivalent
Attachment #8954702 - Flags: review?(poirot.alex)
Blocks: 1442153
Comment on attachment 8954702 [details]
Bug 1441531 - Make waitForMultipleChildrenUpdates an async function

Looks good to me but I would like feedback from an inspector expert :)
Attachment #8954702 - Flags: review?(poirot.alex) → review?(pbrosset)
Comment on attachment 8954702 [details]
Bug 1441531 - Make waitForMultipleChildrenUpdates an async function

::: commit-message-52975:1
(Diff revision 2)
> +Bug 1441531 - browser_markup_load_01.js fails when converting waitForMultipleChildrenUpdates from Task.jsm to async/await

Can you please rephrase so it summarizes what you changed rather than just re-states the title of the bug?
The title of the bug usually says what the problem is (often from the user's standpoint), while a commit message (and there can be several per bug) says what was changed in the code within this commit.

I suggest "Make waitForMultipleChildrenUpdates an async function"

And if you want to say more about the test changes, you can always add more description on new lines below that.
Attachment #8954702 - Flags: review?(pbrosset) → review+
Attachment #8954691 - Attachment is obsolete: true
Pushed by
Make waitForMultipleChildrenUpdates an async function r=pbro
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.