browser_jsterm_autocomplete_disabled.js (1905B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that disabling autocomplete for console 7 8 const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>Test command autocomplete`; 9 10 add_task(async function () { 11 // Run with autocomplete preference as false 12 await pushPref("devtools.webconsole.input.autocomplete", false); 13 await performTests_false(); 14 }); 15 16 async function performTests_false() { 17 const hud = await openNewTabAndConsole(TEST_URI); 18 const { jsterm } = hud; 19 info("web console opened"); 20 21 const { autocompletePopup: popup } = hud.jsterm; 22 23 info(`Enter "w"`); 24 jsterm.focus(); 25 EventUtils.sendString("w"); 26 // delay of 2 seconds. 27 await wait(2000); 28 ok(!popup.isOpen, "popup is not open"); 29 30 info("Check that Ctrl+Space opens the popup when preference is false"); 31 let onUpdated = jsterm.once("autocomplete-updated"); 32 EventUtils.synthesizeKey(" ", { ctrlKey: true }); 33 await onUpdated; 34 35 ok(popup.isOpen, "popup opens on Ctrl+Space"); 36 ok(!!popup.getItems().length, "'w' gave a list of suggestions"); 37 38 onUpdated = jsterm.once("autocomplete-updated"); 39 EventUtils.synthesizeKey("in"); 40 await onUpdated; 41 Assert.equal(popup.getItems().length, 2, "'win' gave a list of suggestions"); 42 43 info("Check that the completion text is updated when it was displayed"); 44 await setInputValue(hud, ""); 45 EventUtils.sendString("deb"); 46 let updated = jsterm.once("autocomplete-updated"); 47 EventUtils.synthesizeKey(" ", { ctrlKey: true }); 48 await updated; 49 50 ok(!popup.isOpen, "popup is not open"); 51 is( 52 jsterm.getAutoCompletionText(), 53 "ugger", 54 "completion text has expected value" 55 ); 56 57 updated = jsterm.once("autocomplete-updated"); 58 EventUtils.sendString("u"); 59 await updated; 60 is( 61 jsterm.getAutoCompletionText(), 62 "gger", 63 "completion text has expected value" 64 ); 65 }