Bug 1386221 - Fix test for inspect binding on 56 beta. r=bgrins. draft
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 01 Aug 2017 19:59:24 +0200
changeset 619754 ef8e21d1f0a1b074fd798ed2b05fb18a9a9335cc
parent 618977 51ffb9283f0c7c00e08eb8c39b33fbee218c370d
child 640501 1d44c8254fc8b4abf6a186b45d0cf8a9235dfbf6
push id71797
push userbmo:nchevobbe@mozilla.com
push dateWed, 02 Aug 2017 14:19:34 +0000
reviewersbgrins
bugs1386221
milestone56.0a1
Bug 1386221 - Fix test for inspect binding on 56 beta. r=bgrins. The test was failing on 56 beta because the new console frontend isn't enabled there and thus the ObjectInspector that were tested not in the old frontend. This patch adds a branch in the test so we can wait for the correct element (VariableView or ObjectInspector) depending on whether the new console frontend is enabled or not. MozReview-Commit-ID: HGGgr7CWMpe
browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_eval_bindings.js
--- a/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_eval_bindings.js
+++ b/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_eval_bindings.js
@@ -116,31 +116,44 @@ add_task(async function test_devtools_in
   info("Wait for the toolbox to switch to the inspector and the expected node has been selected");
   await inspectorPanelSelectedPromise;
   info("Toolbox has been switched to the inspector as expected");
 
   info("Test inspectedWindow.eval inspect() binding called for a JS object");
 
   const splitPanelOpenedPromise = (async () => {
     await toolbox.once("split-console");
-    let jsterm = toolbox.getPanel("webconsole").hud.jsterm;
+    const {hud} = toolbox.getPanel("webconsole");
+    let {jsterm} = hud;
 
-    // Wait for the message to appear on the console.
-    const messageNode = await new Promise(resolve => {
-      jsterm.hud.on("new-messages", function onThisMessage(e, messages) {
-        for (let m of messages) {
-          resolve(m.node);
-          jsterm.hud.off("new-messages", onThisMessage);
-          return;
-        }
+    // See https://bugzilla.mozilla.org/show_bug.cgi?id=1386221.
+    if (jsterm.hud.NEW_CONSOLE_OUTPUT_ENABLED === true) {
+      // Wait for the message to appear on the console.
+      const messageNode = await new Promise(resolve => {
+        jsterm.hud.on("new-messages", function onThisMessage(e, messages) {
+          for (let m of messages) {
+            resolve(m.node);
+            jsterm.hud.off("new-messages", onThisMessage);
+            return;
+          }
+        });
       });
-    });
+      let objectInspectors = [...messageNode.querySelectorAll(".tree")];
+      is(objectInspectors.length, 1, "There is the expected number of object inspectors");
+    } else {
+      const options = await new Promise(resolve => {
+        jsterm.once("variablesview-open", (evt, view, options) => resolve(options));
+      });
 
-    let objectInspectors = [...messageNode.querySelectorAll(".tree")];
-    is(objectInspectors.length, 1, "There is the expected number of object inspectors");
+      const objectType = options.objectActor.type;
+      const objectPreviewProperties = options.objectActor.preview.ownProperties;
+      is(objectType, "object", "The inspected object has the expected type");
+      Assert.deepEqual(Object.keys(objectPreviewProperties), ["testkey"],
+                        "The inspected object has the expected preview properties");
+    }
   })();
 
   const inspectJSObjectPromise = extension.awaitMessage(`inspectedWindow-eval-result`);
   extension.sendMessage(`inspectedWindow-eval-request`, "inspect({testkey: 'testvalue'})");
   await inspectJSObjectPromise;
 
   info("Wait for the split console to be opened and the JS object inspected");
   await splitPanelOpenedPromise;