tor-browser

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

browser_jsterm_history_nav.js (1640B)


      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 660806. Check that history navigation with the UP/DOWN arrows does not trigger
      7 // autocompletion.
      8 
      9 const TEST_URI =
     10  "data:text/html;charset=utf-8,<!DOCTYPE html><p>bug 660806 - history " +
     11  "navigation must not show the autocomplete popup";
     12 
     13 add_task(async function () {
     14  const hud = await openNewTabAndConsole(TEST_URI);
     15  const { jsterm } = hud;
     16  const popup = jsterm.autocompletePopup;
     17 
     18  // The autocomplete popup should never be displayed during the test.
     19  const onShown = function () {
     20    ok(false, "popup shown");
     21  };
     22  popup.on("popup-opened", onShown);
     23 
     24  await executeAndWaitForResultMessage(
     25    hud,
     26    `window.foobarBug660806 = {
     27    'location': 'value0',
     28    'locationbar': 'value1'
     29  }`,
     30    ""
     31  );
     32  ok(!popup.isOpen, "popup is not open");
     33 
     34  // Let's add this expression in the input history. We don't use setInputValue since
     35  // it _does_ trigger an autocompletion request in codeMirror JsTerm.
     36  await executeAndWaitForResultMessage(
     37    hud,
     38    "window.foobarBug660806.location",
     39    ""
     40  );
     41 
     42  const onSetInputValue = jsterm.once("set-input-value");
     43  EventUtils.synthesizeKey("KEY_ArrowUp");
     44  await onSetInputValue;
     45 
     46  // We don't have an explicit event to wait for here, so we just wait for the next tick
     47  // before checking the popup status.
     48  await new Promise(executeSoon);
     49 
     50  is(
     51    getInputValue(hud),
     52    "window.foobarBug660806.location",
     53    "input has expected value"
     54  );
     55 
     56  ok(!popup.isOpen, "popup is not open");
     57  popup.off("popup-opened", onShown);
     58 });