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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Testing navigation between nodes in search results
const TEST_URL = URL_ROOT + "doc_inspector_search.html";
add_task(async function () {
const { inspector } = await openInspectorForURL(TEST_URL);
info("Focus the search box");
await focusSearchBoxUsingShortcut(inspector.panelWin);
info("Enter body > p to search");
const searchText = "body > p";
// EventUtils.sendString will trigger multiple updates, so wait until the final one.
const processingDone = new Promise(resolve => {
const off = inspector.searchSuggestions.on("processing-done", data => {
if (data.query == searchText) {
resolve();
off();
}
});
});
EventUtils.sendString(searchText, inspector.panelWin);
info("Wait for search query to complete");
await processingDone;
let msg = "Press enter and expect a new selection";
await sendKeyAndCheck(inspector, msg, "VK_RETURN", {}, "#p1");
msg = "Press enter to cycle through multiple nodes";
await sendKeyAndCheck(inspector, msg, "VK_RETURN", {}, "#p2");
msg = "Press shift-enter to select the previous node";
await sendKeyAndCheck(inspector, msg, "VK_RETURN", { shiftKey: true }, "#p1");
if (AppConstants.platform === "macosx") {
msg = "Press meta-g to cycle through multiple nodes";
await sendKeyAndCheck(inspector, msg, "VK_G", { metaKey: true }, "#p2");
msg = "Press shift+meta-g to select the previous node";
await sendKeyAndCheck(
inspector,
msg,
"VK_G",
{ metaKey: true, shiftKey: true },
"#p1"
);
} else {
msg = "Press ctrl-g to cycle through multiple nodes";
await sendKeyAndCheck(inspector, msg, "VK_G", { ctrlKey: true }, "#p2");
msg = "Press shift+ctrl-g to select the previous node";
await sendKeyAndCheck(
inspector,
msg,
"VK_G",
{ ctrlKey: true, shiftKey: true },
"#p1"
);
}
});
const sendKeyAndCheck = async function (
inspector,
description,
key,
modifiers,
expectedId
) {
info(description);
const onSelect = inspector.once("inspector-updated");
EventUtils.synthesizeKey(key, modifiers, inspector.panelWin);
await onSelect;
const selectedNode = inspector.selection.nodeFront;
info(selectedNode.id + " is selected with text " + inspector.searchBox.value);
const targetNode = await getNodeFront(expectedId, inspector);
is(selectedNode, targetNode, "Correct node " + expectedId + " is selected");
};
|