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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that console commands are autocompleted.
const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>Test command autocomplete`;
const {
WebConsoleCommandsManager,
} = require("resource://devtools/server/actors/webconsole/commands/manager.js");
add_task(async function () {
const hud = await openNewTabAndConsole(TEST_URI);
const { jsterm } = hud;
const { autocompletePopup } = jsterm;
info(`Enter ":"`);
jsterm.focus();
let onAutocompleUpdated = jsterm.once("autocomplete-updated");
EventUtils.sendString(":");
await onAutocompleUpdated;
const expectedCommands =
WebConsoleCommandsManager.getAllColonCommandNames().map(name => `:${name}`);
ok(
hasExactPopupLabels(autocompletePopup, expectedCommands),
"popup contains expected commands"
);
onAutocompleUpdated = jsterm.once("autocomplete-updated");
EventUtils.sendString("s");
await onAutocompleUpdated;
checkInputCompletionValue(
hud,
"creenshot",
"completion node has expected :screenshot value"
);
onAutocompleUpdated = jsterm.once("autocomplete-updated");
EventUtils.synthesizeKey("KEY_Tab");
await onAutocompleUpdated;
is(
getInputValue(hud),
":screenshot",
"Tab key correctly completed :screenshot"
);
ok(!autocompletePopup.isOpen, "popup is closed after Tab");
info("Test :hel completion");
await setInputValue(hud, ":he");
onAutocompleUpdated = jsterm.once("autocomplete-updated");
EventUtils.sendString("l");
await onAutocompleUpdated;
checkInputCompletionValue(
hud,
"p",
"completion node has expected :help value"
);
EventUtils.synthesizeKey("KEY_Tab");
is(getInputValue(hud), ":help", "Tab key correctly completes :help");
});
|