browser_jsterm_autocomplete_will_navigate.js (1391B)
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 navigating the page closes the autocomplete popup. 7 8 const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html> 9 <head> 10 <script> 11 /* Create a prototype-less object so popup does not contain native 12 * Object prototype properties. 13 */ 14 window.foo = Object.create(null, Object.getOwnPropertyDescriptors({ 15 item0: "value0", 16 item1: "value1", 17 })); 18 </script> 19 </head> 20 <body>Test autocomplete close on content navigation</body>`; 21 22 add_task(async function () { 23 const hud = await openNewTabAndConsole(TEST_URI); 24 const { jsterm } = hud; 25 info("web console opened"); 26 27 const { autocompletePopup: popup } = jsterm; 28 29 const onPopUpOpen = popup.once("popup-opened"); 30 31 info("wait for completion: window.foo."); 32 setInputValue(hud, "window.foo"); 33 EventUtils.sendString("."); 34 35 await onPopUpOpen; 36 37 ok(popup.isOpen, "popup is open"); 38 ok(popup.itemCount, "popup has items"); 39 40 info("reload the page to close the popup"); 41 const onPopupClose = popup.once("popup-closed"); 42 await reloadBrowser(); 43 await onPopupClose; 44 45 ok(!popup.isOpen, "popup is not open after reloading the page"); 46 is(getInputValue(hud), "window.foo.", "completion was cancelled"); 47 ok(!getInputCompletionValue(hud), "completeNode is empty"); 48 });