From 125b92bf423fbe50b278c52a97ff1dda8c59d2d6 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 9 Nov 2016 09:21:17 -0800 Subject: [PATCH] Bug 1151909 - Fix browser_markup_load_01.js race by listening for events before executing the action that trigger them. r=pbro MozReview-Commit-ID: B7gA7CBxWam --HG-- extra : rebase_source : 00a56eeeedc41bc9689c1aa1920ee99f5ef35081 --- .../markup/test/browser_markup_load_01.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/devtools/client/inspector/markup/test/browser_markup_load_01.js b/devtools/client/inspector/markup/test/browser_markup_load_01.js index 9c8f4ed2c98d..78993e89bdfc 100644 --- a/devtools/client/inspector/markup/test/browser_markup_load_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_load_01.js @@ -28,12 +28,13 @@ const TEST_URL = "data:text/html," + "" + "" + "

Slow script

" + - "" + + "" + "" + ""; add_task(function* () { let {inspector, testActor, tab} = yield openInspectorForURL(TEST_URL); + let domContentLoaded = waitForLinkedBrowserEvent(tab, "DOMContentLoaded"); let pageLoaded = waitForLinkedBrowserEvent(tab, "load"); @@ -41,22 +42,32 @@ add_task(function* () { // Select an element while the tab is in the middle of a slow reload. testActor.eval("location.reload()"); + + info("Wait for DOMContentLoaded"); yield domContentLoaded; - yield chooseWithInspectElementContextMenu("img", testActor); + + info("Inspect element via context menu"); + let markupLoaded = inspector.once("markuploaded"); + let multipleChildrenUpdates = waitForMultipleChildrenUpdates(inspector); + yield chooseWithInspectElementContextMenu("img", tab); + + info("Wait for load"); yield pageLoaded; - yield inspector.once("markuploaded"); - yield waitForMultipleChildrenUpdates(inspector); + info("Wait for markup-loaded after element inspection"); + yield markupLoaded; + info("Wait for multiple children updates after element inspection"); + yield multipleChildrenUpdates; ok(inspector.markup, "There is a markup view"); is(inspector.markup._elt.children.length, 1, "The markup view is rendering"); }); -function* chooseWithInspectElementContextMenu(selector, testActor) { +function* chooseWithInspectElementContextMenu(selector, tab) { yield BrowserTestUtils.synthesizeMouseAtCenter(selector, { type: "contextmenu", button: 2 - }, gBrowser.selectedBrowser); + }, tab.linkedBrowser); yield EventUtils.synthesizeKey("Q", {}); }