OLD | NEW |
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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 load_observer.Wait(); | 931 load_observer.Wait(); |
932 | 932 |
933 // Wait for the title to update and ensure it affects the right NavEntry. | 933 // Wait for the title to update and ensure it affects the right NavEntry. |
934 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 934 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
935 NavigationEntry* entry = | 935 NavigationEntry* entry = |
936 shell()->web_contents()->GetController().GetLastCommittedEntry(); | 936 shell()->web_contents()->GetController().GetLastCommittedEntry(); |
937 EXPECT_EQ(expected_title, entry->GetTitle()); | 937 EXPECT_EQ(expected_title, entry->GetTitle()); |
938 } | 938 } |
939 | 939 |
940 // Class to detect incoming GestureScrollEnd acks for bubbling tests. | 940 // Class to detect incoming GestureScrollEnd acks for bubbling tests. |
941 class GestureScrollEndObserver | 941 class InputEventAckWaiter |
942 : public content::RenderWidgetHost::InputEventObserver { | 942 : public content::RenderWidgetHost::InputEventObserver { |
943 public: | 943 public: |
944 GestureScrollEndObserver() | 944 InputEventAckWaiter(blink::WebInputEvent::Type ack_type_waiting_for) |
945 : message_loop_runner_(new content::MessageLoopRunner), | 945 : message_loop_runner_(new content::MessageLoopRunner), |
946 gesture_scroll_end_ack_received_(false) {} | 946 ack_type_waiting_for_(ack_type_waiting_for), |
947 ~GestureScrollEndObserver() override {} | 947 desired_ack_type_received_(false) {} |
| 948 ~InputEventAckWaiter() override {} |
948 | 949 |
949 void OnInputEventAck(const blink::WebInputEvent& event) override { | 950 void OnInputEventAck(const blink::WebInputEvent& event) override { |
950 if (event.GetType() == blink::WebInputEvent::kGestureScrollEnd) { | 951 if (event.GetType() == ack_type_waiting_for_) { |
951 gesture_scroll_end_ack_received_ = true; | 952 desired_ack_type_received_ = true; |
952 if (message_loop_runner_->loop_running()) | 953 if (message_loop_runner_->loop_running()) |
953 message_loop_runner_->Quit(); | 954 message_loop_runner_->Quit(); |
954 } | 955 } |
955 } | 956 } |
956 | 957 |
957 void Wait() { | 958 void Wait() { |
958 if (!gesture_scroll_end_ack_received_) { | 959 if (!desired_ack_type_received_) { |
959 message_loop_runner_->Run(); | 960 message_loop_runner_->Run(); |
960 } | 961 } |
961 } | 962 } |
962 | 963 |
963 void Reset() { | 964 void Reset() { |
964 gesture_scroll_end_ack_received_ = false; | 965 desired_ack_type_received_ = false; |
965 message_loop_runner_ = new content::MessageLoopRunner; | 966 message_loop_runner_ = new content::MessageLoopRunner; |
966 } | 967 } |
967 | 968 |
968 private: | 969 private: |
969 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 970 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
970 bool gesture_scroll_end_ack_received_; | 971 blink::WebInputEvent::Type ack_type_waiting_for_; |
| 972 bool desired_ack_type_received_; |
971 | 973 |
972 DISALLOW_COPY_AND_ASSIGN(GestureScrollEndObserver); | 974 DISALLOW_COPY_AND_ASSIGN(InputEventAckWaiter); |
973 }; | 975 }; |
974 | 976 |
975 // Class to sniff incoming IPCs for FrameHostMsg_FrameRectChanged messages. | 977 // Class to sniff incoming IPCs for FrameHostMsg_FrameRectChanged messages. |
976 class FrameRectChangedMessageFilter : public content::BrowserMessageFilter { | 978 class FrameRectChangedMessageFilter : public content::BrowserMessageFilter { |
977 public: | 979 public: |
978 FrameRectChangedMessageFilter() | 980 FrameRectChangedMessageFilter() |
979 : content::BrowserMessageFilter(FrameMsgStart), | 981 : content::BrowserMessageFilter(FrameMsgStart), |
980 message_loop_runner_(new content::MessageLoopRunner), | 982 message_loop_runner_(new content::MessageLoopRunner), |
981 frame_rect_received_(false) {} | 983 frame_rect_received_(false) {} |
982 | 984 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 | 1114 |
1113 filter->Wait(); | 1115 filter->Wait(); |
1114 | 1116 |
1115 // The precise amount of scroll for the first view position update is not | 1117 // The precise amount of scroll for the first view position update is not |
1116 // deterministic, so this simply verifies that the OOPIF moved from its | 1118 // deterministic, so this simply verifies that the OOPIF moved from its |
1117 // earlier position. | 1119 // earlier position. |
1118 gfx::Rect update_rect = filter->last_rect(); | 1120 gfx::Rect update_rect = filter->last_rect(); |
1119 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y()); | 1121 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y()); |
1120 } | 1122 } |
1121 | 1123 |
| 1124 // This test verifies that scroll bubbling from an OOPIF properly forwards |
| 1125 // GestureFlingStart events from the child frame to the parent frame. This |
| 1126 // test times out on failure. |
| 1127 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 1128 GestureFlingStartEventsBubble) { |
| 1129 GURL main_url(embedded_test_server()->GetURL( |
| 1130 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| 1131 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 1132 |
| 1133 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1134 ->GetFrameTree() |
| 1135 ->root(); |
| 1136 ASSERT_EQ(1U, root->child_count()); |
| 1137 |
| 1138 FrameTreeNode* child_iframe_node = root->child_at(0); |
| 1139 |
| 1140 std::unique_ptr<InputEventAckWaiter> gesture_fling_start_ack_observer = |
| 1141 base::MakeUnique<InputEventAckWaiter>( |
| 1142 blink::WebInputEvent::kGestureFlingStart); |
| 1143 root->current_frame_host()->GetRenderWidgetHost()->AddInputEventObserver( |
| 1144 gesture_fling_start_ack_observer.get()); |
| 1145 |
| 1146 RenderWidgetHost* child_rwh = |
| 1147 child_iframe_node->current_frame_host()->GetRenderWidgetHost(); |
| 1148 |
| 1149 WaitForChildFrameSurfaceReady(child_iframe_node->current_frame_host()); |
| 1150 |
| 1151 gesture_fling_start_ack_observer->Reset(); |
| 1152 // Send a GSB, GSU, GFS sequence and verify that the GFS bubbles. |
| 1153 blink::WebGestureEvent gesture_scroll_begin( |
| 1154 blink::WebGestureEvent::kGestureScrollBegin, |
| 1155 blink::WebInputEvent::kNoModifiers, |
| 1156 blink::WebInputEvent::kTimeStampForTesting); |
| 1157 gesture_scroll_begin.source_device = blink::kWebGestureDeviceTouchscreen; |
| 1158 gesture_scroll_begin.data.scroll_begin.delta_hint_units = |
| 1159 blink::WebGestureEvent::ScrollUnits::kPrecisePixels; |
| 1160 gesture_scroll_begin.data.scroll_begin.delta_x_hint = 0.f; |
| 1161 gesture_scroll_begin.data.scroll_begin.delta_y_hint = 5.f; |
| 1162 |
| 1163 child_rwh->ForwardGestureEvent(gesture_scroll_begin); |
| 1164 |
| 1165 blink::WebGestureEvent gesture_scroll_update( |
| 1166 blink::WebGestureEvent::kGestureScrollUpdate, |
| 1167 blink::WebInputEvent::kNoModifiers, |
| 1168 blink::WebInputEvent::kTimeStampForTesting); |
| 1169 gesture_scroll_update.source_device = blink::kWebGestureDeviceTouchscreen; |
| 1170 gesture_scroll_update.data.scroll_update.delta_units = |
| 1171 blink::WebGestureEvent::ScrollUnits::kPrecisePixels; |
| 1172 gesture_scroll_update.data.scroll_update.delta_x = 0.f; |
| 1173 gesture_scroll_update.data.scroll_update.delta_y = 5.f; |
| 1174 gesture_scroll_update.data.scroll_update.velocity_y = 5.f; |
| 1175 |
| 1176 child_rwh->ForwardGestureEvent(gesture_scroll_update); |
| 1177 |
| 1178 blink::WebGestureEvent gesture_fling_start( |
| 1179 blink::WebGestureEvent::kGestureFlingStart, |
| 1180 blink::WebInputEvent::kNoModifiers, |
| 1181 blink::WebInputEvent::kTimeStampForTesting); |
| 1182 gesture_fling_start.source_device = blink::kWebGestureDeviceTouchscreen; |
| 1183 gesture_fling_start.data.fling_start.velocity_x = 0.f; |
| 1184 gesture_fling_start.data.fling_start.velocity_y = 5.f; |
| 1185 |
| 1186 child_rwh->ForwardGestureEvent(gesture_fling_start); |
| 1187 |
| 1188 // We now wait for the fling start event to be acked by the parent |
| 1189 // frame. If the test fails, then the test times out. |
| 1190 gesture_fling_start_ack_observer->Wait(); |
| 1191 } |
| 1192 |
1122 // Test that scrolling a nested out-of-process iframe bubbles unused scroll | 1193 // Test that scrolling a nested out-of-process iframe bubbles unused scroll |
1123 // delta to a parent frame. | 1194 // delta to a parent frame. |
1124 #if defined(OS_ANDROID) | 1195 #if defined(OS_ANDROID) |
1125 #define MAYBE_ScrollBubblingFromOOPIFTest DISABLED_ScrollBubblingFromOOPIFTest | 1196 #define MAYBE_ScrollBubblingFromOOPIFTest DISABLED_ScrollBubblingFromOOPIFTest |
1126 #else | 1197 #else |
1127 #define MAYBE_ScrollBubblingFromOOPIFTest ScrollBubblingFromOOPIFTest | 1198 #define MAYBE_ScrollBubblingFromOOPIFTest ScrollBubblingFromOOPIFTest |
1128 #endif | 1199 #endif |
1129 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1200 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1130 MAYBE_ScrollBubblingFromOOPIFTest) { | 1201 MAYBE_ScrollBubblingFromOOPIFTest) { |
1131 GURL main_url(embedded_test_server()->GetURL( | 1202 GURL main_url(embedded_test_server()->GetURL( |
(...skipping 10 matching lines...) Expand all Loading... |
1142 | 1213 |
1143 // This test uses the position of the nested iframe within the parent iframe | 1214 // This test uses the position of the nested iframe within the parent iframe |
1144 // to infer the scroll position of the parent. FrameRectChangedMessageFilter | 1215 // to infer the scroll position of the parent. FrameRectChangedMessageFilter |
1145 // catches updates to the position in order to avoid busy waiting. | 1216 // catches updates to the position in order to avoid busy waiting. |
1146 // It gets created early to catch the initial rects from the navigation. | 1217 // It gets created early to catch the initial rects from the navigation. |
1147 scoped_refptr<FrameRectChangedMessageFilter> filter = | 1218 scoped_refptr<FrameRectChangedMessageFilter> filter = |
1148 new FrameRectChangedMessageFilter(); | 1219 new FrameRectChangedMessageFilter(); |
1149 parent_iframe_node->current_frame_host()->GetProcess()->AddFilter( | 1220 parent_iframe_node->current_frame_host()->GetProcess()->AddFilter( |
1150 filter.get()); | 1221 filter.get()); |
1151 | 1222 |
1152 std::unique_ptr<GestureScrollEndObserver> ack_observer = | 1223 std::unique_ptr<InputEventAckWaiter> ack_observer = |
1153 base::MakeUnique<GestureScrollEndObserver>(); | 1224 base::MakeUnique<InputEventAckWaiter>( |
| 1225 blink::WebInputEvent::kGestureScrollEnd); |
1154 parent_iframe_node->current_frame_host() | 1226 parent_iframe_node->current_frame_host() |
1155 ->GetRenderWidgetHost() | 1227 ->GetRenderWidgetHost() |
1156 ->AddInputEventObserver(ack_observer.get()); | 1228 ->AddInputEventObserver(ack_observer.get()); |
1157 | 1229 |
1158 GURL site_url(embedded_test_server()->GetURL( | 1230 GURL site_url(embedded_test_server()->GetURL( |
1159 "b.com", "/frame_tree/page_with_positioned_frame.html")); | 1231 "b.com", "/frame_tree/page_with_positioned_frame.html")); |
1160 NavigateFrameToURL(parent_iframe_node, site_url); | 1232 NavigateFrameToURL(parent_iframe_node, site_url); |
1161 | 1233 |
1162 // Navigate the nested frame to a page large enough to have scrollbars. | 1234 // Navigate the nested frame to a page large enough to have scrollbars. |
1163 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0); | 1235 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0); |
(...skipping 8829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9993 names.insert(root->children[0]->frame_entry->frame_unique_name()); | 10065 names.insert(root->children[0]->frame_entry->frame_unique_name()); |
9994 } | 10066 } |
9995 | 10067 |
9996 // More than one entry in the set means that the subframe frame navigation | 10068 // More than one entry in the set means that the subframe frame navigation |
9997 // entries didn't have a consistent unique name. This will break history | 10069 // entries didn't have a consistent unique name. This will break history |
9998 // navigations =( | 10070 // navigations =( |
9999 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | 10071 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; |
10000 } | 10072 } |
10001 | 10073 |
10002 } // namespace content | 10074 } // namespace content |
OLD | NEW |