Bug 1177346 Part 4 - Add test for using inspector while paused.
authorBrian Hackett <bhackett1024@gmail.com>
Fri, 04 Jan 2019 13:46:04 -1000
changeset 509755 30f3633540ca3dc2bb7f6e56e2c27a2f54be639b
parent 509754 23699c5fb0b28293b8ea70b5364abd93cee45979
child 509756 ad135e7ddad2fa240139653a81be39e3cc96fd0f
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1177346
milestone66.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 1177346 Part 4 - Add test for using inspector while paused.
devtools/client/inspector/test/browser.ini
devtools/client/inspector/test/browser_inspector_highlighter-07.js
--- a/devtools/client/inspector/test/browser.ini
+++ b/devtools/client/inspector/test/browser.ini
@@ -68,16 +68,17 @@ skip-if = os == "mac" # Full keyboard na
 [browser_inspector_destroy-before-ready.js]
 [browser_inspector_expand-collapse.js]
 [browser_inspector_highlighter-01.js]
 [browser_inspector_highlighter-02.js]
 [browser_inspector_highlighter-03.js]
 [browser_inspector_highlighter-04.js]
 [browser_inspector_highlighter-05.js]
 [browser_inspector_highlighter-06.js]
+[browser_inspector_highlighter-07.js]
 [browser_inspector_highlighter-by-type.js]
 [browser_inspector_highlighter-cancel.js]
 [browser_inspector_highlighter-comments.js]
 [browser_inspector_highlighter-cssgrid_01.js]
 [browser_inspector_highlighter-cssgrid_02.js]
 [browser_inspector_highlighter-cssshape_01.js]
 [browser_inspector_highlighter-cssshape_02.js]
 [browser_inspector_highlighter-cssshape_03.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-07.js
@@ -0,0 +1,106 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+// Test that the highlighter works when the debugger is paused.
+
+function debuggerIsPaused(dbg) {
+  const {
+    selectors: { isPaused },
+    getState,
+  } = dbg;
+  return !!isPaused(getState());
+}
+
+function waitForPaused(dbg) {
+  return new Promise(resolve => {
+    if (debuggerIsPaused(dbg)) {
+      resolve();
+      return;
+    }
+
+    const unsubscribe = dbg.store.subscribe(() => {
+      if (debuggerIsPaused(dbg)) {
+        unsubscribe();
+        resolve();
+      }
+    });
+  });
+}
+
+function createDebuggerContext(toolbox) {
+  const panel = toolbox.getPanel("jsdebugger");
+  const win = panel.panelWin;
+  const { store, client, selectors, actions } = panel.getVarsForTests();
+
+  return {
+    actions: actions,
+    selectors: selectors,
+    getState: store.getState,
+    store: store,
+    client: client,
+    toolbox: toolbox,
+    win: win,
+    panel: panel,
+  };
+}
+
+const IFRAME_SRC = "<style>" +
+    "body {" +
+      "margin:0;" +
+      "height:100%;" +
+      "background-color:red" +
+    "}" +
+  "</style><body>hello from iframe</body>";
+
+const DOCUMENT_SRC = "<style>" +
+    "iframe {" +
+      "height:200px;" +
+      "border: 11px solid black;" +
+      "padding: 13px;" +
+    "}" +
+    "body,iframe {" +
+      "margin:0" +
+    "}" +
+  "</style>" +
+  "<body>" +
+   "<script>setInterval('debugger', 100)</script>" +
+   "<iframe src='data:text/html;charset=utf-8," + IFRAME_SRC + "'></iframe>" +
+  "</body>";
+
+const TEST_URI = "data:text/html;charset=utf-8," + DOCUMENT_SRC;
+
+add_task(async function() {
+  const { inspector, toolbox, testActor } = await openInspectorForURL(TEST_URI);
+
+  const target = await TargetFactory.forTab(gBrowser.selectedTab);
+  await gDevTools.showToolbox(target, "jsdebugger");
+  const dbg = createDebuggerContext(toolbox);
+
+  await waitForPaused(dbg);
+
+  await gDevTools.showToolbox(target, "inspector");
+
+  // Needed to get this test to pass consistently :(
+  await waitForTime(1000);
+
+  info("Waiting for box mode to show.");
+  const body = await getNodeFront("body", inspector);
+  await inspector.highlighter.showBoxModel(body);
+
+  info("Waiting for element picker to become active.");
+  await startPicker(toolbox);
+
+  info("Moving mouse over iframe padding.");
+  await moveMouseOver("iframe", 1, 1);
+
+  info("Performing checks");
+  await testActor.isNodeCorrectlyHighlighted("iframe", is);
+
+  function moveMouseOver(selector, x, y) {
+    info("Waiting for element " + selector + " to be highlighted");
+    testActor.synthesizeMouse({selector, x, y, options: {type: "mousemove"}});
+    return inspector.inspector.nodePicker.once("picker-node-hovered");
+  }
+});