browser_jsterm_autocomplete_toggle.js (2170B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Test for the input autocomplete option: check if the preference toggles the 5 // autocomplete feature in the console output. See bug 1593607. 6 7 "use strict"; 8 9 const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>`; 10 const PREF_INPUT_AUTOCOMPLETE = "devtools.webconsole.input.autocomplete"; 11 12 add_task(async function () { 13 // making sure that input autocomplete is true at the start of test 14 await pushPref(PREF_INPUT_AUTOCOMPLETE, true); 15 const hud = await openNewTabAndConsole(TEST_URI); 16 17 info( 18 "Check that console settings contain autocomplete input and its checked" 19 ); 20 await checkConsoleSettingState( 21 hud, 22 ".webconsole-console-settings-menu-item-autocomplete", 23 true 24 ); 25 26 info("Check that popup opens"); 27 const { jsterm } = hud; 28 29 const { autocompletePopup: popup } = jsterm; 30 31 info(`Enter "w"`); 32 await setInputValueForAutocompletion(hud, "w"); 33 34 ok(popup.isOpen, "autocomplete popup opens up"); 35 36 info("Clear input value"); 37 let onPopupClosed = popup.once("popup-closed"); 38 setInputValue(hud, ""); 39 await onPopupClosed; 40 ok(!popup.open, "autocomplete popup closed"); 41 42 info("toggle autocomplete preference"); 43 44 await toggleConsoleSetting( 45 hud, 46 ".webconsole-console-settings-menu-item-autocomplete" 47 ); 48 49 info("Checking that popup do not show"); 50 info(`Enter "w"`); 51 setInputValue(hud, "w"); 52 // delay of 2 seconds. 53 await wait(2000); 54 ok(!popup.isOpen, "popup is not open"); 55 56 info("toggling autocomplete pref back to true"); 57 await toggleConsoleSetting( 58 hud, 59 ".webconsole-console-settings-menu-item-autocomplete" 60 ); 61 62 const prefValue = Services.prefs.getBoolPref(PREF_INPUT_AUTOCOMPLETE); 63 ok(prefValue, "autocomplete pref value set to true"); 64 65 info("Check that popup opens"); 66 67 info(`Enter "w"`); 68 await setInputValueForAutocompletion(hud, "w"); 69 70 ok(popup.isOpen, "autocomplete popup opens up"); 71 72 info("Clear input value"); 73 onPopupClosed = popup.once("popup-closed"); 74 setInputValue(hud, ""); 75 await onPopupClosed; 76 ok(!popup.open, "autocomplete popup closed"); 77 });