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