From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001
From: Daniel Baumann
Date: Fri, 19 Apr 2024 02:47:55 +0200
Subject: Adding upstream version 124.0.1.
Signed-off-by: Daniel Baumann
---
.../browser_inplace-editor_focus_closest_editor.js | 180 +++++++++++++++++++++
1 file changed, 180 insertions(+)
create mode 100644 devtools/client/shared/test/browser_inplace-editor_focus_closest_editor.js
(limited to 'devtools/client/shared/test/browser_inplace-editor_focus_closest_editor.js')
diff --git a/devtools/client/shared/test/browser_inplace-editor_focus_closest_editor.js b/devtools/client/shared/test/browser_inplace-editor_focus_closest_editor.js
new file mode 100644
index 0000000000..5d721410ac
--- /dev/null
+++ b/devtools/client/shared/test/browser_inplace-editor_focus_closest_editor.js
@@ -0,0 +1,180 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+/* import-globals-from helper_inplace_editor.js */
+
+"use strict";
+
+loadHelperScript("helper_inplace_editor.js");
+
+// Test the inplace-editor behavior with focusEditableFieldAfterApply
+// and focusEditableFieldContainerSelector options
+
+add_task(async function () {
+ await addTab(
+ "data:text/html;charset=utf-8,inline editor focusEditableFieldAfterApply"
+ );
+ const { host, doc } = await createHost();
+
+ testFocusNavigationWithMultipleEditor(doc);
+ testFocusNavigationWithNonMatchingFocusEditableFieldContainerSelector(doc);
+ testMissingFocusEditableFieldContainerSelector(doc);
+
+ host.destroy();
+ gBrowser.removeCurrentTab();
+});
+
+function testFocusNavigationWithMultipleEditor(doc) {
+ // For some reason
+ SPAN 3
+ BUTTON 3
+
+
+
+
+ `;
+
+ const span1 = doc.getElementById("span-1");
+ const span2 = doc.getElementById("span-2");
+ const span3 = doc.getElementById("span-3");
+
+ info("Create 3 editable fields for the 3 spans inside the main element");
+ const options = {
+ focusEditableFieldAfterApply: true,
+ focusEditableFieldContainerSelector: "main",
+ };
+ editableField({
+ element: span1,
+ ...options,
+ });
+ editableField({
+ element: span2,
+ ...options,
+ });
+ editableField({
+ element: span3,
+ ...options,
+ });
+
+ span1.click();
+
+ is(
+ doc.activeElement.inplaceEditor.elt.id,
+ "span-1",
+ "Visible editable field is the one associated with span-1"
+ );
+ assertFocusedElementInplaceEditorInput(doc);
+
+ EventUtils.sendKey("Tab");
+
+ is(
+ doc.activeElement.inplaceEditor.elt.id,
+ "span-2",
+ "Using Tab moved focus to span-2 editable field"
+ );
+ assertFocusedElementInplaceEditorInput(doc);
+
+ EventUtils.sendKey("Tab");
+
+ is(
+ doc.activeElement.inplaceEditor.elt.id,
+ "span-3",
+ "Using Tab moved focus to span-3 editable field"
+ );
+ assertFocusedElementInplaceEditorInput(doc);
+
+ EventUtils.sendKey("Tab");
+
+ is(
+ doc.activeElement.id,
+ "sidebar-button",
+ "Using Tab moved focus outside of "
+ );
+}
+
+function testFocusNavigationWithNonMatchingFocusEditableFieldContainerSelector(
+ doc
+) {
+ // For some reason