summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/markup/test/browser_markup_accessibility_focus_blur.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/markup/test/browser_markup_accessibility_focus_blur.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/inspector/markup/test/browser_markup_accessibility_focus_blur.js')
-rw-r--r--devtools/client/inspector/markup/test/browser_markup_accessibility_focus_blur.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/devtools/client/inspector/markup/test/browser_markup_accessibility_focus_blur.js b/devtools/client/inspector/markup/test/browser_markup_accessibility_focus_blur.js
new file mode 100644
index 0000000000..6be70144d8
--- /dev/null
+++ b/devtools/client/inspector/markup/test/browser_markup_accessibility_focus_blur.js
@@ -0,0 +1,77 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// Test inspector markup view handling focus and blur when moving between markup
+// view, its root and other containers, and other parts of inspector.
+
+add_task(async function () {
+ const { inspector } = await openInspectorForURL(
+ "data:text/html;charset=utf-8,<h1>foo</h1><span>bar</span>"
+ );
+ const markup = inspector.markup;
+ const doc = markup.doc;
+ const win = doc.defaultView;
+
+ const spanContainer = await getContainerForSelector("span", inspector);
+ const rootContainer = markup.getContainer(markup._rootNode);
+
+ is(
+ doc.activeElement,
+ doc.body,
+ "Keyboard focus by default is on document body"
+ );
+
+ await selectNode("span", inspector);
+
+ is(doc.activeElement, doc.body, "Keyboard focus is still on document body");
+
+ info("Focusing on the test span node using 'Return' key");
+ // Focus on the tree element.
+ rootContainer.elt.focus();
+ EventUtils.synthesizeKey("VK_RETURN", {}, win);
+
+ is(
+ doc.activeElement,
+ spanContainer.editor.tag,
+ "Keyboard focus should be on tag element of focused container"
+ );
+
+ info("Focusing on search box, external to markup view document");
+ await focusSearchBoxUsingShortcut(inspector.panelWin);
+
+ is(
+ doc.activeElement,
+ doc.body,
+ "Keyboard focus should be removed from focused container"
+ );
+
+ info("Selecting the test span node again");
+ await selectNode("span", inspector);
+
+ is(
+ doc.activeElement,
+ doc.body,
+ "Keyboard focus should again be on document body"
+ );
+
+ info("Focusing on the test span node using 'Space' key");
+ // Focus on the tree element.
+ rootContainer.elt.focus();
+ EventUtils.synthesizeKey("VK_SPACE", {}, win);
+
+ is(
+ doc.activeElement,
+ spanContainer.editor.tag,
+ "Keyboard focus should again be on tag element of focused container"
+ );
+
+ await clickOnInspectMenuItem("h1");
+ is(
+ doc.activeElement,
+ rootContainer.elt,
+ "When inspect menu item is used keyboard focus should move to tree."
+ );
+});