browser_jsterm_autocomplete_null.js (2297B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function () { 7 await pushPref("devtools.chrome.enabled", true); 8 await addTab("about:blank"); 9 10 info(`Open browser console with ctrl-shift-j`); 11 // we're using the browser console so we can check for error messages that would be 12 // caused by console code. 13 const opened = waitForBrowserConsole(); 14 EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window); 15 const hud = await opened; 16 const { jsterm } = hud; 17 const { autocompletePopup: popup } = jsterm; 18 19 info(`Clear existing messages`); 20 const onMessagesCleared = hud.ui.once("messages-cleared"); 21 await clearOutput(hud); 22 await onMessagesCleared; 23 24 info(`Create a null variable`); 25 // Using the commands directly as we don't want to impact the UI state. 26 await hud.commands.scriptCommand.execute("globalThis.nullVar = null"); 27 28 info(`Check completion suggestions for "null"`); 29 await setInputValueForAutocompletion(hud, "null"); 30 ok(popup.isOpen, "popup is open"); 31 const expectedPopupItems = ["null", "nullVar"]; 32 ok( 33 hasExactPopupLabels(popup, expectedPopupItems), 34 "popup has expected items" 35 ); 36 37 info(`Check completion suggestions for "null."`); 38 let onAutocompleteUpdated = jsterm.once("autocomplete-updated"); 39 EventUtils.sendString(".", hud.iframeWindow); 40 await onAutocompleteUpdated; 41 is(popup.itemCount, 0, "popup has no items"); 42 43 info(`Check completion suggestions for "null"`); 44 onAutocompleteUpdated = jsterm.once("autocomplete-updated"); 45 EventUtils.synthesizeKey("KEY_Backspace", undefined, hud.iframeWindow); 46 await onAutocompleteUpdated; 47 is(popup.itemCount, 2, "popup has 2 items"); 48 49 info(`Check completion suggestions for "nullVar"`); 50 onAutocompleteUpdated = jsterm.once("autocomplete-updated"); 51 EventUtils.sendString("Var.", hud.iframeWindow); 52 await onAutocompleteUpdated; 53 is(popup.itemCount, 0, "popup has no items"); 54 is(popup.isOpen, false, "popup is closed"); 55 56 info(`Check that no error was logged`); 57 await waitForTimeout( 58 () => findErrorMessage(hud, "", ":not(.network)"), 59 "No error was logged" 60 ); 61 62 info(`Cleanup`); 63 await hud.commands.scriptCommand.execute("delete globalThis.nullVar"); 64 });