tor-browser

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

browser_inspector_search-navigation.js (2268B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Check that searchbox value is correct when suggestions popup is navigated
      6 // with keyboard.
      7 
      8 // Test data as pairs of [key to press, expected content of searchbox].
      9 const KEY_STATES = [
     10  ["d", "d"],
     11  ["i", "di"],
     12  ["v", "div"],
     13  [".", "div."],
     14  ["VK_UP", "div.l1"],
     15  ["VK_DOWN", "div.c1"],
     16  ["VK_DOWN", "div.l1"],
     17  ["VK_BACK_SPACE", "div.l"],
     18  ["VK_TAB", "div.l1"],
     19  [" ", "div.l1 "],
     20  ["VK_UP", "div.l1 span"],
     21  ["VK_UP", "div.l1 div"],
     22  ["VK_UP", "div.l1 span"],
     23  ["VK_UP", "div.l1 div"],
     24  [".", "div.l1 div."],
     25  ["VK_TAB", "div.l1 div.c1"],
     26  ["VK_BACK_SPACE", "div.l1 div.c"],
     27  ["VK_BACK_SPACE", "div.l1 div."],
     28  ["VK_BACK_SPACE", "div.l1 div"],
     29  ["VK_BACK_SPACE", "div.l1 di"],
     30  ["VK_BACK_SPACE", "div.l1 d"],
     31  ["VK_BACK_SPACE", "div.l1 "],
     32  ["VK_UP", "div.l1 span"],
     33  ["VK_UP", "div.l1 div"],
     34  ["VK_BACK_SPACE", "div.l1 di"],
     35  ["VK_BACK_SPACE", "div.l1 d"],
     36  ["VK_BACK_SPACE", "div.l1 "],
     37  ["VK_UP", "div.l1 span"],
     38  ["VK_UP", "div.l1 div"],
     39  ["VK_TAB", "div.l1 div"],
     40  ["VK_BACK_SPACE", "div.l1 di"],
     41  ["VK_BACK_SPACE", "div.l1 d"],
     42  ["VK_BACK_SPACE", "div.l1 "],
     43  ["VK_DOWN", "div.l1 span"],
     44  ["VK_DOWN", "div.l1 div"],
     45  ["VK_DOWN", "div.l1 span"],
     46  ["VK_BACK_SPACE", "div.l1 spa"],
     47  ["VK_BACK_SPACE", "div.l1 sp"],
     48  ["VK_BACK_SPACE", "div.l1 s"],
     49  ["VK_BACK_SPACE", "div.l1 "],
     50  ["VK_BACK_SPACE", "div.l1"],
     51  ["VK_BACK_SPACE", "div.l"],
     52  ["VK_BACK_SPACE", "div."],
     53  ["VK_BACK_SPACE", "div"],
     54  ["VK_BACK_SPACE", "di"],
     55  ["VK_BACK_SPACE", "d"],
     56  ["VK_BACK_SPACE", ""],
     57 ];
     58 
     59 const TEST_URL = URL_ROOT + "doc_inspector_search-suggestions.html";
     60 
     61 add_task(async function () {
     62  const { inspector } = await openInspectorForURL(TEST_URL);
     63  await focusSearchBoxUsingShortcut(inspector.panelWin);
     64 
     65  for (const [key, query] of KEY_STATES) {
     66    info("Pressing key " + key + " to get searchbox value as " + query);
     67 
     68    const done = inspector.searchSuggestions.once("processing-done");
     69    EventUtils.synthesizeKey(key, {}, inspector.panelWin);
     70 
     71    info("Waiting for search query to complete");
     72    await done;
     73 
     74    is(inspector.searchBox.value, query, "The searchbox value is correct");
     75  }
     76 });