Bug 1339800 - Toggle the highlighter between each test case; r=gl draft
authorPatrick Brosset <pbrosset@mozilla.com>
Mon, 16 Oct 2017 15:39:45 +0200
changeset 680835 41d4d297fb97ba917a042228e24620477fc87074
parent 680782 c6a2643362a67cdf7a87ac165454fce4b383debb
child 682170 f7b7beb44695ddb20b6f85d4a73d1d357f30a515
push id84652
push userbmo:pbrosset@mozilla.com
push dateMon, 16 Oct 2017 13:40:10 +0000
reviewersgl
bugs1339800
milestone58.0a1
Bug 1339800 - Toggle the highlighter between each test case; r=gl MozReview-Commit-ID: 4TS7JovMaJI
devtools/client/inspector/test/browser_inspector_highlighter-zoom.js
--- a/devtools/client/inspector/test/browser_inspector_highlighter-zoom.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-zoom.js
@@ -16,52 +16,40 @@ const TEST_LEVELS = [2, 1, .5];
 // node, for the values given.
 const expectedStyle = (w, h, z) =>
         (z !== 1 ? `transform-origin:top left; transform:scale(${1 / z}); ` : "") +
         `position:absolute; width:${w * z}px;height:${h * z}px; ` +
         "overflow:hidden";
 
 add_task(function* () {
   let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
-
-  info("Highlighting the test node");
+  let highlighterUtils = inspector.toolbox.highlighterUtils;
 
-  yield hoverElement("div", inspector);
-  let isVisible = yield testActor.isHighlighting();
-  ok(isVisible, "The highlighter is visible");
+  let div = yield getNodeFront("div", inspector);
 
   for (let level of TEST_LEVELS) {
-    info("Zoom to level " + level +
-         " and check that the highlighter is correct");
+    info(`Zoom to level ${level}`);
+    yield testActor.zoomPageTo(level, false);
 
-    yield testActor.zoomPageTo(level);
-    isVisible = yield testActor.isHighlighting();
-    ok(isVisible, "The highlighter is still visible at zoom level " + level);
+    info("Highlight the test node");
+    yield highlighterUtils.highlightNodeFront(div);
+
+    let isVisible = yield testActor.isHighlighting();
+    ok(isVisible, `The highlighter is visible at zoom level ${level}`);
 
     yield testActor.isNodeCorrectlyHighlighted("div", is);
 
     info("Check that the highlighter root wrapper node was scaled down");
 
     let style = yield getElementsNodeStyle(testActor);
     let { width, height } = yield testActor.getWindowDimensions();
     is(style, expectedStyle(width, height, level),
       "The style attribute of the root element is correct");
+
+    info("Unhighlight the node");
+    yield highlighterUtils.unhighlight();
   }
 });
 
-function* hoverElement(selector, inspector) {
-  info("Hovering node " + selector + " in the markup view");
-  let container = yield getContainerForSelector(selector, inspector);
-  yield hoverContainer(container, inspector);
-}
-
-function* hoverContainer(container, inspector) {
-  let onHighlight = inspector.toolbox.once("node-highlight");
-  EventUtils.synthesizeMouse(container.tagLine, 2, 2, {type: "mousemove"},
-      inspector.markup.doc.defaultView);
-  yield onHighlight;
-}
-
 function* getElementsNodeStyle(testActor) {
-  let value = yield testActor.getHighlighterNodeAttribute(
-    "box-model-elements", "style");
+  let value = yield testActor.getHighlighterNodeAttribute("box-model-elements", "style");
   return value;
 }