Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1244)

Side by Side Diff: content/browser/accessibility/site_per_process_accessibility_browsertest.cc

Issue 1155993003: Fix accessibility with out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/accessibility/browser_accessibility.h" 8 #include "content/browser/accessibility/browser_accessibility.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 9 #include "content/browser/accessibility/browser_accessibility_manager.h"
10 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 10 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #if defined(OS_ANDROID) 51 #if defined(OS_ANDROID)
52 #define MAYBE_CrossSiteIframeAccessibility DISABLED_CrossSiteIframeAccessibility 52 #define MAYBE_CrossSiteIframeAccessibility DISABLED_CrossSiteIframeAccessibility
53 #else 53 #else
54 #define MAYBE_CrossSiteIframeAccessibility CrossSiteIframeAccessibility 54 #define MAYBE_CrossSiteIframeAccessibility CrossSiteIframeAccessibility
55 #endif 55 #endif
56 IN_PROC_BROWSER_TEST_F(SitePerProcessAccessibilityBrowserTest, 56 IN_PROC_BROWSER_TEST_F(SitePerProcessAccessibilityBrowserTest,
57 MAYBE_CrossSiteIframeAccessibility) { 57 MAYBE_CrossSiteIframeAccessibility) {
58 // Enable full accessibility for all current and future WebContents. 58 // Enable full accessibility for all current and future WebContents.
59 BrowserAccessibilityState::GetInstance()->EnableAccessibility(); 59 BrowserAccessibilityState::GetInstance()->EnableAccessibility();
60 60
61 AccessibilityNotificationWaiter main_frame_accessibility_waiter(
62 shell(), AccessibilityModeComplete,
63 ui::AX_EVENT_LOAD_COMPLETE);
64
65 host_resolver()->AddRule("*", "127.0.0.1"); 61 host_resolver()->AddRule("*", "127.0.0.1");
66 ASSERT_TRUE(test_server()->Start()); 62 ASSERT_TRUE(test_server()->Start());
67 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); 63 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
68 NavigateToURL(shell(), main_url); 64 NavigateToURL(shell(), main_url);
69 65
70 // It is safe to obtain the root frame tree node here, as it doesn't change. 66 // It is safe to obtain the root frame tree node here, as it doesn't change.
71 FrameTreeNode* root = 67 FrameTreeNode* root =
72 static_cast<WebContentsImpl*>(shell()->web_contents())-> 68 static_cast<WebContentsImpl*>(shell()->web_contents())->
73 GetFrameTree()->root(); 69 GetFrameTree()->root();
74 70
75 // Load same-site page into iframe. 71 // Load same-site page into iframe.
76 FrameTreeNode* child = root->child_at(0); 72 FrameTreeNode* child = root->child_at(0);
77 GURL http_url(test_server()->GetURL("files/title1.html")); 73 GURL http_url(test_server()->GetURL("files/title1.html"));
78 NavigateFrameToURL(child, http_url); 74 NavigateFrameToURL(child, http_url);
79 75
80 // Load cross-site page into iframe. 76 // Load cross-site page into iframe.
77 RenderFrameHostImpl* child_rfh =
78 child->render_manager()->current_frame_host();
81 GURL::Replacements replace_host; 79 GURL::Replacements replace_host;
82 GURL cross_site_url(test_server()->GetURL("files/title2.html")); 80 GURL cross_site_url(test_server()->GetURL("files/title2.html"));
83 replace_host.SetHostStr("foo.com"); 81 replace_host.SetHostStr("foo.com");
84 cross_site_url = cross_site_url.ReplaceComponents(replace_host); 82 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
85 NavigateFrameToURL(root->child_at(0), cross_site_url); 83 NavigateFrameToURL(root->child_at(0), cross_site_url);
86 84
87 // Ensure that we have created a new process for the subframe. 85 // Ensure that we have created a new process for the subframe.
88 ASSERT_EQ(2U, root->child_count()); 86 ASSERT_EQ(2U, root->child_count());
89 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); 87 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance();
90 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); 88 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
91 89
92 // Wait for the accessibility tree from the main frame to load. 90 // Wait until the iframe completes the swap.
93 // Because we created the AccessibilityNotificationWaiter before accessibility 91 RenderFrameHostDeletedObserver rfhdo(child_rfh);
94 // was enabled, we're guaranteed to get a LOAD_COMPLETE event. 92 rfhdo.WaitUntilDeleted();
93
94 // Waits for the event that modifies the iframe in the accessibility tree.
95 // This event is sent immediatelly after the swap.
96 AccessibilityNotificationWaiter main_frame_accessibility_waiter(
dmazzoni 2015/05/28 19:12:10 Be careful about constructing the waiter too late.
lfg 2015/05/29 19:23:29 That's why I had the RFHostDeletedObserver right a
dmazzoni 2015/05/29 19:37:23 Yes, but I believe it's possible that the accessib
97 shell(), AccessibilityModeComplete,
98 ui::AX_EVENT_CHILDREN_CHANGED);
95 main_frame_accessibility_waiter.WaitForNotification(); 99 main_frame_accessibility_waiter.WaitForNotification();
96 100
97 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( 101 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>(
98 shell()->web_contents()->GetMainFrame()); 102 shell()->web_contents()->GetMainFrame());
99 BrowserAccessibilityManager* main_frame_manager = 103 BrowserAccessibilityManager* main_frame_manager =
100 main_frame->browser_accessibility_manager(); 104 main_frame->browser_accessibility_manager();
101 VLOG(1) << "Main frame accessibility tree:\n" 105 VLOG(1) << "Main frame accessibility tree:\n"
102 << main_frame_manager->SnapshotAXTreeForTesting().ToString(); 106 << main_frame_manager->SnapshotAXTreeForTesting().ToString();
103 EXPECT_TRUE(AccessibilityTreeIsLoaded(main_frame_manager)); 107 EXPECT_TRUE(AccessibilityTreeIsLoaded(main_frame_manager));
104 108
(...skipping 18 matching lines...) Expand all
123 // Assert that we can walk from the main frame down into the child frame 127 // Assert that we can walk from the main frame down into the child frame
124 // directly, getting correct roles and data along the way. 128 // directly, getting correct roles and data along the way.
125 BrowserAccessibility* ax_root = main_frame_manager->GetRoot(); 129 BrowserAccessibility* ax_root = main_frame_manager->GetRoot();
126 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_root->GetRole()); 130 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_root->GetRole());
127 ASSERT_EQ(1U, ax_root->PlatformChildCount()); 131 ASSERT_EQ(1U, ax_root->PlatformChildCount());
128 132
129 BrowserAccessibility* ax_group = ax_root->PlatformGetChild(0); 133 BrowserAccessibility* ax_group = ax_root->PlatformGetChild(0);
130 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_group->GetRole()); 134 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_group->GetRole());
131 ASSERT_EQ(2U, ax_group->PlatformChildCount()); 135 ASSERT_EQ(2U, ax_group->PlatformChildCount());
132 136
133 BrowserAccessibility* ax_iframe = ax_group->PlatformGetChild(0);
134 EXPECT_EQ(ui::AX_ROLE_IFRAME, ax_iframe->GetRole());
dmazzoni 2015/05/28 19:12:10 We definitely want the IFRAME element to be in the
lfg 2015/05/29 19:23:29 Done.
135 ASSERT_EQ(1U, ax_iframe->PlatformChildCount());
136
137 BrowserAccessibility* ax_scroll_area = ax_iframe->PlatformGetChild(0);
138 EXPECT_EQ(ui::AX_ROLE_SCROLL_AREA, ax_scroll_area->GetRole());
dmazzoni 2015/05/28 19:12:10 I'm okay with losing the scroll area. I'm actually
lfg 2015/05/29 19:23:29 Acknowledged.
139 ASSERT_EQ(1U, ax_scroll_area->PlatformChildCount());
140
141 BrowserAccessibility* ax_child_frame_root = 137 BrowserAccessibility* ax_child_frame_root =
142 ax_scroll_area->PlatformGetChild(0); 138 ax_group->PlatformGetChild(0);
143 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_child_frame_root->GetRole()); 139 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_child_frame_root->GetRole());
144 ASSERT_EQ(1U, ax_child_frame_root->PlatformChildCount()); 140 ASSERT_EQ(1U, ax_child_frame_root->PlatformChildCount());
145 EXPECT_EQ("Title Of Awesomeness", 141 EXPECT_EQ("Title Of Awesomeness",
146 ax_child_frame_root->GetStringAttribute(ui::AX_ATTR_NAME)); 142 ax_child_frame_root->GetStringAttribute(ui::AX_ATTR_NAME));
147 143
148 BrowserAccessibility* ax_child_frame_group = 144 BrowserAccessibility* ax_child_frame_group =
149 ax_child_frame_root->PlatformGetChild(0); 145 ax_child_frame_root->PlatformGetChild(0);
150 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_child_frame_group->GetRole()); 146 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_child_frame_group->GetRole());
151 ASSERT_EQ(1U, ax_child_frame_group->PlatformChildCount()); 147 ASSERT_EQ(1U, ax_child_frame_group->PlatformChildCount());
152 148
153 BrowserAccessibility* ax_child_frame_static_text = 149 BrowserAccessibility* ax_child_frame_static_text =
154 ax_child_frame_group->PlatformGetChild(0); 150 ax_child_frame_group->PlatformGetChild(0);
155 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, ax_child_frame_static_text->GetRole()); 151 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, ax_child_frame_static_text->GetRole());
156 ASSERT_EQ(0U, ax_child_frame_static_text->PlatformChildCount()); 152 ASSERT_EQ(0U, ax_child_frame_static_text->PlatformChildCount());
157 153
158 // Last, check that the parent of the child frame root is correct. 154 // Last, check that the parent of the child frame root is correct.
159 EXPECT_EQ(ax_child_frame_root->GetParent(), ax_scroll_area); 155 EXPECT_EQ(ax_child_frame_root->GetParent(), ax_group);
160 } 156 }
161 157
162 } // namespace content 158 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698