tor-browser

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

browser_jsterm_autocomplete-properties-with-non-alphanumeric-names.js (1382B)


      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 properties starting with underscores or dollars can be
      7 // autocompleted (bug 967468).
      8 const TEST_URI = `data:text/html;charset=utf8,<!DOCTYPE html>test autocompletion with $ or _`;
      9 
     10 add_task(async function () {
     11  const hud = await openNewTabAndConsole(TEST_URI);
     12 
     13  await executeAndWaitForResultMessage(
     14    hud,
     15    "var testObject = {$$aaab: '', $$aaac: ''}",
     16    ""
     17  );
     18 
     19  // Should work with bug 967468.
     20  await testAutocomplete(hud, "Object.__d");
     21  await testAutocomplete(hud, "testObject.$$a");
     22 
     23  // Here's when things go wrong in bug 967468.
     24  await testAutocomplete(hud, "Object.__de");
     25  await testAutocomplete(hud, "testObject.$$aa");
     26 
     27  // Should work with bug 1207868.
     28  await executeAndWaitForResultMessage(
     29    hud,
     30    "let foobar = {a: ''}; const blargh = {a: 1};",
     31    ""
     32  );
     33  await testAutocomplete(hud, "foobar");
     34  await testAutocomplete(hud, "blargh");
     35  await testAutocomplete(hud, "foobar.a");
     36  await testAutocomplete(hud, "blargh.a");
     37 });
     38 
     39 async function testAutocomplete(hud, inputString) {
     40  await setInputValueForAutocompletion(hud, inputString);
     41  const popup = hud.jsterm.autocompletePopup;
     42  Assert.greater(
     43    popup.itemCount,
     44    0,
     45    `There's ${popup.itemCount} suggestions for '${inputString}'`
     46  );
     47 }