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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that disabling autocomplete for console
const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>Test command autocomplete`;
add_task(async function () {
// Run with autocomplete preference as false
await pushPref("devtools.webconsole.input.autocomplete", false);
await performTests_false();
});
async function performTests_false() {
const hud = await openNewTabAndConsole(TEST_URI);
const { jsterm } = hud;
info("web console opened");
const { autocompletePopup: popup } = hud.jsterm;
info(`Enter "w"`);
jsterm.focus();
EventUtils.sendString("w");
// delay of 2 seconds.
await wait(2000);
ok(!popup.isOpen, "popup is not open");
info("Check that Ctrl+Space opens the popup when preference is false");
let onUpdated = jsterm.once("autocomplete-updated");
EventUtils.synthesizeKey(" ", { ctrlKey: true });
await onUpdated;
ok(popup.isOpen, "popup opens on Ctrl+Space");
ok(!!popup.getItems().length, "'w' gave a list of suggestions");
onUpdated = jsterm.once("autocomplete-updated");
EventUtils.synthesizeKey("in");
await onUpdated;
ok(popup.getItems().length == 2, "'win' gave a list of suggestions");
info("Check that the completion text is updated when it was displayed");
await setInputValue(hud, "");
EventUtils.sendString("deb");
let updated = jsterm.once("autocomplete-updated");
EventUtils.synthesizeKey(" ", { ctrlKey: true });
await updated;
ok(!popup.isOpen, "popup is not open");
is(
jsterm.getAutoCompletionText(),
"ugger",
"completion text has expected value"
);
updated = jsterm.once("autocomplete-updated");
EventUtils.sendString("u");
await updated;
is(
jsterm.getAutoCompletionText(),
"gger",
"completion text has expected value"
);
}
|