From 9d9a22fc48f7de6c356a2527ab1170cd50e7dad8 Mon Sep 17 00:00:00 2001
From: Peter Varga <pvarga@inf.u-szeged.hu>
Date: Tue, 3 Oct 2017 16:51:56 +0200
Subject: [PATCH] Update accessibility roles and tests for Chromium 60

Change-Id: I8ef0b65fe365f468eeb3336e9bd2569e49257113
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
---
 src/core/browser_accessibility_qt.cpp                         | 4 ++++
 .../qwebengineaccessibility/tst_qwebengineaccessibility.cpp   | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index 9d9ae9009..cafc4f5ad 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -200,6 +200,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
     case ui::AX_ROLE_ALERT:
     case ui::AX_ROLE_ALERT_DIALOG:
         return QAccessible::AlertMessage;
+    case ui::AX_ROLE_ANCHOR:
+        return QAccessible::Link;
     case ui::AX_ROLE_ANNOTATION:
         return QAccessible::StaticText;
     case ui::AX_ROLE_APPLICATION:
@@ -222,6 +224,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
         return QAccessible::Canvas;
     case ui::AX_ROLE_CAPTION:
         return QAccessible::Heading;
+    case ui::AX_ROLE_CARET:
+        return QAccessible::NoRole; // FIXME: https://codereview.chromium.org/2781613003
     case ui::AX_ROLE_CELL:
         return QAccessible::Cell;
     case ui::AX_ROLE_CHECK_BOX:
diff --git a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
index bed2745e3..759158a50 100644
--- a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
+++ b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
@@ -259,6 +259,7 @@ void tst_QWebEngineAccessibility::roles_data()
     QTest::newRow("AX_ROLE_ABBR") << QString("<abbr>a</abbr>") << false << QAccessible::StaticText;
     QTest::newRow("AX_ROLE_ALERT") << QString("<div role='alert'>alert</div>") << true << QAccessible::AlertMessage;
     QTest::newRow("AX_ROLE_ALERT_DIALOG") << QString("<div role='alertdialog'>alert</div>") << true << QAccessible::AlertMessage;
+    //QTest::newRow("AX_ROLE_ANCHOR") << QString("<a>target</a>") << false << QAccessible::Link; // FIXME: The test case might be wrong (see https://codereview.chromium.org/2713193003)
     QTest::newRow("AX_ROLE_ANNOTATION") << QString("<rt>a</rt>") << false << QAccessible::StaticText;
     QTest::newRow("AX_ROLE_APPLICATION") << QString("<div role='application'>landmark</div>") << true << QAccessible::Document;
     QTest::newRow("AX_ROLE_ARTICLE") << QString("<article>a</article>") << true << QAccessible::Section;
@@ -270,6 +271,7 @@ void tst_QWebEngineAccessibility::roles_data()
     //QTest::newRow("AX_ROLE_BUTTON_DROP_DOWN"); // Not a blink accessibility role
     //QTest::newRow("AX_ROLE_CANVAS") << QString("<canvas width='10' height='10'></canvas>") << true << QAccessible::Canvas; // FIXME: The test case might be wrong (see AXLayoutObject.cpp)
     QTest::newRow("AX_ROLE_CAPTION") << QString("<table><caption>a</caption></table>") << false << QAccessible::Heading;
+    //QTest::newRow("AX_ROLE_CARET"); // Not a blink accessibility role
     //QTest::newRow("AX_ROLE_CELL") << QString("<td role='cell'>a</td>") << true << QAccessible::Cell; // FIXME: Aria role 'cell' should work for <td>
     QTest::newRow("AX_ROLE_CHECK_BOX") << QString("<input type='checkbox'>a</input>") << false << QAccessible::CheckBox;
     QTest::newRow("AX_ROLE_CLIENT") << QString("") << true << QAccessible::Client;
@@ -378,7 +380,7 @@ void tst_QWebEngineAccessibility::roles_data()
     QTest::newRow("AX_ROLE_TOOLBAR") << QString("<div role='toolbar'>a</div>") << true << QAccessible::ToolBar;
     QTest::newRow("AX_ROLE_TOOLTIP") << QString("<div role='tooltip'>a</div>") << true << QAccessible::ToolTip;
     QTest::newRow("AX_ROLE_TREE") << QString("<div role='tree'>a</div>") << true << QAccessible::Tree;
-    //QTest::newRow("AX_ROLE_TREE_GRID") << QString("<div role='treegrid'>a</div>") << true << QAccessible::Tree; // FIXME: Aria role 'treegrid' should work
+    QTest::newRow("AX_ROLE_TREE_GRID") << QString("<div role='treegrid'>a</div>") << true << QAccessible::Tree;
     QTest::newRow("AX_ROLE_TREE_ITEM") << QString("<div role='treeitem'>a</div>") << true << QAccessible::TreeItem;
     QTest::newRow("AX_ROLE_VIDEO") << QString("<video><source src='test.mp4' type='video/mp4'></video>") << false << QAccessible::Animation;
     //QTest::newRow("AX_ROLE_WINDOW"); // No mapping to ARIA role
-- 
GitLab