Commit 78f19056 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Chromium LUCI CQ

Cleanup: Modernizes some parts of CrossPlatformAccessibilityBrowserTest,...

Cleanup: Modernizes some parts of CrossPlatformAccessibilityBrowserTest, enables all disabled tests and makes them more consistent with other accessibility browser tests

Some tests having to do with iframe traversal in CrossPlatformAccessibilityBrowserTest were disabled.
In https://crrev.com/c/2556452, the kPDFRoot role is being added and the kWebArea role is being removed.
Iframe traversal tests should be enabled and functioning to ensure the robustness of any code changes
in those roles, as they could potentially break iframe navigation.

Meanwhile, many of the code convensions used in CrossPlatformAccessibilityBrowserTest were different from all other accessibility browser tests
and some have been superceded by changes to C++.

This patch switches to using raw literal strings for loading HTML snippets, improves indentation, and
uses the same method names for loading test pages as in other accessibility browser tests.
Also, useless comments were eliminated and test fixtures cleaned up were necessary.

Originally split out from
https://crrev.com/c/2556452

AX-Relnotes: n/a.

R=dmazzoni@chromium.org, aleventhal@chromium.org

Change-Id: Ia9c3094606581468d7f1b5c8849bb44668b47de1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575101
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Auto-Submit: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarAbigail Klein <abigailbklein@google.com>
Cr-Commit-Position: refs/heads/master@{#836225}
parent 2885cb89
...@@ -28,12 +28,14 @@ ...@@ -28,12 +28,14 @@
#include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h" #include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "net/base/escape.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#include "ui/accessibility/accessibility_features.h" #include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/accessibility_switches.h" #include "ui/accessibility/accessibility_switches.h"
#include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_tree.h" #include "ui/accessibility/ax_tree.h"
#include "ui/accessibility/ax_tree_id.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/atl.h" #include "base/win/atl.h"
...@@ -56,22 +58,12 @@ namespace content { ...@@ -56,22 +58,12 @@ namespace content {
class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest {
public: public:
CrossPlatformAccessibilityBrowserTest() {} CrossPlatformAccessibilityBrowserTest() = default;
~CrossPlatformAccessibilityBrowserTest() override = default;
// Tell the renderer to send an accessibility tree, then wait for the
// notification that it's been received.
const ui::AXTree& GetAXTree(
ui::AXMode accessibility_mode = ui::kAXModeComplete) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(),
accessibility_mode,
ax::mojom::Event::kLayoutComplete);
waiter.WaitForNotification();
return waiter.GetAXTree();
}
// Make sure each node in the tree has a unique id. // Make sure each node in the tree has a unique id.
void RecursiveAssertUniqueIds(const ui::AXNode* node, void RecursiveAssertUniqueIds(const ui::AXNode* node,
std::unordered_set<int>* ids) { std::unordered_set<int>* ids) const {
ASSERT_TRUE(ids->find(node->id()) == ids->end()); ASSERT_TRUE(ids->find(node->id()) == ids->end());
ids->insert(node->id()); ids->insert(node->id());
for (const auto* child : node->children()) for (const auto* child : node->children())
...@@ -80,7 +72,6 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { ...@@ -80,7 +72,6 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest {
void SetUp() override; void SetUp() override;
void SetUpOnMainThread() override; void SetUpOnMainThread() override;
void TearDownOnMainThread() override;
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
ContentBrowserTest::SetUpCommandLine(command_line); ContentBrowserTest::SetUpCommandLine(command_line);
...@@ -100,32 +91,41 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { ...@@ -100,32 +91,41 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest {
base::ASCIIToUTF16(script), base::NullCallback()); base::ASCIIToUTF16(script), base::NullCallback());
} }
void LoadInitialAccessibilityTreeFromUrl( void LoadInitialAccessibilityTreeFromHtml(const std::string& html) {
const GURL& url,
ui::AXMode accessibility_mode = ui::kAXModeComplete) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), AccessibilityNotificationWaiter waiter(shell()->web_contents(),
accessibility_mode, ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete); ax::mojom::Event::kLoadComplete);
EXPECT_TRUE(NavigateToURL(shell(), url)); GURL html_data_url(
net::EscapeExternalHandlerValue("data:text/html," + html));
ASSERT_TRUE(NavigateToURL(shell(), html_data_url));
waiter.WaitForNotification(); waiter.WaitForNotification();
} }
void LoadInitialAccessibilityTreeFromHtmlFilePath( void LoadInitialAccessibilityTreeFromHtmlFilePath(
const std::string& html_file_path, const std::string& html_file_path) {
ui::AXMode accessibility_mode = ui::kAXModeComplete) {
if (!embedded_test_server()->Started()) if (!embedded_test_server()->Started())
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
ASSERT_TRUE(embedded_test_server()->Started()); ASSERT_TRUE(embedded_test_server()->Started());
LoadInitialAccessibilityTreeFromUrl( AccessibilityNotificationWaiter waiter(shell()->web_contents(),
embedded_test_server()->GetURL(html_file_path), accessibility_mode); ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete);
ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL(html_file_path)));
waiter.WaitForNotification();
} }
BrowserAccessibilityManager* GetManager() { BrowserAccessibilityManager* GetManager() const {
WebContentsImpl* web_contents = WebContentsImpl* web_contents =
static_cast<WebContentsImpl*>(shell()->web_contents()); static_cast<WebContentsImpl*>(shell()->web_contents());
return web_contents->GetRootBrowserAccessibilityManager(); return web_contents->GetRootBrowserAccessibilityManager();
} }
const ui::AXTree& GetAXTree() const {
const ui::AXTree* ax_tree = GetManager()->ax_tree();
EXPECT_NE(nullptr, ax_tree);
return *ax_tree;
}
BrowserAccessibility* FindNode(const std::string& name_or_value) { BrowserAccessibility* FindNode(const std::string& name_or_value) {
return FindNodeInSubtree(*GetManager()->GetRoot(), name_or_value); return FindNodeInSubtree(*GetManager()->GetRoot(), name_or_value);
} }
...@@ -142,7 +142,7 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { ...@@ -142,7 +142,7 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest {
// Will expose no HTML value attribute, but some screen readers, such as // Will expose no HTML value attribute, but some screen readers, such as
// Jaws, VoiceOver and Talkback, require one to be computed. // Jaws, VoiceOver and Talkback, require one to be computed.
const std::string& value = base::UTF16ToUTF8(node.GetValueForControl()); const std::string& value = base::UTF16ToUTF8(node.GetValueForControl());
if ((name == name_or_value || value == name_or_value)) { if (name == name_or_value || value == name_or_value) {
return &node; return &node;
} }
...@@ -195,14 +195,8 @@ void CrossPlatformAccessibilityBrowserTest::ChooseFeatures( ...@@ -195,14 +195,8 @@ void CrossPlatformAccessibilityBrowserTest::ChooseFeatures(
void CrossPlatformAccessibilityBrowserTest::SetUpOnMainThread() { void CrossPlatformAccessibilityBrowserTest::SetUpOnMainThread() {
#if defined(OS_WIN) #if defined(OS_WIN)
com_initializer_ = std::make_unique<base::win::ScopedCOMInitializer>();
ui::win::CreateATLModuleIfNeeded(); ui::win::CreateATLModuleIfNeeded();
com_initializer_.reset(new base::win::ScopedCOMInitializer());
#endif
}
void CrossPlatformAccessibilityBrowserTest::TearDownOnMainThread() {
#if defined(OS_WIN)
com_initializer_.reset();
#endif #endif
} }
...@@ -265,20 +259,25 @@ BrowserAccessibility* FindNodeByRole(BrowserAccessibility* root, ...@@ -265,20 +259,25 @@ BrowserAccessibility* FindNodeByRole(BrowserAccessibility* root,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
WebpageAccessibility) { WebpageAccessibility) {
// Create a data url and load it. const std::string url_str(R"HTML(
const char url_str[] = <!DOCTYPE html>
"data:text/html," <html>
"<!doctype html>" <head>
"<html><head><title>Accessibility Test</title></head>" <title>Accessibility Test</title>
"<body><input type='button' value='push' /><input type='checkbox' />" </head>
"</body></html>"; <body>
GURL url(url_str); <input type="button" value="push">
EXPECT_TRUE(NavigateToURL(shell(), url)); <input type="checkbox">
</body>
</html>)HTML");
LoadInitialAccessibilityTreeFromHtml(url_str);
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
// Check properties of thet tree. // Check properties of the tree.
EXPECT_EQ(url_str, tree.data().url); EXPECT_EQ(net::EscapeExternalHandlerValue("data:text/html," + url_str),
tree.data().url);
EXPECT_EQ("Accessibility Test", tree.data().title); EXPECT_EQ("Accessibility Test", tree.data().title);
EXPECT_EQ("html", tree.data().doctype); EXPECT_EQ("html", tree.data().doctype);
EXPECT_EQ("text/html", tree.data().mimetype); EXPECT_EQ("text/html", tree.data().mimetype);
...@@ -318,15 +317,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -318,15 +317,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
UnselectedEditableTextAccessibility) { UnselectedEditableTextAccessibility) {
// Create a data url and load it. LoadInitialAccessibilityTreeFromHtml(R"HTML(
const char url_str[] = <!DOCTYPE html>
"data:text/html," <html>
"<!doctype html>" <body>
"<body>" <input value="Hello, world.">
"<input value=\"Hello, world.\"/>" </body>
"</body></html>"; </html>)HTML");
GURL url(url_str);
EXPECT_TRUE(NavigateToURL(shell(), url));
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
...@@ -348,15 +345,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -348,15 +345,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
SelectedEditableTextAccessibility) { SelectedEditableTextAccessibility) {
// Create a data url and load it. LoadInitialAccessibilityTreeFromHtml(R"HTML(
const char url_str[] = <!DOCTYPE html>
"data:text/html," <html>
"<!doctype html>" <body onload="document.body.children[0].select();">
"<body onload=\"document.body.children[0].select();\">" <input value="Hello, world.">
"<input value=\"Hello, world.\"/>" </body>
"</body></html>"; </html>)HTML");
GURL url(url_str);
EXPECT_TRUE(NavigateToURL(shell(), url));
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
...@@ -377,17 +372,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -377,17 +372,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
// Here's a html snippet where Blink puts the same node as a child // Here's a html snippet where Blink puts the same node as a child
// of two different parents. Instead of checking the exact output, just // of two different parents. Instead of checking the exact output, just
// make sure that no id is reused in the resulting tree. // make sure that no id is reused in the resulting tree.
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
"data:text/html," <!DOCTYPE html>
"<!doctype html>" <html>
"<script>\n" <script>
" document.writeln('<q><section></section></q><q><li>');\n" document.writeln('<q><section></section></q><q><li>');
" setTimeout(function() {\n" setTimeout(function() {
" document.close();\n" document.close();
" }, 1);\n" }, 1);
"</script>"; </script>
GURL url(url_str); </html>)HTML");
EXPECT_TRUE(NavigateToURL(shell(), url));
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
...@@ -395,26 +389,36 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -395,26 +389,36 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
RecursiveAssertUniqueIds(root, &ids); RecursiveAssertUniqueIds(root, &ids);
} }
// TODO(dmazzoni): Needs to be rebaselined. http://crbug.com/347464
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
DISABLED_IframeAccessibility) { IframeAccessibility) {
// Create a data url and load it. LoadInitialAccessibilityTreeFromHtml(R"HTML(
const char url_str[] = <!DOCTYPE html>
"data:text/html," <html>
"<!doctype html><html><body>" <body>
"<button>Button 1</button>" <button>Button 1</button>
"<iframe src='data:text/html," <iframe srcdoc="
"<!doctype html><html><body><button>Button 2</button></body></html>" <!DOCTYPE html>
"'></iframe>" <html>
"<button>Button 3</button>" <body>
"</body></html>"; <button>Button 2</button>
GURL url(url_str); </body>
EXPECT_TRUE(NavigateToURL(shell(), url)); </html>
"></iframe>
<button>Button 3</button>
</body>
</html>)HTML");
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
"Button 2");
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
ASSERT_EQ(1u, root->GetUnignoredChildCount()); ASSERT_EQ(1u, root->children().size());
const ui::AXNode* body = root->GetUnignoredChildAtIndex(0);
const ui::AXNode* html_element = root->children()[0];
ASSERT_EQ(1u, html_element->GetUnignoredChildCount());
const ui::AXNode* body = html_element->children()[0];
ASSERT_EQ(3u, body->GetUnignoredChildCount()); ASSERT_EQ(3u, body->GetUnignoredChildCount());
const ui::AXNode* button1 = body->GetUnignoredChildAtIndex(0); const ui::AXNode* button1 = body->GetUnignoredChildAtIndex(0);
...@@ -425,13 +429,26 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -425,13 +429,26 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
const ui::AXNode* iframe = body->GetUnignoredChildAtIndex(1); const ui::AXNode* iframe = body->GetUnignoredChildAtIndex(1);
EXPECT_STREQ("iframe", EXPECT_STREQ("iframe",
GetAttr(iframe, ax::mojom::StringAttribute::kHtmlTag).c_str()); GetAttr(iframe, ax::mojom::StringAttribute::kHtmlTag).c_str());
ASSERT_EQ(1u, iframe->GetUnignoredChildCount());
const ui::AXNode* sub_document = iframe->GetUnignoredChildAtIndex(0); // Iframes loaded via the "srcdoc" attribute, (or the now deprecated method of
// "src=data:text/html,..."), create a new origin context and are thus loaded
// into a separate accessibility tree. (See "out-of-process cross-origin
// iframes in Chromium documentation.)
ASSERT_EQ(0u, iframe->children().size());
const ui::AXTreeID iframe_tree_id = AXTreeID::FromString(
GetAttr(iframe, ax::mojom::StringAttribute::kChildTreeId));
const BrowserAccessibilityManager* iframe_manager =
BrowserAccessibilityManager::FromID(iframe_tree_id);
ASSERT_NE(nullptr, iframe_manager);
const ui::AXNode* sub_document = iframe_manager->GetRootAsAXNode();
EXPECT_EQ(ax::mojom::Role::kRootWebArea, sub_document->data().role); EXPECT_EQ(ax::mojom::Role::kRootWebArea, sub_document->data().role);
ASSERT_EQ(1u, sub_document->GetUnignoredChildCount()); ASSERT_EQ(1u, sub_document->children().size());
const ui::AXNode* sub_html_element = sub_document->children()[0];
ASSERT_EQ(1u, sub_html_element->GetUnignoredChildCount());
const ui::AXNode* sub_body = sub_document->GetUnignoredChildAtIndex(0); const ui::AXNode* sub_body = sub_html_element->children()[0];
ASSERT_EQ(1u, sub_body->GetUnignoredChildCount()); ASSERT_EQ(1u, sub_body->GetUnignoredChildCount());
const ui::AXNode* button2 = sub_body->GetUnignoredChildAtIndex(0); const ui::AXNode* button2 = sub_body->GetUnignoredChildAtIndex(0);
...@@ -447,22 +464,23 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -447,22 +464,23 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
PlatformIframeAccessibility) { PlatformIframeAccessibility) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), LoadInitialAccessibilityTreeFromHtml(R"HTML(
ui::kAXModeComplete, <!DOCTYPE html>
ax::mojom::Event::kLoadComplete); <html>
// Create a data url and load it. <body>
GURL url( <button>Button 1</button>
"data:text/html," <iframe srcdoc="
"<!doctype html><html><body>" <!DOCTYPE html>
"<button>Button 1</button>" <html>
"<iframe src='data:text/html," <body>
"<!doctype html><html><body><button>Button 2</button></body></html>" <button>Button 2</button>
"'></iframe>" </body>
"<button>Button 3</button>" </html>
"</body></html>"); "></iframe>
<button>Button 3</button>
EXPECT_TRUE(NavigateToURL(shell(), url)); </body>
waiter.WaitForNotification(); </html>)HTML");
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
"Button 2"); "Button 2");
...@@ -507,21 +525,18 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -507,21 +525,18 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
AXNodePositionTreeBoundary) { AXNodePositionTreeBoundary) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), LoadInitialAccessibilityTreeFromHtml(R"HTML(
ui::kAXModeComplete, <!DOCTYPE html>
ax::mojom::Event::kLoadComplete); <html>
GURL url( <body>Text before iframe<iframe srcdoc="
"data:text/html," <!DOCTYPE html>
"<!doctype html><html><body>" <html>
"Text before iframe" <body>Text in iframe
"<iframe src='data:text/html," </body>
"<!doctype html><html><body>Text in iframe</body></html>" </html>">
"'></iframe>" </iframe>Text after iframe</body>
"Text after iframe" </html>)HTML");
"</body></html>");
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
"Text in iframe"); "Text in iframe");
...@@ -602,24 +617,24 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -602,24 +617,24 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
PlatformIterator) { PlatformIterator) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), LoadInitialAccessibilityTreeFromHtml(R"HTML(
ui::kAXModeComplete, <!DOCTYPE html>
ax::mojom::Event::kLoadComplete); <html>
// Create a data url and load it. <body>
GURL url( <button>Button 1</button>
"data:text/html," <iframe srcdoc="
"<!doctype html><html><body>" <!DOCTYPE html>
"<button>Button 1</button>" <html>
"<iframe src='data:text/html," <body>
"<!doctype html><html><body>" <button>Button 2</button>
"<button>Button 2</button>" <button>Button 3</button>
"<button>Button 3</button>" </body>
"</body></html>'></iframe>" </html>">
"<button>Button 4</button>" </iframe>
"</body></html>"); <button>Button 4</button>
</body>
EXPECT_TRUE(NavigateToURL(shell(), url)); </html>)HTML");
waiter.WaitForNotification();
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
"Button 2"); "Button 2");
const BrowserAccessibility* root = GetManager()->GetRoot(); const BrowserAccessibility* root = GetManager()->GetRoot();
...@@ -659,12 +674,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -659,12 +674,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
// Here's another html snippet where WebKit has a parent node containing // Here's another html snippet where WebKit has a parent node containing
// two duplicate child nodes. Instead of checking the exact output, just // two duplicate child nodes. Instead of checking the exact output, just
// make sure that no id is reused in the resulting tree. // make sure that no id is reused in the resulting tree.
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
"data:text/html," <!DOCTYPE html>
"<!doctype html>" <html>
"<em><code ><h4 ></em>"; <body>
GURL url(url_str); <em>
EXPECT_TRUE(NavigateToURL(shell(), url)); <code >
<h4 >
</em>
</body>
</html>)HTML");
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
...@@ -673,14 +692,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -673,14 +692,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
} }
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, WritableElement) { IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, WritableElement) {
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
"data:text/html," <!DOCTYPE html>
"<!doctype html>" <html>
"<div role='textbox' tabindex=0>" <body>
" Some text" <div role="textbox" tabindex="0">
"</div>"; Some text
GURL url(url_str); </div>
EXPECT_TRUE(NavigateToURL(shell(), url)); </body>
</html>)HTML");
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
ASSERT_EQ(1u, root->GetUnignoredChildCount()); ASSERT_EQ(1u, root->GetUnignoredChildCount());
...@@ -690,18 +711,21 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, WritableElement) { ...@@ -690,18 +711,21 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, WritableElement) {
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
AriaSortDirection) { AriaSortDirection) {
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
"data:text/html," <!DOCTYPE html>
"<!doctype html>" <html>
"<table><tr>" <body>
"<th scope='row' aria-sort='ascending'>row header 1</th>" <table>
"<th scope='row' aria-sort='descending'>row header 2</th>" <tr>
"<th scope='col' aria-sort='custom'>col header 1</th>" <th scope="row" aria-sort="ascending">row header 1</th>
"<th scope='col' aria-sort='none'>col header 2</th>" <th scope="row" aria-sort="descending">row header 2</th>
"<th scope='col'>col header 3</th>" <th scope="col" aria-sort="custom">col header 1</th>
"</tr></table>"; <th scope="col" aria-sort="none">col header 2</th>
GURL url(url_str); <th scope="col">col header 3</th>
EXPECT_TRUE(NavigateToURL(shell(), url)); </tr>
</table>
</body>
</html>)HTML");
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
...@@ -732,32 +756,29 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -732,32 +756,29 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
LocalizedLandmarkType) { LocalizedLandmarkType) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), LoadInitialAccessibilityTreeFromHtml(R"HTML(
ui::kAXModeComplete, <!DOCTYPE html>
ax::mojom::Event::kLoadComplete); <html>
GURL url( <body>
"data:text/html," <header aria-label="header"></header>
"<!doctype html>" <aside aria-label="aside"></aside>
"<header aria-label='header'></header>" <footer aria-label="footer"></footer>
"<aside aria-label='aside'></aside>" <form aria-label="form"></form>
"<footer aria-label='footer'></footer>" <main aria-label="main"></main>
"<form aria-label='form'></form>" <nav aria-label="nav"></nav>
"<main aria-label='main'></main>" <section></section>
"<nav aria-label='nav'></nav>" <section aria-label="section"></section>
"<section></section>" <div role="banner" aria-label="banner"></div>
"<section aria-label='section'></section>" <div role="complementary" aria-label="complementary"></div>
"<div role='banner' aria-label='banner'></div>" <div role="contentinfo" aria-label="contentinfo"></div>
"<div role='complementary' aria-label='complementary'></div>" <div role="form" aria-label="role_form"></div>
"<div role='contentinfo' aria-label='contentinfo'></div>" <div role="main" aria-label="role_main"></div>
"<div role='form' aria-label='role_form'></div>" <div role="navigation" aria-label="role_nav"></div>
"<div role='main' aria-label='role_main'></div>" <div role="region"></div>
"<div role='navigation' aria-label='role_nav'></div>" <div role="region" aria-label="region"></div>
"<div role='region'></div>" <div role="search" aria-label="search"></div>
"<div role='region' aria-label='region'></div>" </body>
"<div role='search' aria-label='search'></div>"); </html>)HTML");
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
BrowserAccessibility* root = GetManager()->GetRoot(); BrowserAccessibility* root = GetManager()->GetRoot();
ASSERT_NE(nullptr, root); ASSERT_NE(nullptr, root);
...@@ -814,35 +835,33 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -814,35 +835,33 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
#endif #endif
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
MAYBE_LocalizedRoleDescription) { MAYBE_LocalizedRoleDescription) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), LoadInitialAccessibilityTreeFromHtml(R"HTML(
ui::kAXModeComplete, <!DOCTYPE html>
ax::mojom::Event::kLoadComplete); <html>
GURL url( <body>
"data:text/html," <article></article>
"<article></article>" <audio controls></audio>
"<audio controls></audio>" <details></details>
"<details></details>" <figure></figure>
"<figure></figure>" <footer></footer>
"<footer></footer>" <header></header>
"<header></header>" <input>
"<input>" <input type="color">
"<input type='color'>" <input type="date">
"<input type='date'>" <input type="datetime-local">
"<input type='datetime-local'>" <input type="email">
"<input type='email'>" <input type="tel">
"<input type='tel'>" <input type="url">
"<input type='url'>" <input type="week">
"<input type='week'>" <mark></mark>
"<mark></mark>" <meter></meter>
"<meter></meter>" <output></output>
"<output></output>" <section></section>
"<section></section>" <section aria-label="section"></section>
"<section aria-label='section'></section>" <time></time>
"<time></time>" <div role="contentinfo" aria-label="contentinfo"></div>
"<div role='contentinfo' aria-label='contentinfo'></div>"); </body>
</html>)HTML");
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
BrowserAccessibility* root = GetManager()->GetRoot(); BrowserAccessibility* root = GetManager()->GetRoot();
ASSERT_NE(nullptr, root); ASSERT_NE(nullptr, root);
...@@ -885,16 +904,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -885,16 +904,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
GetStyleNameAttributeAsLocalizedString) { GetStyleNameAttributeAsLocalizedString) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), LoadInitialAccessibilityTreeFromHtml(R"HTML(
ui::kAXModeComplete, <!DOCTYPE html>
ax::mojom::Event::kLoadComplete); <html>
GURL url( <body>
"data:text/html," <p>text <mark>mark text</mark></p>
"<!doctype html>" </body>
"<p>text <mark>mark text</mark></p>"); </html>)HTML");
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
BrowserAccessibility* root = GetManager()->GetRoot(); BrowserAccessibility* root = GetManager()->GetRoot();
ASSERT_NE(nullptr, root); ASSERT_NE(nullptr, root);
...@@ -937,14 +953,15 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -937,14 +953,15 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
TooltipStringAttributeMutuallyExclusiveOfNameFromTitle) { TooltipStringAttributeMutuallyExclusiveOfNameFromTitle) {
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
"data:text/html," <!DOCTYPE html>
"<!doctype html>" <html>
"<input type='text' title='title'>" <body>
"<input type='text' title='title' aria-labelledby='inputlabel'>" <input type="text" title="title">
"<div id='inputlabel'>aria-labelledby</div>"; <input type="text" title="title" aria-labelledby="inputlabel">
GURL url(url_str); <div id="inputlabel">aria-labelledby</div>
EXPECT_TRUE(NavigateToURL(shell(), url)); </body>
</html>)HTML");
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
...@@ -969,15 +986,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -969,15 +986,16 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
CrossPlatformAccessibilityBrowserTest, CrossPlatformAccessibilityBrowserTest,
PlaceholderStringAttributeMutuallyExclusiveOfNameFromPlaceholder) { PlaceholderStringAttributeMutuallyExclusiveOfNameFromPlaceholder) {
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
"data:text/html," <!DOCTYPE html>
"<!doctype html>" <html>
"<fieldset>" <body>
"<input type='text' placeholder='placeholder'>" <fieldset>
"<input type='text' placeholder='placeholder' aria-label='label'>" <input type="text" placeholder="placeholder">
"</fieldset>"; <input type="text" placeholder="placeholder" aria-label="label">
GURL url(url_str); </fieldset>
EXPECT_TRUE(NavigateToURL(shell(), url)); </body>
</html>)HTML");
const ui::AXTree& tree = GetAXTree(); const ui::AXTree& tree = GetAXTree();
const ui::AXNode* root = tree.root(); const ui::AXNode* root = tree.root();
...@@ -1004,7 +1022,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1004,7 +1022,6 @@ IN_PROC_BROWSER_TEST_F(
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
GetBoundsRectUnclippedRootFrameFromIFrame) { GetBoundsRectUnclippedRootFrameFromIFrame) {
// Start by loading a document with iframes.
LoadInitialAccessibilityTreeFromHtmlFilePath( LoadInitialAccessibilityTreeFromHtmlFilePath(
"/accessibility/html/iframe-padding.html"); "/accessibility/html/iframe-padding.html");
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
...@@ -1033,7 +1050,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1033,7 +1050,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
.ToString()); .ToString());
// Now get the root delegate of the iframe's accessibility tree. // Now get the root delegate of the iframe's accessibility tree.
AXTreeID iframe_tree_id = AXTreeID::FromString( ui::AXTreeID iframe_tree_id = ui::AXTreeID::FromString(
leaf_iframe_browser_accessibility->GetStringAttribute( leaf_iframe_browser_accessibility->GetStringAttribute(
ax::mojom::StringAttribute::kChildTreeId)); ax::mojom::StringAttribute::kChildTreeId));
BrowserAccessibilityManager* iframe_browser_accessibility_manager = BrowserAccessibilityManager* iframe_browser_accessibility_manager =
...@@ -1056,7 +1073,6 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1056,7 +1073,6 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
GetBoundsRectUnclippedFrameFromIFrame) { GetBoundsRectUnclippedFrameFromIFrame) {
// Start by loading a document with iframes.
LoadInitialAccessibilityTreeFromHtmlFilePath( LoadInitialAccessibilityTreeFromHtmlFilePath(
"/accessibility/html/iframe-padding.html"); "/accessibility/html/iframe-padding.html");
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
...@@ -1084,7 +1100,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1084,7 +1100,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
.ToString()); .ToString());
// Now get the root delegate of the iframe's accessibility tree. // Now get the root delegate of the iframe's accessibility tree.
AXTreeID iframe_tree_id = AXTreeID::FromString( ui::AXTreeID iframe_tree_id = ui::AXTreeID::FromString(
leaf_iframe_browser_accessibility->GetStringAttribute( leaf_iframe_browser_accessibility->GetStringAttribute(
ax::mojom::StringAttribute::kChildTreeId)); ax::mojom::StringAttribute::kChildTreeId));
BrowserAccessibilityManager* iframe_browser_accessibility_manager = BrowserAccessibilityManager* iframe_browser_accessibility_manager =
...@@ -1105,26 +1121,17 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1105,26 +1121,17 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
} }
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
TestControlsIdsForDateTimePopup) { ControlsIdsForDateTimePopup) {
// Create a data url and load it. LoadInitialAccessibilityTreeFromHtml(R"HTML(
const char url_str[] = <!DOCTYPE html>
R"HTML(data:text/html,<!DOCTYPE html> <html>
<html> <body>
<div style="margin-top: 100px;"></div> <div style="margin-top: 100px;"></div>
<input type="datetime-local" aria-label="datetime" <input type="datetime-local" aria-label="datetime"
aria-controls="button1"> aria-controls="button1">
<button id="button1">button</button> <button id="button1">button</button>
</html>)HTML"; </body>
GURL url(url_str); </html>)HTML");
// Load the document and wait for it
{
AccessibilityNotificationWaiter waiter(shell()->web_contents(),
ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete);
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
}
BrowserAccessibilityManager* manager = GetManager(); BrowserAccessibilityManager* manager = GetManager();
ASSERT_NE(nullptr, manager); ASSERT_NE(nullptr, manager);
...@@ -1186,28 +1193,19 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1186,28 +1193,19 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
} }
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
TestControlsIdsForColorPopup) { ControlsIdsForColorPopup) {
// Create a data url and load it. LoadInitialAccessibilityTreeFromHtml(R"HTML(
const char url_str[] = <!DOCTYPE html>
R"HTML(data:text/html,<!DOCTYPE html> <html>
<html> <body>
<input type="color" aria-label="color" list="colorlist"> <input type="color" aria-label="color" list="colorlist">
<datalist id="colorlist"> <datalist id="colorlist">
<option value="#ff0000"> <option value="#ff0000">
<option value="#00ff00"> <option value="#00ff00">
<option value="#0000ff"> <option value="#0000ff">
</datalist> </datalist>
</html>)HTML"; </body>
GURL url(url_str); </html>)HTML");
// Load the document and wait for it
{
AccessibilityNotificationWaiter waiter(shell()->web_contents(),
ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete);
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
}
BrowserAccessibilityManager* manager = GetManager(); BrowserAccessibilityManager* manager = GetManager();
ASSERT_NE(nullptr, manager); ASSERT_NE(nullptr, manager);
...@@ -1254,17 +1252,20 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1254,17 +1252,20 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
TextFragmentAnchor) { TextFragmentAnchor) {
EXPECT_TRUE(NavigateToURL(shell(), GURL(url::kAboutBlankURL)));
AccessibilityNotificationWaiter anchor_waiter( AccessibilityNotificationWaiter anchor_waiter(
shell()->web_contents(), ui::kAXModeComplete, shell()->web_contents(), ui::kAXModeComplete,
ax::mojom::Event::kScrolledToAnchor); ax::mojom::Event::kScrolledToAnchor);
GURL url( GURL url(net::EscapeExternalHandlerValue(R"HTML(data:text/html,
"data:text/html," <p>
"<p>Some text</p>" Some text
"<p id='target' style='position: absolute; top: 1000px'>Anchor text</p>" </p>
"#:~:text=Anchor%20text"); <p id="target" style="position: absolute; top: 1000px">
EXPECT_TRUE(NavigateToURL(shell(), url)); Anchor text
</p>
#:~:text=Anchor text)HTML"));
ASSERT_TRUE(NavigateToURL(shell(), url));
anchor_waiter.WaitForNotification(); anchor_waiter.WaitForNotification();
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
"Anchor text"); "Anchor text");
...@@ -1279,16 +1280,23 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1279,16 +1280,23 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
} }
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, GeneratedText) { IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, GeneratedText) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(), LoadInitialAccessibilityTreeFromHtml(R"HTML(
ui::kAXModeComplete, <!DOCTYPE html>
ax::mojom::Event::kLoadComplete); <html>
GURL url( <head>
"data:text/html," <style>
"<style>h1.generated::before{content:' [ ';}" h1.generated::before {
"h1.generated::after{content:' ] ';}</style>" content: " [ ";
"<h1 class='generated'>Foo</h1>"); }
EXPECT_TRUE(NavigateToURL(shell(), url)); h1.generated::after {
waiter.WaitForNotification(); content: " ] ";
}
</style>
</head>
<body>
<h1 class="generated">Foo</h1>
</body>
</html>)HTML");
const BrowserAccessibility* root = GetManager()->GetRoot(); const BrowserAccessibility* root = GetManager()->GetRoot();
ASSERT_EQ(1U, root->PlatformChildCount()); ASSERT_EQ(1U, root->PlatformChildCount());
...@@ -1370,7 +1378,6 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1370,7 +1378,6 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
IFrameContentHadFocus_ThenRootDocumentGainedFocus) { IFrameContentHadFocus_ThenRootDocumentGainedFocus) {
// Start by loading a document with iframes.
LoadInitialAccessibilityTreeFromHtmlFilePath( LoadInitialAccessibilityTreeFromHtmlFilePath(
"/accessibility/html/iframe-padding.html"); "/accessibility/html/iframe-padding.html");
WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(),
...@@ -1425,6 +1432,12 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1425,6 +1432,12 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
class CrossPlatformAccessibilityBrowserTestWithImplicitRootScrolling class CrossPlatformAccessibilityBrowserTestWithImplicitRootScrolling
: public CrossPlatformAccessibilityBrowserTest { : public CrossPlatformAccessibilityBrowserTest {
public:
CrossPlatformAccessibilityBrowserTestWithImplicitRootScrolling() = default;
~CrossPlatformAccessibilityBrowserTestWithImplicitRootScrolling() override =
default;
protected:
void ChooseFeatures(std::vector<base::Feature>* enabled_features, void ChooseFeatures(std::vector<base::Feature>* enabled_features,
std::vector<base::Feature>* disabled_features) override { std::vector<base::Feature>* disabled_features) override {
enabled_features->emplace_back(blink::features::kImplicitRootScroller); enabled_features->emplace_back(blink::features::kImplicitRootScroller);
...@@ -1475,35 +1488,30 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1475,35 +1488,30 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
NonInteractiveChangesAreBatched) { NonInteractiveChangesAreBatched) {
// Ensure that normal DOM changes are batched together, and do not occur // Ensure that normal DOM changes are batched together, and do not occur
// more than once every kDelayForDeferredUpdatesAfterPageLoad. // more than once every kDelayForDeferredUpdatesAfterPageLoad.
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
R"HTML(data:text/html, <!DOCTYPE html>
<!doctype html> <html>
<body><div id=foo></div> <body>
<script> <div id="foo">
const startTime = performance.now(); </div>
const fooElem = document.getElementById('foo'); <script>
function addChild() { const startTime = performance.now();
const newChild = document.createElement('div'); const fooElem = document.getElementById('foo');
newChild.innerHTML = '<button>x</button>'; function addChild() {
fooElem.appendChild(newChild); const newChild = document.createElement('div');
if (performance.now() - startTime < 1000) newChild.innerHTML = '<button>x</button>';
requestAnimationFrame(addChild); fooElem.appendChild(newChild);
else if (performance.now() - startTime < 1000) {
document.close(); requestAnimationFrame(addChild);
} } else {
addChild(); document.close();
</script> }
</body></html>)HTML"; }
GURL url(url_str); addChild();
</script>
// Load the document and wait for it </body>
{ </html>)HTML");
AccessibilityNotificationWaiter waiter(shell()->web_contents(),
ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete);
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
}
base::ElapsedTimer timer; base::ElapsedTimer timer;
int num_batches = 0; int num_batches = 0;
...@@ -1531,50 +1539,42 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1531,50 +1539,42 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
DocumentSelectionChangesAreNotBatched) { DocumentSelectionChangesAreNotBatched) {
// Ensure that document selection changes are not batched, and occur faster // Ensure that document selection changes are not batched, and occur faster
// than once per kDelayForDeferredUpdatesAfterPageLoad. // than once per kDelayForDeferredUpdatesAfterPageLoad.
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
R"HTML(data:text/html, <!DOCTYPE html>
<!doctype html> <html>
<body><div id=foo></div> <body>
<script> <div id="foo">
const startTime = performance.now(); </div>
const fooElem = document.getElementById('foo'); <script>
function addChild() { const startTime = performance.now();
const newChild = document.createElement('div'); const fooElem = document.getElementById('foo');
newChild.innerHTML = '<button>x</button>'; function addChild() {
fooElem.appendChild(newChild); const newChild = document.createElement('div');
window.getSelection().selectAllChildren(newChild); newChild.innerHTML = '<button>x</button>';
if (performance.now() - startTime < 1000) fooElem.appendChild(newChild);
requestAnimationFrame(addChild); window.getSelection().selectAllChildren(newChild);
else if (performance.now() - startTime < 1000) {
document.close(); requestAnimationFrame(addChild);
} } else {
addChild(); document.close();
</script> }
</body></html>)HTML"; }
GURL url(url_str); addChild();
</script>
// Load the document and wait for it </body>
{ </html>)HTML");
AccessibilityNotificationWaiter waiter(shell()->web_contents(),
ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete);
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
}
base::ElapsedTimer timer; base::ElapsedTimer timer;
int num_batches = 0; int num_batches = 0;
{ AccessibilityNotificationWaiter waiter(
AccessibilityNotificationWaiter waiter(shell()->web_contents(), shell()->web_contents(), ui::kAXModeComplete,
ui::kAXModeComplete, ax::mojom::Event::kDocumentSelectionChanged);
ax::mojom::Event::kLayoutComplete); // Run test for 1 second, counting the number of selection changes.
// Run test for 1 second, counting the number of layout completes. while (timer.Elapsed().InMilliseconds() < 1000) {
while (timer.Elapsed().InMilliseconds() < 1000) { waiter.WaitForNotificationWithTimeout(
waiter.WaitForNotificationWithTimeout( base::TimeDelta::FromMilliseconds(1000) - timer.Elapsed());
base::TimeDelta::FromMilliseconds(1000) - timer.Elapsed()); ++num_batches;
++num_batches;
}
} }
// In practice, num_batches is about 50 on a fast Linux box. // In practice, num_batches is about 50 on a fast Linux box.
...@@ -1587,38 +1587,32 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1587,38 +1587,32 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
ActiveDescendantChangesAreNotBatched) { ActiveDescendantChangesAreNotBatched) {
// Ensure that active descendant changes are not batched, and occur faster // Ensure that active descendant changes are not batched, and occur faster
// than once per kDelayForDeferredUpdatesAfterPageLoad. // than once per kDelayForDeferredUpdatesAfterPageLoad.
const char url_str[] = LoadInitialAccessibilityTreeFromHtml(R"HTML(
R"HTML(data:text/html, <!DOCTYPE html>
<!doctype html> <html>
<body><div id=foo tabindex=0 autofocus></div> <body>
<script> <div id="foo" tabindex="0" autofocus>
const startTime = performance.now(); </div>
const fooElem = document.getElementById('foo'); <script>
let count = 0; const startTime = performance.now();
function addChild() { const fooElem = document.getElementById('foo');
const newChild = document.createElement('div'); let count = 0;
++count; function addChild() {
newChild.innerHTML = '<button id=' + count + '>x</button>'; const newChild = document.createElement('div');
fooElem.appendChild(newChild); ++count;
fooElem.setAttribute('aria-activedescendant', count); newChild.innerHTML = '<button id=' + count + '>x</button>';
if (performance.now() - startTime < 1000) fooElem.appendChild(newChild);
requestAnimationFrame(addChild); fooElem.setAttribute('aria-activedescendant', count);
else if (performance.now() - startTime < 1000) {
document.close(); requestAnimationFrame(addChild);
} } else {
addChild(); document.close();
</script> }
</body></html>)HTML"; }
GURL url(url_str); addChild();
</script>
// Load the document and wait for it </body>
{ </html>)HTML");
AccessibilityNotificationWaiter waiter(shell()->web_contents(),
ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete);
EXPECT_TRUE(NavigateToURL(shell(), url));
waiter.WaitForNotification();
}
base::ElapsedTimer timer; base::ElapsedTimer timer;
int num_batches = 0; int num_batches = 0;
...@@ -1647,13 +1641,15 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -1647,13 +1641,15 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
// listener to it we can make it no longer ignored without correctly firing // listener to it we can make it no longer ignored without correctly firing
// the right notifications - with the end result being that the whole // the right notifications - with the end result being that the whole
// accessibility tree is broken. // accessibility tree is broken.
LoadInitialAccessibilityTreeFromUrl(GURL(R"HTML(data:text/html, LoadInitialAccessibilityTreeFromHtml(R"HTML(
<!DOCTYPE html> <!DOCTYPE html>
<html>
<body> <body>
<div> <div>
<button>This should be accessible</button> <button>This should be accessible</button>
</div> </div>
</body></html>)HTML")); </body>
</html>)HTML");
BrowserAccessibilityManager* browser_accessibility_manager = GetManager(); BrowserAccessibilityManager* browser_accessibility_manager = GetManager();
BrowserAccessibility* root_browser_accessibility = BrowserAccessibility* root_browser_accessibility =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment