From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../browser_inspector_highlighter-geometry_01.js | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 devtools/client/inspector/test/browser_inspector_highlighter-geometry_01.js (limited to 'devtools/client/inspector/test/browser_inspector_highlighter-geometry_01.js') diff --git a/devtools/client/inspector/test/browser_inspector_highlighter-geometry_01.js b/devtools/client/inspector/test/browser_inspector_highlighter-geometry_01.js new file mode 100644 index 000000000..28a20998c --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_highlighter-geometry_01.js @@ -0,0 +1,89 @@ +/* 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 the creation of the geometry highlighter elements. + +const TEST_URL = `data:text/html;charset=utf-8, + +
+
`; + +const HIGHLIGHTER_TYPE = "GeometryEditorHighlighter"; + +const ID = "geometry-editor-"; +const SIDES = ["left", "right", "top", "bottom"]; + +add_task(function* () { + let helper = yield openInspectorForURL(TEST_URL) + .then(getHighlighterHelperFor(HIGHLIGHTER_TYPE)); + + let { finalize } = helper; + + helper.prefix = ID; + + yield hasArrowsAndLabelsAndHandlers(helper); + yield isHiddenForNonPositionedNonSizedElement(helper); + yield sideArrowsAreDisplayedForPositionedNode(helper); + + finalize(); +}); + +function* hasArrowsAndLabelsAndHandlers({getElementAttribute}) { + info("Checking that the highlighter has the expected arrows and labels"); + + for (let name of [...SIDES]) { + let value = yield getElementAttribute("arrow-" + name, "class"); + is(value, ID + "arrow " + name, "The " + name + " arrow exists"); + + value = yield getElementAttribute("label-text-" + name, "class"); + is(value, ID + "label-text", "The " + name + " label exists"); + + value = yield getElementAttribute("handler-" + name, "class"); + is(value, ID + "handler-" + name, "The " + name + " handler exists"); + } +} + +function* isHiddenForNonPositionedNonSizedElement( + {show, hide, isElementHidden}) { + info("Asking to show the highlighter on an inline, non p ositioned element"); + + yield show("#inline"); + + for (let name of [...SIDES]) { + let hidden = yield isElementHidden("arrow-" + name); + ok(hidden, "The " + name + " arrow is hidden"); + + hidden = yield isElementHidden("handler-" + name); + ok(hidden, "The " + name + " handler is hidden"); + } +} + +function* sideArrowsAreDisplayedForPositionedNode( + {show, hide, isElementHidden}) { + info("Asking to show the highlighter on the positioned node"); + + yield show("#positioned"); + + for (let name of SIDES) { + let hidden = yield isElementHidden("arrow-" + name); + ok(!hidden, "The " + name + " arrow is visible for the positioned node"); + + hidden = yield isElementHidden("handler-" + name); + ok(!hidden, "The " + name + " handler is visible for the positioned node"); + } + + info("Hiding the highlighter"); + yield hide(); +} -- cgit v1.2.3