browser/devtools/inspector/test/browser_inspector_infobar.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 function test() {
michael@0 5 waitForExplicitFinish();
michael@0 6 ignoreAllUncaughtExceptions();
michael@0 7
michael@0 8 let doc;
michael@0 9 let nodes;
michael@0 10 let cursor;
michael@0 11 let inspector;
michael@0 12
michael@0 13 gBrowser.selectedTab = gBrowser.addTab();
michael@0 14 gBrowser.selectedBrowser.addEventListener("load", function onload() {
michael@0 15 gBrowser.selectedBrowser.removeEventListener("load", onload, true);
michael@0 16 doc = content.document;
michael@0 17 waitForFocus(setupInfobarTest, content);
michael@0 18 }, true);
michael@0 19
michael@0 20 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 21 let html = "<style>" + style + "</style><div id=vertical></div><div id=top class='class1 class2'></div><div id=bottom></div><div id=farbottom></div>"
michael@0 22
michael@0 23 content.location = "data:text/html," + encodeURIComponent(html);
michael@0 24
michael@0 25 function setupInfobarTest() {
michael@0 26 nodes = [
michael@0 27 {node: doc.querySelector("#top"), position: "bottom", tag: "DIV", id: "#top", classes: ".class1.class2"},
michael@0 28 {node: doc.querySelector("#vertical"), position: "overlap", tag: "DIV", id: "#vertical", classes: ""},
michael@0 29 {node: doc.querySelector("#bottom"), position: "top", tag: "DIV", id: "#bottom", classes: ""},
michael@0 30 {node: doc.querySelector("body"), position: "overlap", tag: "BODY", id: "", classes: ""},
michael@0 31 {node: doc.querySelector("#farbottom"), position: "top", tag: "DIV", id: "#farbottom", classes: ""},
michael@0 32 ]
michael@0 33
michael@0 34 for (let i = 0; i < nodes.length; i++) {
michael@0 35 ok(nodes[i].node, "node " + i + " found");
michael@0 36 }
michael@0 37
michael@0 38 openInspector(runTests);
michael@0 39 }
michael@0 40
michael@0 41 function mouseOverContainerToShowHighlighter(node, cb) {
michael@0 42 let container = getContainerForRawNode(inspector.markup, node);
michael@0 43 EventUtils.synthesizeMouse(container.tagLine, 2, 2, {type: "mousemove"},
michael@0 44 inspector.markup.doc.defaultView);
michael@0 45 executeSoon(cb);
michael@0 46 }
michael@0 47
michael@0 48 function runTests(aInspector) {
michael@0 49 inspector = aInspector;
michael@0 50 inspector.selection.setNode(content.document.querySelector("body"));
michael@0 51 inspector.once("inspector-updated", () => {
michael@0 52 cursor = 0;
michael@0 53 executeSoon(function() {
michael@0 54 mouseOverContainerToShowHighlighter(nodes[0].node, nodeSelected);
michael@0 55 });
michael@0 56 });
michael@0 57 }
michael@0 58
michael@0 59 function nodeSelected() {
michael@0 60 executeSoon(function() {
michael@0 61 performTest();
michael@0 62 cursor++;
michael@0 63 if (cursor >= nodes.length) {
michael@0 64 finishUp();
michael@0 65 } else {
michael@0 66 let node = nodes[cursor].node;
michael@0 67 mouseOverContainerToShowHighlighter(node, nodeSelected);
michael@0 68 }
michael@0 69 });
michael@0 70 }
michael@0 71
michael@0 72 function performTest() {
michael@0 73 let browser = gBrowser.selectedBrowser;
michael@0 74 let stack = browser.parentNode;
michael@0 75
michael@0 76 let container = stack.querySelector(".highlighter-nodeinfobar-positioner");
michael@0 77 is(container.getAttribute("position"), nodes[cursor].position, "node " + cursor + ": position matches.");
michael@0 78
michael@0 79 let tagNameLabel = stack.querySelector(".highlighter-nodeinfobar-tagname");
michael@0 80 is(tagNameLabel.textContent, nodes[cursor].tag, "node " + cursor + ": tagName matches.");
michael@0 81
michael@0 82 let idLabel = stack.querySelector(".highlighter-nodeinfobar-id");
michael@0 83 is(idLabel.textContent, nodes[cursor].id, "node " + cursor + ": id matches.");
michael@0 84
michael@0 85 let classesBox = stack.querySelector(".highlighter-nodeinfobar-classes");
michael@0 86 is(classesBox.textContent, nodes[cursor].classes, "node " + cursor + ": classes match.");
michael@0 87 }
michael@0 88
michael@0 89 function finishUp() {
michael@0 90 doc = nodes = null;
michael@0 91 gBrowser.removeCurrentTab();
michael@0 92 finish();
michael@0 93 }
michael@0 94 }

mercurial