tor-browser

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

browser_grids_display-setting-show-grid-line-numbers.js (1815B)


      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 'Display numbers on lines' grid highlighter setting will update
      7 // the redux store and pref setting.
      8 
      9 const TEST_URI = `
     10  <style type='text/css'>
     11    #grid {
     12      display: grid;
     13    }
     14  </style>
     15  <div id="grid">
     16    <div id="cell1">cell1</div>
     17    <div id="cell2">cell2</div>
     18  </div>
     19 `;
     20 
     21 const SHOW_GRID_LINE_NUMBERS = "devtools.gridinspector.showGridLineNumbers";
     22 
     23 add_task(async function () {
     24  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     25  const { inspector, gridInspector } = await openLayoutView();
     26  const { document: doc } = gridInspector;
     27  const { store } = inspector;
     28 
     29  await selectNode("#grid", inspector);
     30  const checkbox = doc.getElementById("grid-setting-show-grid-line-numbers");
     31 
     32  info("Checking the initial state of the CSS grid highlighter setting.");
     33  ok(
     34    !Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
     35    "'Display numbers on lines' is pref off by default."
     36  );
     37 
     38  info("Toggling ON the 'Display numbers on lines' setting.");
     39  let onCheckboxChange = waitUntilState(
     40    store,
     41    state => state.highlighterSettings.showGridLineNumbers
     42  );
     43  checkbox.click();
     44  await onCheckboxChange;
     45 
     46  ok(
     47    Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
     48    "'Display numbers on lines' is pref on."
     49  );
     50 
     51  info("Toggling OFF the 'Display numbers on lines' setting.");
     52  onCheckboxChange = waitUntilState(
     53    store,
     54    state => !state.highlighterSettings.showGridLineNumbers
     55  );
     56  checkbox.click();
     57  await onCheckboxChange;
     58 
     59  ok(
     60    !Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
     61    "'Display numbers on lines' is pref off."
     62  );
     63 
     64  Services.prefs.clearUserPref(SHOW_GRID_LINE_NUMBERS);
     65 });