fune/devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_commands.js
Narcis Beleuzu 6c99b443b3 Backed out 2 changesets (bug 1616847, bug 1609942) for dt failures on browser_jsterm_autocomplete_control_space.js . CLOSED TREE
Backed out changeset c1d7d5e9a18b (bug 1609942)
Backed out changeset 7a5178ee8cd2 (bug 1616847)
2020-02-28 22:05:05 +02:00

64 lines
1.6 KiB
JavaScript

/* 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,Test command autocomplete`;
add_task(async function() {
const hud = await openNewTabAndConsole(TEST_URI);
const { jsterm } = hud;
const { autocompletePopup } = jsterm;
const onPopUpOpen = autocompletePopup.once("popup-opened");
info(`Enter ":"`);
jsterm.focus();
EventUtils.sendString(":");
await onPopUpOpen;
const expectedCommands = [":help", ":screenshot"];
is(
getAutocompletePopupLabels(autocompletePopup).join("\n"),
expectedCommands.join("\n"),
"popup contains expected commands"
);
let 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");
});