Bug 1336198 - part10: fix race condition in boxmodel tests;r=gl draft
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 22 Feb 2017 20:48:23 +0100
changeset 488209 62946960f4bd877631f1598ca21b8e7e889fd126
parent 488189 d401231636394e6db000cf6bf59f25c02020909f
child 546670 f9923e681b452ce84374666573c9d4afc76bde4e
push id46459
push userjdescottes@mozilla.com
push dateWed, 22 Feb 2017 19:50:32 +0000
reviewersgl
bugs1336198
milestone54.0a1
Bug 1336198 - part10: fix race condition in boxmodel tests;r=gl MozReview-Commit-ID: IDBgbnlMX2c
devtools/client/inspector/boxmodel/test/head.js
devtools/client/inspector/test/shared-head.js
--- a/devtools/client/inspector/boxmodel/test/head.js
+++ b/devtools/client/inspector/boxmodel/test/head.js
@@ -88,11 +88,12 @@ function setStyle(testActor, selector, p
 
 /**
  * The box model doesn't participate in the inspector's update mechanism, so simply
  * calling the default selectNode isn't enough to guarantee that the box model view has
  * finished updating. We also need to wait for the "boxmodel-view-updated" event.
  */
 var _selectNode = selectNode;
 selectNode = function* (node, inspector, reason) {
+  let onUpdate = waitForUpdate(inspector);
   yield _selectNode(node, inspector, reason);
-  yield waitForUpdate(inspector);
+  yield onUpdate;
 };
--- a/devtools/client/inspector/test/shared-head.js
+++ b/devtools/client/inspector/test/shared-head.js
@@ -47,17 +47,25 @@ var openInspector = Task.async(function*
  *        The ID of the sidebar tab to be opened
  * @return a promise that resolves when the inspector is ready and the tab is
  * visible and ready
  */
 var openInspectorSidebarTab = Task.async(function* (id) {
   let {toolbox, inspector, testActor} = yield openInspector();
 
   info("Selecting the " + id + " sidebar");
-  inspector.sidebar.select(id);
+
+  if (id === "computedview" || id === "layoutview") {
+    // The layout and computed viewS should wait until the box-model widget is ready.
+    let onBoxModelViewReady = inspector.once("boxmodel-view-updated");
+    inspector.sidebar.select(id);
+    yield onBoxModelViewReady;
+  } else {
+    inspector.sidebar.select(id);
+  }
 
   return {
     toolbox,
     inspector,
     testActor
   };
 });