summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/test/browser_inspector_highlighter-zoom.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/inspector/test/browser_inspector_highlighter-zoom.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/inspector/test/browser_inspector_highlighter-zoom.js')
-rw-r--r--devtools/client/inspector/test/browser_inspector_highlighter-zoom.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_highlighter-zoom.js b/devtools/client/inspector/test/browser_inspector_highlighter-zoom.js
new file mode 100644
index 000000000..1919975ef
--- /dev/null
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-zoom.js
@@ -0,0 +1,72 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// Test that the highlighter stays correctly positioned and has the right aspect
+// ratio even when the page is zoomed in or out.
+
+const TEST_URL = "data:text/html;charset=utf-8,<div>zoom me</div>";
+
+// TEST_LEVELS entries should contain the following properties:
+// - level: the zoom level to test
+// - expected: the style attribute value to check for on the root highlighter
+// element.
+const TEST_LEVELS = [{
+ level: 2,
+ expected: "position:absolute;transform-origin:top left;" +
+ "transform:scale(0.5);width:200%;height:200%;"
+}, {
+ level: 1,
+ expected: "position:absolute;width:100%;height:100%;"
+}, {
+ level: .5,
+ expected: "position:absolute;transform-origin:top left;" +
+ "transform:scale(2);width:50%;height:50%;"
+}];
+
+add_task(function* () {
+ let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
+
+ info("Highlighting the test node");
+
+ yield hoverElement("div", inspector);
+ let isVisible = yield testActor.isHighlighting();
+ ok(isVisible, "The highlighter is visible");
+
+ for (let {level, expected} of TEST_LEVELS) {
+ info("Zoom to level " + level +
+ " and check that the highlighter is correct");
+
+ yield testActor.zoomPageTo(level);
+ isVisible = yield testActor.isHighlighting();
+ ok(isVisible, "The highlighter is still visible at zoom level " + level);
+
+ yield testActor.isNodeCorrectlyHighlighted("div", is);
+
+ info("Check that the highlighter root wrapper node was scaled down");
+
+ let style = yield getRootNodeStyle(testActor);
+ is(style, expected, "The style attribute of the root element is correct");
+ }
+});
+
+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* getRootNodeStyle(testActor) {
+ let value = yield testActor.getHighlighterNodeAttribute(
+ "box-model-root", "style");
+ return value;
+}