Bug 1386221 - Fix test for inspect binding on 56 beta. r=bgrins, a=test-only
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 01 Aug 2017 19:59:24 +0200
changeset 423362 04450e033f1ca05de91f3c82293f57d3a0157c95
parent 423361 f404b283003599d33e9ed805fb69f1104a06274c
child 423363 cc969bb39edc291153d48d299721d48c1b7458ea
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins, test-only
bugs1386221
milestone56.0
Bug 1386221 - Fix test for inspect binding on 56 beta. r=bgrins, a=test-only 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;