diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /devtools/client/shared/components/test | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/shared/components/test')
7 files changed, 74 insertions, 12 deletions
diff --git a/devtools/client/shared/components/test/chrome/test_list_keyboard.html b/devtools/client/shared/components/test/chrome/test_list_keyboard.html index 7558404ed2..f350c1241c 100644 --- a/devtools/client/shared/components/test/chrome/test_list_keyboard.html +++ b/devtools/client/shared/components/test/chrome/test_list_keyboard.html @@ -76,6 +76,27 @@ window.onload = function() { el.focus(); } + function getExpectedActiveElementForFinalShiftTab() { + if (!SpecialPowers.getBoolPref("dom.disable_tab_focus_to_root_element")) { + return listEl.ownerDocument.documentElement; + } + + // When tab focus mode is applied, the "Run Chrome Tests" button is not + // focusable, so this Shift+Tab moves the focus to a Chrome UI element + // instead of the "Run Chrome Tests" button, which makes the focus to + // move to a browsing context that has a different top level browsing context + // than the current browsing context. Since top level browsing contexts are + // different, the activeElement in the old document is not cleared. Also + // this is only the case when e10s is enabled. + if (SpecialPowers.getBoolPref("accessibility.tabfocus_applies_to_xul") && + SpecialPowers.Services.appinfo.browserTabsRemoteAutostart) { + return listEl; + } + + // <body> + return defaultFocus; + } + const tests = [{ name: "Test default List state. Keyboard focus is set to document body by default.", state: { current: null, active: null }, @@ -246,7 +267,7 @@ window.onload = function() { synthesizeKey("KEY_Tab", { shiftKey: true }); }, state: { current: 0, active: null }, - activeElement: listEl.ownerDocument.documentElement, + activeElement: getExpectedActiveElementForFinalShiftTab(), }]; for (const test of tests) { diff --git a/devtools/client/shared/components/test/chrome/test_notification_box_04.html b/devtools/client/shared/components/test/chrome/test_notification_box_04.html index 07ad9af25c..fde11a7bff 100644 --- a/devtools/client/shared/components/test/chrome/test_notification_box_04.html +++ b/devtools/client/shared/components/test/chrome/test_notification_box_04.html @@ -43,7 +43,7 @@ window.onload = async function () { null, PriorityLevels.PRIORITY_INFO_LOW, [mdnLinkButton], - (e) => false, + () => false, ); const linkNode = notificationNode.querySelector( diff --git a/devtools/client/shared/components/test/chrome/test_notification_box_05.html b/devtools/client/shared/components/test/chrome/test_notification_box_05.html index b3a4e96378..10d6b8971f 100644 --- a/devtools/client/shared/components/test/chrome/test_notification_box_05.html +++ b/devtools/client/shared/components/test/chrome/test_notification_box_05.html @@ -42,7 +42,7 @@ window.onload = async function () { null, PriorityLevels.PRIORITY_INFO_LOW, [], - (e) => false, + () => false, ); // Ensure close button is not present diff --git a/devtools/client/shared/components/test/chrome/test_tree-view_01.html b/devtools/client/shared/components/test/chrome/test_tree-view_01.html index 0acae4c1dc..7a97dfa917 100644 --- a/devtools/client/shared/components/test/chrome/test_tree-view_01.html +++ b/devtools/client/shared/components/test/chrome/test_tree-view_01.html @@ -63,6 +63,26 @@ window.onload = function() { el.focus(); } + function getExpectedActiveElementForFinalShiftTab() { + if (!SpecialPowers.getBoolPref("dom.disable_tab_focus_to_root_element")) { + return treeViewEl.ownerDocument.documentElement; + } + + // When tab focus mode is applied, the "Run Chrome Tests" button is not + // focusable, so this Shift+Tab moves the focus to a Chrome UI element + // instead of the "Run Chrome Tests" button, which makes the focus to + // move to a browsing context that has a different top level browsing context + // than the current browsing context. Since top level browsing contexts are + // different, the activeElement in the old document is not cleared. Also + // this is only the case when e10s is enabled. + if (SpecialPowers.getBoolPref("accessibility.tabfocus_applies_to_xul") && + SpecialPowers.Services.appinfo.browserTabsRemoteAutostart) { + return treeViewEl; + } + + return treeViewEl.ownerDocument.body; + } + const tests = [{ name: "Test default TreeView state. Keyboard focus is set to document " + "body by default.", @@ -255,8 +275,9 @@ window.onload = function() { synthesizeKey("KEY_Tab", { shiftKey: true }); }, state: { selected: "/B", active: null }, - activeElement: treeViewEl.ownerDocument.documentElement, - }]; + activeElement: getExpectedActiveElementForFinalShiftTab(), + } + ]; for (const test of tests) { const { action, event, state, name } = test; diff --git a/devtools/client/shared/components/test/chrome/test_tree_14.html b/devtools/client/shared/components/test/chrome/test_tree_14.html index d68d87d6c5..65557b167c 100644 --- a/devtools/client/shared/components/test/chrome/test_tree_14.html +++ b/devtools/client/shared/components/test/chrome/test_tree_14.html @@ -82,6 +82,26 @@ window.onload = async function() { }, }; + function getExpectedActiveElementForFinalShiftTab() { + if (!SpecialPowers.getBoolPref("dom.disable_tab_focus_to_root_element")) { + return document.documentElement; + } + + // When tab focus mode is applied, the "Run Chrome Tests" button is not + // focusable, so this Shift+Tab moves the focus to a Chrome UI element + // instead of the "Run Chrome Tests" button, which makes the focus to + // move to a browsing context that has a different top level browsing context + // than the current browsing context. Since top level browsing contexts are + // different, the activeElement in the old document is not cleared. Also + // this is only the case when e10s is enabled. + if (SpecialPowers.getBoolPref("accessibility.tabfocus_applies_to_xul") && + SpecialPowers.Services.appinfo.browserTabsRemoteAutostart) { + return "tree"; + } + + return document.body; + } + const tests = [{ name: "Test default Tree props. Keyboard focus is set to document body by default.", props: { focused: undefined, active: undefined }, @@ -204,7 +224,7 @@ window.onload = async function() { synthesizeKey("KEY_Tab", { shiftKey: true }); }, props: { focused: "A", active: null }, - activeElement: document.documentElement, + activeElement: getExpectedActiveElementForFinalShiftTab(), }]; for (const test of tests) { diff --git a/devtools/client/shared/components/test/node/__mocks__/object-front.js b/devtools/client/shared/components/test/node/__mocks__/object-front.js index def182111d..5913deb82e 100644 --- a/devtools/client/shared/components/test/node/__mocks__/object-front.js +++ b/devtools/client/shared/components/test/node/__mocks__/object-front.js @@ -14,7 +14,7 @@ function ObjectFront(grip, overrides) { }) ); }, - enumProperties(options) { + enumProperties() { return Promise.resolve( this.getIterator({ ownProperties: {}, @@ -43,7 +43,7 @@ function ObjectFront(grip, overrides) { // Declared here so we can override it. getIterator(res) { return { - slice(start, count) { + slice() { return Promise.resolve(res); }, }; diff --git a/devtools/client/shared/components/test/node/components/tree.test.js b/devtools/client/shared/components/test/node/components/tree.test.js index c70b66e8ff..eb6f95fa7d 100644 --- a/devtools/client/shared/components/test/node/components/tree.test.js +++ b/devtools/client/shared/components/test/node/components/tree.test.js @@ -50,12 +50,12 @@ function mountTree(overrides = {}) { getKey: x => `key-${x}`, itemHeight: 1, onFocus: x => { - this.setState(previousState => { + this.setState(() => { return { focused: x }; }); }, onActivate: x => { - this.setState(previousState => { + this.setState(() => { return { active: x }; }); }, @@ -207,7 +207,7 @@ describe("Tree", () => { }); it("calls shouldItemUpdate when provided", () => { - const shouldItemUpdate = jest.fn((prev, next) => true); + const shouldItemUpdate = jest.fn(() => true); const wrapper = mountTree({ shouldItemUpdate, }); @@ -636,7 +636,7 @@ describe("Tree", () => { it("renders as expected navigating with arrows on unexpandable roots", () => { const wrapper = mountTree({ focused: "A", - isExpandable: item => false, + isExpandable: () => false, }); expect(formatTree(wrapper)).toMatchSnapshot(); |