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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2830183003: Re-enable ScrollBubblingFromOOPIFTest on CrOS. (Closed)
Patch Set: Synchronize with an InputEventObserver instead of delay. Created 3 years, 7 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 | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 "window.location.href = '" + frame_url.spec() + "';")); 928 "window.location.href = '" + frame_url.spec() + "';"));
929 load_observer.Wait(); 929 load_observer.Wait();
930 930
931 // Wait for the title to update and ensure it affects the right NavEntry. 931 // Wait for the title to update and ensure it affects the right NavEntry.
932 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 932 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
933 NavigationEntry* entry = 933 NavigationEntry* entry =
934 shell()->web_contents()->GetController().GetLastCommittedEntry(); 934 shell()->web_contents()->GetController().GetLastCommittedEntry();
935 EXPECT_EQ(expected_title, entry->GetTitle()); 935 EXPECT_EQ(expected_title, entry->GetTitle());
936 } 936 }
937 937
938 // Class to detect incoming GestureScrollEnd acks for bubbling tests.
939 class GestureScrollEndObserver
940 : public content::RenderWidgetHost::InputEventObserver {
941 public:
942 GestureScrollEndObserver()
943 : message_loop_runner_(new content::MessageLoopRunner),
944 gesture_scroll_end_ack_received_(false) {}
945 ~GestureScrollEndObserver() override {}
946
947 void OnInputEventAck(const blink::WebInputEvent& event) override {
948 if (event.GetType() == blink::WebInputEvent::kGestureScrollEnd) {
949 gesture_scroll_end_ack_received_ = true;
950 if (message_loop_runner_->loop_running())
951 message_loop_runner_->Quit();
952 }
953 }
954
955 void Wait() {
956 if (!gesture_scroll_end_ack_received_) {
957 message_loop_runner_->Run();
958 }
959 }
960
961 void Reset() {
962 gesture_scroll_end_ack_received_ = false;
963 message_loop_runner_ = new content::MessageLoopRunner;
964 }
965
966 private:
967 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
968 bool gesture_scroll_end_ack_received_;
969
970 DISALLOW_COPY_AND_ASSIGN(GestureScrollEndObserver);
971 };
972
938 // Class to sniff incoming IPCs for FrameHostMsg_FrameRectChanged messages. 973 // Class to sniff incoming IPCs for FrameHostMsg_FrameRectChanged messages.
939 class FrameRectChangedMessageFilter : public content::BrowserMessageFilter { 974 class FrameRectChangedMessageFilter : public content::BrowserMessageFilter {
940 public: 975 public:
941 FrameRectChangedMessageFilter() 976 FrameRectChangedMessageFilter()
942 : content::BrowserMessageFilter(FrameMsgStart), 977 : content::BrowserMessageFilter(FrameMsgStart),
943 message_loop_runner_(new content::MessageLoopRunner), 978 message_loop_runner_(new content::MessageLoopRunner),
944 frame_rect_received_(false) {} 979 frame_rect_received_(false) {}
945 980
946 bool OnMessageReceived(const IPC::Message& message) override { 981 bool OnMessageReceived(const IPC::Message& message) override {
947 IPC_BEGIN_MESSAGE_MAP(FrameRectChangedMessageFilter, message) 982 IPC_BEGIN_MESSAGE_MAP(FrameRectChangedMessageFilter, message)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1112
1078 // The precise amount of scroll for the first view position update is not 1113 // The precise amount of scroll for the first view position update is not
1079 // deterministic, so this simply verifies that the OOPIF moved from its 1114 // deterministic, so this simply verifies that the OOPIF moved from its
1080 // earlier position. 1115 // earlier position.
1081 gfx::Rect update_rect = filter->last_rect(); 1116 gfx::Rect update_rect = filter->last_rect();
1082 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y()); 1117 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y());
1083 } 1118 }
1084 1119
1085 // Test that scrolling a nested out-of-process iframe bubbles unused scroll 1120 // Test that scrolling a nested out-of-process iframe bubbles unused scroll
1086 // delta to a parent frame. 1121 // delta to a parent frame.
1087 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 1122 #if defined(OS_ANDROID)
1088 #define MAYBE_ScrollBubblingFromOOPIFTest DISABLED_ScrollBubblingFromOOPIFTest 1123 #define MAYBE_ScrollBubblingFromOOPIFTest DISABLED_ScrollBubblingFromOOPIFTest
1089 #else 1124 #else
1090 #define MAYBE_ScrollBubblingFromOOPIFTest ScrollBubblingFromOOPIFTest 1125 #define MAYBE_ScrollBubblingFromOOPIFTest ScrollBubblingFromOOPIFTest
1091 #endif 1126 #endif
1092 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1127 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1093 MAYBE_ScrollBubblingFromOOPIFTest) { 1128 MAYBE_ScrollBubblingFromOOPIFTest) {
1094 GURL main_url(embedded_test_server()->GetURL( 1129 GURL main_url(embedded_test_server()->GetURL(
1095 "a.com", "/cross_site_iframe_factory.html?a(b)")); 1130 "a.com", "/cross_site_iframe_factory.html?a(b)"));
1096 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1131 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1097 1132
1098 // It is safe to obtain the root frame tree node here, as it doesn't change. 1133 // It is safe to obtain the root frame tree node here, as it doesn't change.
1099 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1134 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1100 ->GetFrameTree() 1135 ->GetFrameTree()
1101 ->root(); 1136 ->root();
1102 ASSERT_EQ(1U, root->child_count()); 1137 ASSERT_EQ(1U, root->child_count());
1103 1138
1104 FrameTreeNode* parent_iframe_node = root->child_at(0); 1139 FrameTreeNode* parent_iframe_node = root->child_at(0);
1105 1140
1106 // This test uses the position of the nested iframe within the parent iframe 1141 // This test uses the position of the nested iframe within the parent iframe
1107 // to infer the scroll position of the parent. FrameRectChangedMessageFilter 1142 // to infer the scroll position of the parent. FrameRectChangedMessageFilter
1108 // catches updates to the position in order to avoid busy waiting. 1143 // catches updates to the position in order to avoid busy waiting.
1109 // It gets created early to catch the initial rects from the navigation. 1144 // It gets created early to catch the initial rects from the navigation.
1110 scoped_refptr<FrameRectChangedMessageFilter> filter = 1145 scoped_refptr<FrameRectChangedMessageFilter> filter =
1111 new FrameRectChangedMessageFilter(); 1146 new FrameRectChangedMessageFilter();
1112 parent_iframe_node->current_frame_host()->GetProcess()->AddFilter( 1147 parent_iframe_node->current_frame_host()->GetProcess()->AddFilter(
1113 filter.get()); 1148 filter.get());
1114 1149
1150 std::unique_ptr<GestureScrollEndObserver> ack_observer =
1151 base::MakeUnique<GestureScrollEndObserver>();
1152 parent_iframe_node->current_frame_host()
1153 ->GetRenderWidgetHost()
1154 ->AddInputEventObserver(ack_observer.get());
1155
1115 GURL site_url(embedded_test_server()->GetURL( 1156 GURL site_url(embedded_test_server()->GetURL(
1116 "b.com", "/frame_tree/page_with_positioned_frame.html")); 1157 "b.com", "/frame_tree/page_with_positioned_frame.html"));
1117 NavigateFrameToURL(parent_iframe_node, site_url); 1158 NavigateFrameToURL(parent_iframe_node, site_url);
1118 1159
1119 // Navigate the nested frame to a page large enough to have scrollbars. 1160 // Navigate the nested frame to a page large enough to have scrollbars.
1120 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0); 1161 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0);
1121 GURL nested_site_url(embedded_test_server()->GetURL( 1162 GURL nested_site_url(embedded_test_server()->GetURL(
1122 "baz.com", "/tall_page.html")); 1163 "baz.com", "/tall_page.html"));
1123 NavigateFrameToURL(nested_iframe_node, nested_site_url); 1164 NavigateFrameToURL(nested_iframe_node, nested_site_url);
1124 1165
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 // pathways, which currently break this test. 1203 // pathways, which currently break this test.
1163 // https://bugs.chromium.org/p/chromium/issues/detail?id=710513 1204 // https://bugs.chromium.org/p/chromium/issues/detail?id=710513
1164 scroll_event.has_precise_scrolling_deltas = true; 1205 scroll_event.has_precise_scrolling_deltas = true;
1165 rwhv_parent->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo()); 1206 rwhv_parent->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
1166 1207
1167 // Ensure that the view position is propagated to the child properly. 1208 // Ensure that the view position is propagated to the child properly.
1168 filter->Wait(); 1209 filter->Wait();
1169 update_rect = filter->last_rect(); 1210 update_rect = filter->last_rect();
1170 EXPECT_LT(update_rect.y(), initial_y); 1211 EXPECT_LT(update_rect.y(), initial_y);
1171 filter->Reset(); 1212 filter->Reset();
1213 ack_observer->Reset();
1172 1214
1173 // Now scroll the nested frame upward, which should bubble to the parent. 1215 // Now scroll the nested frame upward, which should bubble to the parent.
1174 // The upscroll exceeds the amount that the frame was initially scrolled 1216 // The upscroll exceeds the amount that the frame was initially scrolled
1175 // down to account for rounding. 1217 // down to account for rounding.
1176 scroll_event.delta_y = 6.0f; 1218 scroll_event.delta_y = 6.0f;
1177 rwhv_nested->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo()); 1219 rwhv_nested->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
1178 1220
1179 filter->Wait(); 1221 filter->Wait();
1180 // This loop isn't great, but it accounts for the possibility of multiple 1222 // This loop isn't great, but it accounts for the possibility of multiple
1181 // incremental updates happening as a result of the scroll animation. 1223 // incremental updates happening as a result of the scroll animation.
1182 // A failure condition of this test is that the loop might not terminate 1224 // A failure condition of this test is that the loop might not terminate
1183 // due to bubbling not working properly. If the overscroll bubbles to the 1225 // due to bubbling not working properly. If the overscroll bubbles to the
1184 // parent iframe then the nested frame's y coord will return to its 1226 // parent iframe then the nested frame's y coord will return to its
1185 // initial position. 1227 // initial position.
1186 update_rect = filter->last_rect(); 1228 update_rect = filter->last_rect();
1187 while (update_rect.y() > initial_y) { 1229 while (update_rect.y() > initial_y) {
1188 base::RunLoop run_loop; 1230 base::RunLoop run_loop;
1189 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1231 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1190 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); 1232 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
1191 run_loop.Run(); 1233 run_loop.Run();
1192 update_rect = filter->last_rect(); 1234 update_rect = filter->last_rect();
1193 } 1235 }
1194 1236
1195 filter->Reset(); 1237 filter->Reset();
1238 // Once we've sent a wheel to the nested iframe that we expect to turn into
1239 // a bubbling scroll, we need to delay to make sure the GestureScrollBegin
1240 // from this new scroll doesn't hit the RenderWidgetHostImpl before the
1241 // GestureScrollEnd bubbled from the child.
1242 // This timing only seems to be needed for CrOS, but we'll enable it on
1243 // all platforms just to lessen the possibility of tests being flakey
1244 // on non-CrOS platforms.
1245 ack_observer->Wait();
1196 1246
1197 // Scroll the parent down again in order to test scroll bubbling from 1247 // Scroll the parent down again in order to test scroll bubbling from
1198 // gestures. 1248 // gestures.
1199 scroll_event.delta_y = -5.0f; 1249 scroll_event.delta_y = -5.0f;
1200 rwhv_parent->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo()); 1250 rwhv_parent->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
1201 1251
1202 // Ensure ensuing offset change is received, and then reset the filter. 1252 // Ensure ensuing offset change is received, and then reset the filter.
1203 filter->Wait(); 1253 filter->Wait();
1204 filter->Reset(); 1254 filter->Reset();
1205 1255
(...skipping 8735 matching lines...) Expand 10 before | Expand all | Expand 10 after
9941 names.insert(root->children[0]->frame_entry->frame_unique_name()); 9991 names.insert(root->children[0]->frame_entry->frame_unique_name());
9942 } 9992 }
9943 9993
9944 // More than one entry in the set means that the subframe frame navigation 9994 // More than one entry in the set means that the subframe frame navigation
9945 // entries didn't have a consistent unique name. This will break history 9995 // entries didn't have a consistent unique name. This will break history
9946 // navigations =( 9996 // navigations =(
9947 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; 9997 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!";
9948 } 9998 }
9949 9999
9950 } // namespace content 10000 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698