Bug 1464461 - fix talos failure; r=nchevobbe draft
authoryulia <ystartsev@mozilla.com>
Tue, 03 Jul 2018 15:33:38 +0200
changeset 813609 7ded7b0fc581
parent 813608 de0f6f715b4f
push id114934
push userbmo:ystartsev@mozilla.com
push dateTue, 03 Jul 2018 13:34:11 +0000
reviewersnchevobbe
bugs1464461
milestone63.0a1
Bug 1464461 - fix talos failure; r=nchevobbe MozReview-Commit-ID: 9v9lRZjzacs
testing/talos/talos/tests/devtools/addon/content/tests/webconsole/objectexpand.js
--- a/testing/talos/talos/tests/devtools/addon/content/tests/webconsole/objectexpand.js
+++ b/testing/talos/talos/tests/devtools/addon/content/tests/webconsole/objectexpand.js
@@ -10,24 +10,24 @@ const { openToolbox, closeToolboxAndLog,
 module.exports = async function() {
   let tab = await testSetup(SIMPLE_URL);
 
   let messageManager = tab.linkedBrowser.messageManager;
   let toolbox = await openToolbox("webconsole");
   let webconsole = toolbox.getPanel("webconsole");
 
   // Resolve once the first message is received.
-  let onMessageReceived = new Promise(resolve => {
-    function receiveMessages(messages) {
-      for (let m of messages) {
-        resolve(m);
-      }
+  const waitForDirMessage = async () => {
+    let message = webconsole.hud.ui.outputNode.querySelector(".dir.message");
+    if (message) {
+      return message;
     }
-    webconsole.hud.ui.once("new-messages", receiveMessages);
-  });
+    await new Promise(res => setTimeout(res, 50));
+    return waitForDirMessage();
+  };
 
   // Load a frame script using a data URI so we can do logs
   // from the page.
   messageManager.loadFrameScript("data:,(" + encodeURIComponent(
     `function () {
       addMessageListener("do-dir", function () {
         content.console.dir(Array.from({length:333}).reduce((res, _, i)=> {
           res["item_" + i] = "alphanum-indexed-" + i;
@@ -38,18 +38,18 @@ module.exports = async function() {
       });
     }`
   ) + ")()", true);
 
   let test = runTest("console.objectexpand");
   // Kick off the logging
   messageManager.sendAsyncMessage("do-dir");
 
-  await onMessageReceived;
-  const tree = webconsole.hud.ui.outputNode.querySelector(".dir.message .tree");
+  const message = await waitForDirMessage();
+  const tree = message.querySelector(".tree");
 
   // The tree can be collapsed since the properties are fetched asynchronously.
   if (tree.querySelectorAll(".node").length === 1) {
     // If this is the case, we wait for the properties to be fetched and displayed.
     await new Promise(resolve => {
       const observer = new (getBrowserWindow().MutationObserver)(mutations => {
         resolve(mutations);
         observer.disconnect();