From 1873db3a24987c461c53509ba64dd6653fc20222 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 2 Jul 2025 20:25:49 +0530 Subject: [PATCH 1/3] Tab item announcement fix --- .../awt/a11y/CommonComponentAccessibility.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index 41a3accd0a591..9d78598eddd72 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -860,7 +860,13 @@ - (NSAccessibilityRole)accessibilityRole - (NSString *)accessibilityRoleDescription { // first ask AppKit for its accessible role description for a given AXRole - NSString *value = NSAccessibilityRoleDescription([self accessibilityRole], nil); + NSString *value = nil; + + if ([[self javaRole] isEqualToString:@"pagetab"]) { + value = NSAccessibilityRoleDescription([self accessibilityRole], NSAccessibilityTabButtonSubrole); + } else { + value = NSAccessibilityRoleDescription([self accessibilityRole], nil); + } if (value == nil) { // query java if necessary From 0bc63054f1f53d02b9c6e13e4f8ea44a810115e6 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 2 Jul 2025 21:03:31 +0530 Subject: [PATCH 2/3] Add test --- .../AccessibleTabbedPaneRoleTest.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java diff --git a/test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java b/test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java new file mode 100644 index 0000000000000..d22989cba5a93 --- /dev/null +++ b/test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; + +/* + * @test + * @bug 8361283 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "mac") + * @summary VO shouldn't announce the tab items as RadioButton + * @run main/manual AccessibleTabbedPaneRoleTest + */ + +public class AccessibleTabbedPaneRoleTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test is applicable only on macOS. + + Test UI contains a JFrame containing JTabbedPane with multiple tabs. + + Follow these steps to test the behaviour: + + 1. Start the VoiceOver (Press Command + F5) application. + 2. Test Frame should have focus. If not, then bring focus to test frame. + 3. Press Left / Right arrow key to move to next and prevoius tab. + 4. VO should announce "Tab" in stead of "RadioButton" for tab items. + (For e.g. When Tab 1 is selected, VO should announce "Tab 1, selected, + tab, group). + 5. Press Pass if you are able to hear correct announcements + else Fail."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(AccessibleTabbedPaneRoleTest::createUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + int NUM_TABS = 6; + JFrame frame = new JFrame("Test Frame"); + JTabbedPane tabPane = new JTabbedPane(); + tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); + tabPane.setTabPlacement(JTabbedPane.TOP); + for( int i = 0; i < NUM_TABS; ++i) { + tabPane.addTab("Tab " + i , new JLabel("Content Area")); + } + JPanel panel = new JPanel(new BorderLayout()); + panel.add(tabPane, BorderLayout.CENTER); + frame.add(panel); + frame.setSize(400, 100); + return frame; + } +} From 7d0b937990a9b909b967b4106f46d59e3e6db01a Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 7 Jul 2025 09:52:02 +0530 Subject: [PATCH 3/3] Minor change --- .../accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java b/test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java index d22989cba5a93..56f41f9f84bec 100644 --- a/test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java +++ b/test/jdk/javax/accessibility/JTabbedPane/AccessibleTabbedPaneRoleTest.java @@ -71,7 +71,7 @@ private static JFrame createUI() { JTabbedPane tabPane = new JTabbedPane(); tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); tabPane.setTabPlacement(JTabbedPane.TOP); - for( int i = 0; i < NUM_TABS; ++i) { + for (int i = 0; i < NUM_TABS; ++i) { tabPane.addTab("Tab " + i , new JLabel("Content Area")); } JPanel panel = new JPanel(new BorderLayout());