Bug 1151909 - Fix browser_markup_load_01.js race by listening for events before executing the action that trigger them. r=pbro
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 09 Nov 2016 09:21:17 -0800
changeset 324363 c307daee56b588148e7853a74a3190bf64034499
parent 324362 7f137d9fa7ba6f092eb1821b3972ff2f1ea85a12
child 324364 fb4f5c7e082a4176cd1b8f3c784e5f424417e3fa
push id31003
push usercbook@mozilla.com
push dateMon, 28 Nov 2016 15:36:30 +0000
treeherdermozilla-central@2594b001d757 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1151909
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
devtools/client/inspector/markup/test/browser_markup_load_01.js
--- a/devtools/client/inspector/markup/test/browser_markup_load_01.js
+++ b/devtools/client/inspector/markup/test/browser_markup_load_01.js
@@ -23,45 +23,56 @@ server.registerPathHandler("/slow.gif", 
 });
 
 // Test page load events.
 const TEST_URL = "data:text/html," +
   "<!DOCTYPE html>" +
   "<head><meta charset='utf-8' /></head>" +
   "<body>" +
   "<p>Slow script</p>" +
-  "<img src='http://localhost:" + server.identity.primaryPort + "/slow.gif' /></script>" +
+  "<img src='http://localhost:" + server.identity.primaryPort + "/slow.gif' />" +
   "</body>" +
   "</html>";
 
 add_task(function* () {
   let {inspector, testActor, tab} = yield openInspectorForURL(TEST_URL);
+
   let domContentLoaded = waitForLinkedBrowserEvent(tab, "DOMContentLoaded");
   let pageLoaded = waitForLinkedBrowserEvent(tab, "load");
 
   ok(inspector.markup, "There is a markup view");
 
   // 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", {});
 }
 
 function waitForLinkedBrowserEvent(tab, event) {
   let def = defer();
   tab.linkedBrowser.addEventListener(event, function cb() {
     tab.linkedBrowser.removeEventListener(event, cb, true);