tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_jsterm_autocomplete_escape_key.js (1357B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // See Bug 585991.
      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);
     15    Object.assign(window.foo, {
     16      item0: "value0",
     17      item1: "value1",
     18    });
     19  </script>
     20 </head>
     21 <body>bug 585991 - autocomplete popup escape key usage test</body>`;
     22 
     23 add_task(async function () {
     24  const hud = await openNewTabAndConsole(TEST_URI);
     25  const { jsterm } = hud;
     26  info("web console opened");
     27 
     28  const { autocompletePopup: popup } = jsterm;
     29 
     30  const onPopUpOpen = popup.once("popup-opened");
     31 
     32  info("wait for completion: window.foo.");
     33  setInputValue(hud, "window.foo");
     34  EventUtils.sendString(".");
     35 
     36  await onPopUpOpen;
     37 
     38  ok(popup.isOpen, "popup is open");
     39  ok(popup.itemCount, "popup has items");
     40 
     41  info("press Escape to close the popup");
     42  const onPopupClose = popup.once("popup-closed");
     43  EventUtils.synthesizeKey("KEY_Escape");
     44 
     45  await onPopupClose;
     46 
     47  ok(!popup.isOpen, "popup is not open after VK_ESCAPE");
     48  is(getInputValue(hud), "window.foo.", "completion was cancelled");
     49  ok(!getInputCompletionValue(hud), "completeNode is empty");
     50 });