tor-browser

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

browser_inspector_search-10.js (1645B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Bug 1830111 - Test that searching elements while having hidden <iframe> works
      6 
      7 const HTML = `
      8  <!DOCTYPE html>
      9  <html>
     10    <body>
     11      <!-- The nested iframe, will be a children node of the top iframe
     12           but won't be displayed, not considered as valid children by the inspector -->
     13      <iframe><iframe></iframe></iframe>
     14      <div>after iframe</<div>
     15      <script>
     16        document.querySelector("iframe").appendChild(document.createElement("iframe"));
     17      </script>
     18    </body>
     19  </html>
     20 `;
     21 
     22 const TEST_URI = "data:text/html;charset=utf-8," + encodeURI(HTML);
     23 
     24 add_task(async function () {
     25  const { inspector } = await openInspectorForURL(TEST_URI);
     26 
     27  await focusSearchBoxUsingShortcut(inspector.panelWin);
     28 
     29  const onSearchProcessingDone =
     30    inspector.searchSuggestions.once("processing-done");
     31  synthesizeKeys("div", inspector.panelWin);
     32  info("Waiting for search query to complete");
     33  await onSearchProcessingDone;
     34 
     35  const popup = inspector.searchSuggestions.searchPopup;
     36  const actualSuggestions = popup.getItems().map(item => item.label);
     37  Assert.deepEqual(
     38    actualSuggestions,
     39    ["div"],
     40    "autocomplete popup displays the right suggestions"
     41  );
     42 
     43  const onSearchResult = inspector.search.once("search-result");
     44  EventUtils.synthesizeKey("VK_RETURN", {}, inspector.panelWin);
     45 
     46  info("Waiting for results");
     47  await onSearchResult;
     48 
     49  const nodeFront = await getNodeFront("div", inspector);
     50  is(inspector.selection.nodeFront, nodeFront, "The <div> element is selected");
     51 });