tor-browser

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

browser_computed_no-results-placeholder.js (2058B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests that the no results placeholder works properly.
      7 
      8 const TEST_URI = `
      9  <style type="text/css">
     10    .matches {
     11      color: #F00;
     12    }
     13  </style>
     14  <span id="matches" class="matches">Some styled text</span>
     15 `;
     16 
     17 add_task(async function () {
     18  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     19  const { inspector, view } = await openComputedView();
     20  await selectNode("#matches", inspector);
     21 
     22  await enterInvalidFilter(inspector, view);
     23  checkNoResultsPlaceholderShown(view);
     24 
     25  await clearFilterText(inspector, view);
     26  checkNoResultsPlaceholderHidden(view);
     27 });
     28 
     29 async function enterInvalidFilter(inspector, computedView) {
     30  const searchbar = computedView.searchField;
     31  const searchTerm = "xxxxx";
     32 
     33  info('setting filter text to "' + searchTerm + '"');
     34 
     35  const onRefreshed = inspector.once("computed-view-refreshed");
     36  searchbar.focus();
     37  synthesizeKeys(searchTerm, computedView.styleWindow);
     38  await onRefreshed;
     39 }
     40 
     41 function checkNoResultsPlaceholderShown(computedView) {
     42  info("Checking that the no results placeholder is shown");
     43 
     44  const placeholder = computedView.noResults;
     45  const win = computedView.styleWindow;
     46  const display = win.getComputedStyle(placeholder).display;
     47  is(display, "block", "placeholder is visible");
     48 }
     49 
     50 async function clearFilterText(inspector, computedView) {
     51  info("Clearing the filter text");
     52 
     53  const searchbar = computedView.searchField;
     54 
     55  const onRefreshed = inspector.once("computed-view-refreshed");
     56  searchbar.focus();
     57  searchbar.value = "";
     58  EventUtils.synthesizeKey("c", {}, computedView.styleWindow);
     59  await onRefreshed;
     60 }
     61 
     62 function checkNoResultsPlaceholderHidden(computedView) {
     63  info("Checking that the no results placeholder is hidden");
     64 
     65  const placeholder = computedView.noResults;
     66  const win = computedView.styleWindow;
     67  const display = win.getComputedStyle(placeholder).display;
     68  is(display, "none", "placeholder is hidden");
     69 }