summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js b/devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js
new file mode 100644
index 0000000000..3dee2533cd
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js
@@ -0,0 +1,65 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the 'Display numbers on lines' grid highlighter setting will update
+// the redux store and pref setting.
+
+const TEST_URI = `
+ <style type='text/css'>
+ #grid {
+ display: grid;
+ }
+ </style>
+ <div id="grid">
+ <div id="cell1">cell1</div>
+ <div id="cell2">cell2</div>
+ </div>
+`;
+
+const SHOW_GRID_LINE_NUMBERS = "devtools.gridinspector.showGridLineNumbers";
+
+add_task(async function () {
+ await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ const { inspector, gridInspector } = await openLayoutView();
+ const { document: doc } = gridInspector;
+ const { store } = inspector;
+
+ await selectNode("#grid", inspector);
+ const checkbox = doc.getElementById("grid-setting-show-grid-line-numbers");
+
+ info("Checking the initial state of the CSS grid highlighter setting.");
+ ok(
+ !Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
+ "'Display numbers on lines' is pref off by default."
+ );
+
+ info("Toggling ON the 'Display numbers on lines' setting.");
+ let onCheckboxChange = waitUntilState(
+ store,
+ state => state.highlighterSettings.showGridLineNumbers
+ );
+ checkbox.click();
+ await onCheckboxChange;
+
+ ok(
+ Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
+ "'Display numbers on lines' is pref on."
+ );
+
+ info("Toggling OFF the 'Display numbers on lines' setting.");
+ onCheckboxChange = waitUntilState(
+ store,
+ state => !state.highlighterSettings.showGridLineNumbers
+ );
+ checkbox.click();
+ await onCheckboxChange;
+
+ ok(
+ !Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
+ "'Display numbers on lines' is pref off."
+ );
+
+ Services.prefs.clearUserPref(SHOW_GRID_LINE_NUMBERS);
+});