1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* 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";
// Check clicking on open-in-inspector icon does select the node in the inspector.
const HTML = `
<!DOCTYPE html>
<html>
<body>
<h1>Select node in inspector test</h1>
</body>
<script>
function logNode(selector) {
console.log(document.querySelector(selector));
}
</script>
</html>
`;
const TEST_URI = "data:text/html;charset=utf-8," + encodeURI(HTML);
add_task(async function () {
const hud = await openNewTabAndConsole(TEST_URI);
const toolbox = hud.toolbox;
// Loading the inspector panel at first, to make it possible to listen for
// new node selections
await toolbox.loadTool("inspector");
const inspector = toolbox.getPanel("inspector");
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
content.wrappedJSObject.logNode("h1");
});
const msg = await waitFor(() => findConsoleAPIMessage(hud, "<h1>"));
const node = msg.querySelector(".objectBox-node");
ok(node !== null, "Node was logged as expected");
const openInInspectorIcon = node.querySelector(".open-inspector");
ok(openInInspectorIcon !== null, "The is an open in inspector icon");
info(
"Clicking on the inspector icon and waiting for the " +
"inspector to be selected"
);
const onInspectorSelected = toolbox.once("inspector-selected");
const onInspectorUpdated = inspector.once("inspector-updated");
const onNewNode = toolbox.selection.once("new-node-front");
openInInspectorIcon.click();
await onInspectorSelected;
await onInspectorUpdated;
const nodeFront = await onNewNode;
ok(true, "Inspector selected and new node got selected");
is(nodeFront.displayName, "h1", "The expected node was selected");
is(
msg.querySelector(".arrow").classList.contains("expanded"),
false,
"The object inspector wasn't expanded"
);
});
|