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

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: fix dcheck/android build Created 5 years, 5 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
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 29 matching lines...) Expand all
40 }; 40 };
41 41
42 // Utility function to determine if an accessibility tree has finished loading 42 // Utility function to determine if an accessibility tree has finished loading
43 // or if the tree represents a page that hasn't finished loading yet. 43 // or if the tree represents a page that hasn't finished loading yet.
44 bool AccessibilityTreeIsLoaded(BrowserAccessibilityManager* manager) { 44 bool AccessibilityTreeIsLoaded(BrowserAccessibilityManager* manager) {
45 BrowserAccessibility* root = manager->GetRoot(); 45 BrowserAccessibility* root = manager->GetRoot();
46 return (root->GetFloatAttribute(ui::AX_ATTR_DOC_LOADING_PROGRESS) == 1.0 && 46 return (root->GetFloatAttribute(ui::AX_ATTR_DOC_LOADING_PROGRESS) == 1.0 &&
47 root->GetStringAttribute(ui::AX_ATTR_DOC_URL) != url::kAboutBlankURL); 47 root->GetStringAttribute(ui::AX_ATTR_DOC_URL) != url::kAboutBlankURL);
48 } 48 }
49 49
50 // Disabled, see https://crbug.com/490831.
51 // Times out on Android, not clear if it's an actual bug or just slow. 50 // Times out on Android, not clear if it's an actual bug or just slow.
51 #if defined(OS_ANDROID)
52 #define MAYBE_CrossSiteIframeAccessibility DISABLED_CrossSiteIframeAccessibility
53 #else
54 #define MAYBE_CrossSiteIframeAccessibility CrossSiteIframeAccessibility
55 #endif
52 IN_PROC_BROWSER_TEST_F(SitePerProcessAccessibilityBrowserTest, 56 IN_PROC_BROWSER_TEST_F(SitePerProcessAccessibilityBrowserTest,
53 DISABLED_CrossSiteIframeAccessibility) { 57 MAYBE_CrossSiteIframeAccessibility) {
54 // Enable full accessibility for all current and future WebContents. 58 // Enable full accessibility for all current and future WebContents.
55 BrowserAccessibilityState::GetInstance()->EnableAccessibility(); 59 BrowserAccessibilityState::GetInstance()->EnableAccessibility();
56 60
57 AccessibilityNotificationWaiter main_frame_accessibility_waiter(
58 shell(), AccessibilityModeComplete,
59 ui::AX_EVENT_LOAD_COMPLETE);
60
61 host_resolver()->AddRule("*", "127.0.0.1"); 61 host_resolver()->AddRule("*", "127.0.0.1");
62 ASSERT_TRUE(test_server()->Start()); 62 ASSERT_TRUE(test_server()->Start());
63 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"));
64 NavigateToURL(shell(), main_url); 64 NavigateToURL(shell(), main_url);
65 65
66 // 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.
67 FrameTreeNode* root = 67 FrameTreeNode* root =
68 static_cast<WebContentsImpl*>(shell()->web_contents())-> 68 static_cast<WebContentsImpl*>(shell()->web_contents())->
69 GetFrameTree()->root(); 69 GetFrameTree()->root();
70 70
71 // Load same-site page into iframe. 71 // Load same-site page into iframe.
72 FrameTreeNode* child = root->child_at(0); 72 FrameTreeNode* child = root->child_at(0);
73 GURL http_url(test_server()->GetURL("files/title1.html")); 73 GURL http_url(test_server()->GetURL("files/title1.html"));
74 NavigateFrameToURL(child, http_url); 74 NavigateFrameToURL(child, http_url);
75 75
76 // Load cross-site page into iframe. 76 // Load cross-site page into iframe.
77 RenderFrameHostImpl* child_rfh =
78 child->render_manager()->current_frame_host();
79 RenderFrameHostDeletedObserver rfhdo(child_rfh);
77 GURL::Replacements replace_host; 80 GURL::Replacements replace_host;
78 GURL cross_site_url(test_server()->GetURL("files/title2.html")); 81 GURL cross_site_url(test_server()->GetURL("files/title2.html"));
79 replace_host.SetHostStr("foo.com"); 82 replace_host.SetHostStr("foo.com");
80 cross_site_url = cross_site_url.ReplaceComponents(replace_host); 83 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
81 NavigateFrameToURL(root->child_at(0), cross_site_url); 84 NavigateFrameToURL(root->child_at(0), cross_site_url);
82 85
83 // Ensure that we have created a new process for the subframe. 86 // Ensure that we have created a new process for the subframe.
84 ASSERT_EQ(2U, root->child_count()); 87 ASSERT_EQ(2U, root->child_count());
85 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); 88 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance();
86 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); 89 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
87 90
88 // Wait for the accessibility tree from the main frame to load. 91 AccessibilityNotificationWaiter main_frame_accessibility_waiter(
dmazzoni 2015/06/25 22:15:38 This still doesn't look early enough to me. I thin
lfg 2015/06/25 22:48:24 It can't be above because it'll get the wrong even
dmazzoni 2015/06/25 22:57:13 A side effect of creating an AccessibilityNotifica
89 // Because we created the AccessibilityNotificationWaiter before accessibility 92 shell(), AccessibilityModeComplete, ui::AX_EVENT_CHILDREN_CHANGED);
90 // was enabled, we're guaranteed to get a LOAD_COMPLETE event. 93
94 // Wait until the iframe completes the swap.
95 rfhdo.WaitUntilDeleted();
96
97 // Waits for the event that modifies the iframe in the accessibility tree.
98 // This event is sent immediatelly after the swap.
91 main_frame_accessibility_waiter.WaitForNotification(); 99 main_frame_accessibility_waiter.WaitForNotification();
92 100
93 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( 101 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>(
94 shell()->web_contents()->GetMainFrame()); 102 shell()->web_contents()->GetMainFrame());
95 BrowserAccessibilityManager* main_frame_manager = 103 BrowserAccessibilityManager* main_frame_manager =
96 main_frame->browser_accessibility_manager(); 104 main_frame->browser_accessibility_manager();
97 VLOG(1) << "Main frame accessibility tree:\n" 105 VLOG(1) << "Main frame accessibility tree:\n"
98 << main_frame_manager->SnapshotAXTreeForTesting().ToString(); 106 << main_frame_manager->SnapshotAXTreeForTesting().ToString();
99 EXPECT_TRUE(AccessibilityTreeIsLoaded(main_frame_manager)); 107 EXPECT_TRUE(AccessibilityTreeIsLoaded(main_frame_manager));
100 108
(...skipping 22 matching lines...) Expand all
123 ASSERT_EQ(1U, ax_root->PlatformChildCount()); 131 ASSERT_EQ(1U, ax_root->PlatformChildCount());
124 132
125 BrowserAccessibility* ax_group = ax_root->PlatformGetChild(0); 133 BrowserAccessibility* ax_group = ax_root->PlatformGetChild(0);
126 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_group->GetRole()); 134 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_group->GetRole());
127 ASSERT_EQ(2U, ax_group->PlatformChildCount()); 135 ASSERT_EQ(2U, ax_group->PlatformChildCount());
128 136
129 BrowserAccessibility* ax_iframe = ax_group->PlatformGetChild(0); 137 BrowserAccessibility* ax_iframe = ax_group->PlatformGetChild(0);
130 EXPECT_EQ(ui::AX_ROLE_IFRAME, ax_iframe->GetRole()); 138 EXPECT_EQ(ui::AX_ROLE_IFRAME, ax_iframe->GetRole());
131 ASSERT_EQ(1U, ax_iframe->PlatformChildCount()); 139 ASSERT_EQ(1U, ax_iframe->PlatformChildCount());
132 140
133 BrowserAccessibility* ax_scroll_area = ax_iframe->PlatformGetChild(0); 141 BrowserAccessibility* ax_child_frame_root = ax_iframe->PlatformGetChild(0);
134 EXPECT_EQ(ui::AX_ROLE_SCROLL_AREA, ax_scroll_area->GetRole());
135 ASSERT_EQ(1U, ax_scroll_area->PlatformChildCount());
136
137 BrowserAccessibility* ax_child_frame_root =
138 ax_scroll_area->PlatformGetChild(0);
139 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_child_frame_root->GetRole()); 142 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_child_frame_root->GetRole());
140 ASSERT_EQ(1U, ax_child_frame_root->PlatformChildCount()); 143 ASSERT_EQ(1U, ax_child_frame_root->PlatformChildCount());
141 EXPECT_EQ("Title Of Awesomeness", 144 EXPECT_EQ("Title Of Awesomeness",
142 ax_child_frame_root->GetStringAttribute(ui::AX_ATTR_NAME)); 145 ax_child_frame_root->GetStringAttribute(ui::AX_ATTR_NAME));
143 146
144 BrowserAccessibility* ax_child_frame_group = 147 BrowserAccessibility* ax_child_frame_group =
145 ax_child_frame_root->PlatformGetChild(0); 148 ax_child_frame_root->PlatformGetChild(0);
146 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_child_frame_group->GetRole()); 149 EXPECT_EQ(ui::AX_ROLE_GROUP, ax_child_frame_group->GetRole());
147 ASSERT_EQ(1U, ax_child_frame_group->PlatformChildCount()); 150 ASSERT_EQ(1U, ax_child_frame_group->PlatformChildCount());
148 151
149 BrowserAccessibility* ax_child_frame_static_text = 152 BrowserAccessibility* ax_child_frame_static_text =
150 ax_child_frame_group->PlatformGetChild(0); 153 ax_child_frame_group->PlatformGetChild(0);
151 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, ax_child_frame_static_text->GetRole()); 154 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, ax_child_frame_static_text->GetRole());
152 ASSERT_EQ(0U, ax_child_frame_static_text->PlatformChildCount()); 155 ASSERT_EQ(0U, ax_child_frame_static_text->PlatformChildCount());
153 156
154 // Last, check that the parent of the child frame root is correct. 157 // Last, check that the parent of the child frame root is correct.
155 EXPECT_EQ(ax_child_frame_root->GetParent(), ax_scroll_area); 158 EXPECT_EQ(ax_child_frame_root->GetParent(), ax_iframe);
156 } 159 }
157 160
158 } // namespace content 161 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698