michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: ignoreAllUncaughtExceptions(); michael@0: michael@0: let doc; michael@0: let nodes; michael@0: let cursor; michael@0: let inspector; michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function onload() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", onload, true); michael@0: doc = content.document; michael@0: waitForFocus(setupInfobarTest, content); michael@0: }, true); michael@0: michael@0: let style = "body{width:100%;height: 100%} div {position: absolute;height: 100px;width: 500px}#bottom {bottom: 0px}#vertical {height: 100%}#farbottom{bottom: -200px}"; michael@0: let html = "
" michael@0: michael@0: content.location = "data:text/html," + encodeURIComponent(html); michael@0: michael@0: function setupInfobarTest() { michael@0: nodes = [ michael@0: {node: doc.querySelector("#top"), position: "bottom", tag: "DIV", id: "#top", classes: ".class1.class2"}, michael@0: {node: doc.querySelector("#vertical"), position: "overlap", tag: "DIV", id: "#vertical", classes: ""}, michael@0: {node: doc.querySelector("#bottom"), position: "top", tag: "DIV", id: "#bottom", classes: ""}, michael@0: {node: doc.querySelector("body"), position: "overlap", tag: "BODY", id: "", classes: ""}, michael@0: {node: doc.querySelector("#farbottom"), position: "top", tag: "DIV", id: "#farbottom", classes: ""}, michael@0: ] michael@0: michael@0: for (let i = 0; i < nodes.length; i++) { michael@0: ok(nodes[i].node, "node " + i + " found"); michael@0: } michael@0: michael@0: openInspector(runTests); michael@0: } michael@0: michael@0: function mouseOverContainerToShowHighlighter(node, cb) { michael@0: let container = getContainerForRawNode(inspector.markup, node); michael@0: EventUtils.synthesizeMouse(container.tagLine, 2, 2, {type: "mousemove"}, michael@0: inspector.markup.doc.defaultView); michael@0: executeSoon(cb); michael@0: } michael@0: michael@0: function runTests(aInspector) { michael@0: inspector = aInspector; michael@0: inspector.selection.setNode(content.document.querySelector("body")); michael@0: inspector.once("inspector-updated", () => { michael@0: cursor = 0; michael@0: executeSoon(function() { michael@0: mouseOverContainerToShowHighlighter(nodes[0].node, nodeSelected); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function nodeSelected() { michael@0: executeSoon(function() { michael@0: performTest(); michael@0: cursor++; michael@0: if (cursor >= nodes.length) { michael@0: finishUp(); michael@0: } else { michael@0: let node = nodes[cursor].node; michael@0: mouseOverContainerToShowHighlighter(node, nodeSelected); michael@0: } michael@0: }); michael@0: } michael@0: michael@0: function performTest() { michael@0: let browser = gBrowser.selectedBrowser; michael@0: let stack = browser.parentNode; michael@0: michael@0: let container = stack.querySelector(".highlighter-nodeinfobar-positioner"); michael@0: is(container.getAttribute("position"), nodes[cursor].position, "node " + cursor + ": position matches."); michael@0: michael@0: let tagNameLabel = stack.querySelector(".highlighter-nodeinfobar-tagname"); michael@0: is(tagNameLabel.textContent, nodes[cursor].tag, "node " + cursor + ": tagName matches."); michael@0: michael@0: let idLabel = stack.querySelector(".highlighter-nodeinfobar-id"); michael@0: is(idLabel.textContent, nodes[cursor].id, "node " + cursor + ": id matches."); michael@0: michael@0: let classesBox = stack.querySelector(".highlighter-nodeinfobar-classes"); michael@0: is(classesBox.textContent, nodes[cursor].classes, "node " + cursor + ": classes match."); michael@0: } michael@0: michael@0: function finishUp() { michael@0: doc = nodes = null; michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: } michael@0: }