Chromium Code Reviews| 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 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
|
kenrb
2017/04/27 20:47:23
This test should have a description.
| |
| 1125 GestureFlingStartEventsBubble) { | |
| 1126 GURL main_url(embedded_test_server()->GetURL( | |
| 1127 "a.com", "/cross_site_iframe_factory.html?a(b)")); | |
| 1128 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 1129 | |
| 1130 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 1131 ->GetFrameTree() | |
| 1132 ->root(); | |
| 1133 ASSERT_EQ(1U, root->child_count()); | |
| 1134 | |
| 1135 FrameTreeNode* child_iframe_node = root->child_at(0); | |
| 1136 | |
| 1137 std::unique_ptr<InputEventAckWaiter> gesture_fling_start_ack_observer = | |
| 1138 base::MakeUnique<InputEventAckWaiter>( | |
| 1139 blink::WebInputEvent::kGestureFlingStart); | |
| 1140 root->current_frame_host()->GetRenderWidgetHost()->AddInputEventObserver( | |
| 1141 gesture_fling_start_ack_observer.get()); | |
| 1142 | |
| 1143 RenderWidgetHost* child_rwh = | |
| 1144 child_iframe_node->current_frame_host()->GetRenderWidgetHost(); | |
| 1145 | |
| 1146 WaitForChildFrameSurfaceReady(child_iframe_node->current_frame_host()); | |
| 1147 | |
| 1148 gesture_fling_start_ack_observer->Reset(); | |
| 1149 // Send a GSB, GSU, GFS sequence and verify that the GFS bubbles. | |
| 1150 blink::WebGestureEvent gesture_scroll_begin( | |
| 1151 blink::WebGestureEvent::kGestureScrollBegin, | |
| 1152 blink::WebInputEvent::kNoModifiers, | |
| 1153 blink::WebInputEvent::kTimeStampForTesting); | |
| 1154 gesture_scroll_begin.source_device = blink::kWebGestureDeviceTouchscreen; | |
| 1155 gesture_scroll_begin.data.scroll_begin.delta_hint_units = | |
| 1156 blink::WebGestureEvent::ScrollUnits::kPrecisePixels; | |
| 1157 gesture_scroll_begin.data.scroll_begin.delta_x_hint = 0.f; | |
| 1158 gesture_scroll_begin.data.scroll_begin.delta_y_hint = 5.f; | |
| 1159 | |
| 1160 child_rwh->ForwardGestureEvent(gesture_scroll_begin); | |
| 1161 | |
| 1162 blink::WebGestureEvent gesture_scroll_update( | |
| 1163 blink::WebGestureEvent::kGestureScrollUpdate, | |
| 1164 blink::WebInputEvent::kNoModifiers, | |
| 1165 blink::WebInputEvent::kTimeStampForTesting); | |
| 1166 gesture_scroll_update.source_device = blink::kWebGestureDeviceTouchscreen; | |
| 1167 gesture_scroll_update.data.scroll_update.delta_units = | |
| 1168 blink::WebGestureEvent::ScrollUnits::kPrecisePixels; | |
| 1169 gesture_scroll_update.data.scroll_update.delta_x = 0.f; | |
| 1170 gesture_scroll_update.data.scroll_update.delta_y = 5.f; | |
| 1171 gesture_scroll_update.data.scroll_update.velocity_y = 5.f; | |
| 1172 | |
| 1173 child_rwh->ForwardGestureEvent(gesture_scroll_update); | |
| 1174 | |
| 1175 blink::WebGestureEvent gesture_fling_start( | |
| 1176 blink::WebGestureEvent::kGestureFlingStart, | |
| 1177 blink::WebInputEvent::kNoModifiers, | |
| 1178 blink::WebInputEvent::kTimeStampForTesting); | |
| 1179 gesture_fling_start.source_device = blink::kWebGestureDeviceTouchscreen; | |
| 1180 gesture_fling_start.data.fling_start.velocity_x = 0.f; | |
| 1181 gesture_fling_start.data.fling_start.velocity_y = 5.f; | |
| 1182 | |
| 1183 child_rwh->ForwardGestureEvent(gesture_fling_start); | |
| 1184 | |
| 1185 gesture_fling_start_ack_observer->Wait(); | |
|
kenrb
2017/04/27 20:47:23
Since there are no EXPECT statements in the later
| |
| 1186 } | |
| 1187 | |
| 1122 // Test that scrolling a nested out-of-process iframe bubbles unused scroll | 1188 // Test that scrolling a nested out-of-process iframe bubbles unused scroll |
| 1123 // delta to a parent frame. | 1189 // delta to a parent frame. |
| 1124 #if defined(OS_ANDROID) | 1190 #if defined(OS_ANDROID) |
| 1125 #define MAYBE_ScrollBubblingFromOOPIFTest DISABLED_ScrollBubblingFromOOPIFTest | 1191 #define MAYBE_ScrollBubblingFromOOPIFTest DISABLED_ScrollBubblingFromOOPIFTest |
| 1126 #else | 1192 #else |
| 1127 #define MAYBE_ScrollBubblingFromOOPIFTest ScrollBubblingFromOOPIFTest | 1193 #define MAYBE_ScrollBubblingFromOOPIFTest ScrollBubblingFromOOPIFTest |
| 1128 #endif | 1194 #endif |
| 1129 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1195 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 1130 MAYBE_ScrollBubblingFromOOPIFTest) { | 1196 MAYBE_ScrollBubblingFromOOPIFTest) { |
| 1131 GURL main_url(embedded_test_server()->GetURL( | 1197 GURL main_url(embedded_test_server()->GetURL( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1142 | 1208 |
| 1143 // This test uses the position of the nested iframe within the parent iframe | 1209 // This test uses the position of the nested iframe within the parent iframe |
| 1144 // to infer the scroll position of the parent. FrameRectChangedMessageFilter | 1210 // to infer the scroll position of the parent. FrameRectChangedMessageFilter |
| 1145 // catches updates to the position in order to avoid busy waiting. | 1211 // catches updates to the position in order to avoid busy waiting. |
| 1146 // It gets created early to catch the initial rects from the navigation. | 1212 // It gets created early to catch the initial rects from the navigation. |
| 1147 scoped_refptr<FrameRectChangedMessageFilter> filter = | 1213 scoped_refptr<FrameRectChangedMessageFilter> filter = |
| 1148 new FrameRectChangedMessageFilter(); | 1214 new FrameRectChangedMessageFilter(); |
| 1149 parent_iframe_node->current_frame_host()->GetProcess()->AddFilter( | 1215 parent_iframe_node->current_frame_host()->GetProcess()->AddFilter( |
| 1150 filter.get()); | 1216 filter.get()); |
| 1151 | 1217 |
| 1152 std::unique_ptr<GestureScrollEndObserver> ack_observer = | 1218 std::unique_ptr<InputEventAckWaiter> ack_observer = |
| 1153 base::MakeUnique<GestureScrollEndObserver>(); | 1219 base::MakeUnique<InputEventAckWaiter>( |
| 1220 blink::WebInputEvent::kGestureScrollEnd); | |
| 1154 parent_iframe_node->current_frame_host() | 1221 parent_iframe_node->current_frame_host() |
| 1155 ->GetRenderWidgetHost() | 1222 ->GetRenderWidgetHost() |
| 1156 ->AddInputEventObserver(ack_observer.get()); | 1223 ->AddInputEventObserver(ack_observer.get()); |
| 1157 | 1224 |
| 1158 GURL site_url(embedded_test_server()->GetURL( | 1225 GURL site_url(embedded_test_server()->GetURL( |
| 1159 "b.com", "/frame_tree/page_with_positioned_frame.html")); | 1226 "b.com", "/frame_tree/page_with_positioned_frame.html")); |
| 1160 NavigateFrameToURL(parent_iframe_node, site_url); | 1227 NavigateFrameToURL(parent_iframe_node, site_url); |
| 1161 | 1228 |
| 1162 // Navigate the nested frame to a page large enough to have scrollbars. | 1229 // Navigate the nested frame to a page large enough to have scrollbars. |
| 1163 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0); | 1230 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()); | 10060 names.insert(root->children[0]->frame_entry->frame_unique_name()); |
| 9994 } | 10061 } |
| 9995 | 10062 |
| 9996 // More than one entry in the set means that the subframe frame navigation | 10063 // 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 | 10064 // entries didn't have a consistent unique name. This will break history |
| 9998 // navigations =( | 10065 // navigations =( |
| 9999 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | 10066 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; |
| 10000 } | 10067 } |
| 10001 | 10068 |
| 10002 } // namespace content | 10069 } // namespace content |
| OLD | NEW |