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 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 // Test that inspector links in webconsole outputs for DOM Nodes highlight
7 // the actual DOM Nodes on hover
9 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-output-dom-elements.html";
11 function test() {
12 Task.spawn(function*() {
13 let {tab} = yield loadTab(TEST_URI);
14 let hud = yield openConsole(tab);
15 let toolbox = gDevTools.getToolbox(hud.target);
17 // Loading the inspector panel at first, to make it possible to listen for
18 // new node selections
19 yield toolbox.loadTool("inspector");
20 let inspector = toolbox.getPanel("inspector");
22 info("Executing 'testNode()' in the web console to output a DOM Node");
23 let [result] = yield jsEval("testNode()", hud, {
24 text: '<p some-attribute="some-value">'
25 });
27 let elementNodeWidget = yield getWidget(result);
29 let nodeFront = yield hoverOverWidget(elementNodeWidget, toolbox);
30 let attrs = nodeFront.attributes;
31 is(nodeFront.tagName, "P", "The correct node was highlighted");
32 is(attrs[0].name, "some-attribute", "The correct node was highlighted");
33 is(attrs[0].value, "some-value", "The correct node was highlighted");
34 }).then(finishTest);
35 }
37 function jsEval(input, hud, message) {
38 hud.jsterm.execute(input);
39 return waitForMessages({
40 webconsole: hud,
41 messages: [message]
42 });
43 }
45 function* getWidget(result) {
46 info("Getting the output ElementNode widget");
48 let msg = [...result.matched][0];
49 let elementNodeWidget = [...msg._messageObject.widgets][0];
50 ok(elementNodeWidget, "ElementNode widget found in the output");
52 info("Waiting for the ElementNode widget to be linked to the inspector");
53 yield elementNodeWidget.linkToInspector();
55 return elementNodeWidget;
56 }
58 function* hoverOverWidget(widget, toolbox) {
59 info("Hovering over the output to highlight the node");
61 let onHighlight = toolbox.once("node-highlight");
62 EventUtils.sendMouseEvent({type: "mouseover"}, widget.element,
63 widget.element.ownerDocument.defaultView);
64 let nodeFront = yield onHighlight;
65 ok(true, "The highlighter was shown on a node");
66 return nodeFront;
67 }