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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 &success)); | 128 &success)); |
129 EXPECT_TRUE(success); | 129 EXPECT_TRUE(success); |
130 } | 130 } |
131 | 131 |
132 // Helper function to generate a click on the given RenderWidgetHost. The | 132 // Helper function to generate a click on the given RenderWidgetHost. The |
133 // mouse event is forwarded directly to the RenderWidgetHost without any | 133 // mouse event is forwarded directly to the RenderWidgetHost without any |
134 // hit-testing. | 134 // hit-testing. |
135 void SimulateMouseClick(RenderWidgetHost* rwh, int x, int y) { | 135 void SimulateMouseClick(RenderWidgetHost* rwh, int x, int y) { |
136 blink::WebMouseEvent mouse_event; | 136 blink::WebMouseEvent mouse_event; |
137 mouse_event.type = blink::WebInputEvent::MouseDown; | 137 mouse_event.type = blink::WebInputEvent::MouseDown; |
138 mouse_event.button = blink::WebPointerProperties::ButtonLeft; | 138 mouse_event.button = blink::WebPointerProperties::Button::Left; |
139 mouse_event.x = x; | 139 mouse_event.x = x; |
140 mouse_event.y = y; | 140 mouse_event.y = y; |
141 rwh->ForwardMouseEvent(mouse_event); | 141 rwh->ForwardMouseEvent(mouse_event); |
142 } | 142 } |
143 | 143 |
144 // Retrieve document.origin for the frame |ftn|. | 144 // Retrieve document.origin for the frame |ftn|. |
145 std::string GetDocumentOrigin(FrameTreeNode* ftn) { | 145 std::string GetDocumentOrigin(FrameTreeNode* ftn) { |
146 std::string origin; | 146 std::string origin; |
147 EXPECT_TRUE(ExecuteScriptAndExtractString( | 147 EXPECT_TRUE(ExecuteScriptAndExtractString( |
148 ftn, "domAutomationController.send(document.origin)", &origin)); | 148 ftn, "domAutomationController.send(document.origin)", &origin)); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( | 243 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
244 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | 244 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
245 | 245 |
246 SurfaceHitTestReadyNotifier notifier( | 246 SurfaceHitTestReadyNotifier notifier( |
247 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); | 247 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
248 notifier.WaitForSurfaceReady(); | 248 notifier.WaitForSurfaceReady(); |
249 | 249 |
250 // Target input event to child frame. | 250 // Target input event to child frame. |
251 blink::WebMouseEvent child_event; | 251 blink::WebMouseEvent child_event; |
252 child_event.type = blink::WebInputEvent::MouseDown; | 252 child_event.type = blink::WebInputEvent::MouseDown; |
253 child_event.button = blink::WebPointerProperties::ButtonLeft; | 253 child_event.button = blink::WebPointerProperties::Button::Left; |
254 child_event.x = 75; | 254 child_event.x = 75; |
255 child_event.y = 75; | 255 child_event.y = 75; |
256 child_event.clickCount = 1; | 256 child_event.clickCount = 1; |
257 main_frame_monitor.ResetEventReceived(); | 257 main_frame_monitor.ResetEventReceived(); |
258 child_frame_monitor.ResetEventReceived(); | 258 child_frame_monitor.ResetEventReceived(); |
259 router->RouteMouseEvent(root_view, &child_event); | 259 router->RouteMouseEvent(root_view, &child_event); |
260 | 260 |
261 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 261 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
262 EXPECT_EQ(23, child_frame_monitor.event().x); | 262 EXPECT_EQ(23, child_frame_monitor.event().x); |
263 EXPECT_EQ(23, child_frame_monitor.event().y); | 263 EXPECT_EQ(23, child_frame_monitor.event().y); |
264 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 264 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
265 | 265 |
266 child_frame_monitor.ResetEventReceived(); | 266 child_frame_monitor.ResetEventReceived(); |
267 main_frame_monitor.ResetEventReceived(); | 267 main_frame_monitor.ResetEventReceived(); |
268 | 268 |
269 // Target input event to main frame. | 269 // Target input event to main frame. |
270 blink::WebMouseEvent main_event; | 270 blink::WebMouseEvent main_event; |
271 main_event.type = blink::WebInputEvent::MouseDown; | 271 main_event.type = blink::WebInputEvent::MouseDown; |
272 main_event.button = blink::WebPointerProperties::ButtonLeft; | 272 main_event.button = blink::WebPointerProperties::Button::Left; |
273 main_event.x = 1; | 273 main_event.x = 1; |
274 main_event.y = 1; | 274 main_event.y = 1; |
275 main_event.clickCount = 1; | 275 main_event.clickCount = 1; |
276 // Ladies and gentlemen, THIS is the main_event! | 276 // Ladies and gentlemen, THIS is the main_event! |
277 router->RouteMouseEvent(root_view, &main_event); | 277 router->RouteMouseEvent(root_view, &main_event); |
278 | 278 |
279 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); | 279 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); |
280 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); | 280 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
281 EXPECT_EQ(1, main_frame_monitor.event().x); | 281 EXPECT_EQ(1, main_frame_monitor.event().x); |
282 EXPECT_EQ(1, main_frame_monitor.event().y); | 282 EXPECT_EQ(1, main_frame_monitor.event().y); |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 ->GetRenderWidgetHost() | 1240 ->GetRenderWidgetHost() |
1241 ->GetView()); | 1241 ->GetView()); |
1242 | 1242 |
1243 SurfaceHitTestReadyNotifier notifier( | 1243 SurfaceHitTestReadyNotifier notifier( |
1244 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); | 1244 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); |
1245 notifier.WaitForSurfaceReady(); | 1245 notifier.WaitForSurfaceReady(); |
1246 | 1246 |
1247 // Target input event to nested frame. | 1247 // Target input event to nested frame. |
1248 blink::WebMouseEvent nested_event; | 1248 blink::WebMouseEvent nested_event; |
1249 nested_event.type = blink::WebInputEvent::MouseDown; | 1249 nested_event.type = blink::WebInputEvent::MouseDown; |
1250 nested_event.button = blink::WebPointerProperties::ButtonLeft; | 1250 nested_event.button = blink::WebPointerProperties::Button::Left; |
1251 nested_event.x = 125; | 1251 nested_event.x = 125; |
1252 nested_event.y = 125; | 1252 nested_event.y = 125; |
1253 nested_event.clickCount = 1; | 1253 nested_event.clickCount = 1; |
1254 nested_frame_monitor.ResetEventReceived(); | 1254 nested_frame_monitor.ResetEventReceived(); |
1255 main_frame_monitor.ResetEventReceived(); | 1255 main_frame_monitor.ResetEventReceived(); |
1256 router->RouteMouseEvent(root_view, &nested_event); | 1256 router->RouteMouseEvent(root_view, &nested_event); |
1257 | 1257 |
1258 EXPECT_TRUE(nested_frame_monitor.EventWasReceived()); | 1258 EXPECT_TRUE(nested_frame_monitor.EventWasReceived()); |
1259 EXPECT_EQ(21, nested_frame_monitor.event().x); | 1259 EXPECT_EQ(21, nested_frame_monitor.event().x); |
1260 EXPECT_EQ(21, nested_frame_monitor.event().y); | 1260 EXPECT_EQ(21, nested_frame_monitor.event().y); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( | 1305 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
1306 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | 1306 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
1307 | 1307 |
1308 SurfaceHitTestReadyNotifier notifier( | 1308 SurfaceHitTestReadyNotifier notifier( |
1309 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); | 1309 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
1310 notifier.WaitForSurfaceReady(); | 1310 notifier.WaitForSurfaceReady(); |
1311 | 1311 |
1312 // Target input event to child frame. | 1312 // Target input event to child frame. |
1313 blink::WebMouseEvent child_event; | 1313 blink::WebMouseEvent child_event; |
1314 child_event.type = blink::WebInputEvent::MouseDown; | 1314 child_event.type = blink::WebInputEvent::MouseDown; |
1315 child_event.button = blink::WebPointerProperties::ButtonLeft; | 1315 child_event.button = blink::WebPointerProperties::Button::Left; |
1316 child_event.x = 75; | 1316 child_event.x = 75; |
1317 child_event.y = 75; | 1317 child_event.y = 75; |
1318 child_event.clickCount = 1; | 1318 child_event.clickCount = 1; |
1319 main_frame_monitor.ResetEventReceived(); | 1319 main_frame_monitor.ResetEventReceived(); |
1320 child_frame_monitor.ResetEventReceived(); | 1320 child_frame_monitor.ResetEventReceived(); |
1321 router->RouteMouseEvent(root_view, &child_event); | 1321 router->RouteMouseEvent(root_view, &child_event); |
1322 | 1322 |
1323 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); | 1323 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
1324 EXPECT_EQ(75, main_frame_monitor.event().x); | 1324 EXPECT_EQ(75, main_frame_monitor.event().x); |
1325 EXPECT_EQ(75, main_frame_monitor.event().y); | 1325 EXPECT_EQ(75, main_frame_monitor.event().y); |
(...skipping 4077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5403 | 5403 |
5404 RenderWidgetHostInputEventRouter* router = | 5404 RenderWidgetHostInputEventRouter* router = |
5405 static_cast<WebContentsImpl*>(shell->web_contents()) | 5405 static_cast<WebContentsImpl*>(shell->web_contents()) |
5406 ->GetInputEventRouter(); | 5406 ->GetInputEventRouter(); |
5407 | 5407 |
5408 gfx::Point point(75, 75); | 5408 gfx::Point point(75, 75); |
5409 | 5409 |
5410 // Target right-click event to child frame. | 5410 // Target right-click event to child frame. |
5411 blink::WebMouseEvent click_event; | 5411 blink::WebMouseEvent click_event; |
5412 click_event.type = blink::WebInputEvent::MouseDown; | 5412 click_event.type = blink::WebInputEvent::MouseDown; |
5413 click_event.button = blink::WebPointerProperties::ButtonRight; | 5413 click_event.button = blink::WebPointerProperties::Button::Right; |
5414 click_event.x = point.x(); | 5414 click_event.x = point.x(); |
5415 click_event.y = point.y(); | 5415 click_event.y = point.y(); |
5416 click_event.clickCount = 1; | 5416 click_event.clickCount = 1; |
5417 router->RouteMouseEvent(root_view, &click_event); | 5417 router->RouteMouseEvent(root_view, &click_event); |
5418 | 5418 |
5419 // We also need a MouseUp event, needed by Windows. | 5419 // We also need a MouseUp event, needed by Windows. |
5420 click_event.type = blink::WebInputEvent::MouseUp; | 5420 click_event.type = blink::WebInputEvent::MouseUp; |
5421 click_event.x = point.x(); | 5421 click_event.x = point.x(); |
5422 click_event.y = point.y(); | 5422 click_event.y = point.y(); |
5423 router->RouteMouseEvent(root_view, &click_event); | 5423 router->RouteMouseEvent(root_view, &click_event); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5558 | 5558 |
5559 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 5559 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
5560 child_node->current_frame_host()->GetSiteInstance()); | 5560 child_node->current_frame_host()->GetSiteInstance()); |
5561 | 5561 |
5562 scoped_refptr<ShowWidgetMessageFilter> filter = new ShowWidgetMessageFilter(); | 5562 scoped_refptr<ShowWidgetMessageFilter> filter = new ShowWidgetMessageFilter(); |
5563 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); | 5563 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); |
5564 | 5564 |
5565 // Target left-click event to child frame. | 5565 // Target left-click event to child frame. |
5566 blink::WebMouseEvent click_event; | 5566 blink::WebMouseEvent click_event; |
5567 click_event.type = blink::WebInputEvent::MouseDown; | 5567 click_event.type = blink::WebInputEvent::MouseDown; |
5568 click_event.button = blink::WebPointerProperties::ButtonLeft; | 5568 click_event.button = blink::WebPointerProperties::Button::Left; |
5569 click_event.x = 15; | 5569 click_event.x = 15; |
5570 click_event.y = 15; | 5570 click_event.y = 15; |
5571 click_event.clickCount = 1; | 5571 click_event.clickCount = 1; |
5572 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 5572 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
5573 | 5573 |
5574 // Dismiss the popup. | 5574 // Dismiss the popup. |
5575 click_event.x = 1; | 5575 click_event.x = 1; |
5576 click_event.y = 1; | 5576 click_event.y = 1; |
5577 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 5577 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
5578 | 5578 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5633 | 5633 |
5634 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 5634 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
5635 c_node->current_frame_host()->GetSiteInstance()); | 5635 c_node->current_frame_host()->GetSiteInstance()); |
5636 | 5636 |
5637 scoped_refptr<ShowWidgetMessageFilter> filter = new ShowWidgetMessageFilter(); | 5637 scoped_refptr<ShowWidgetMessageFilter> filter = new ShowWidgetMessageFilter(); |
5638 c_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); | 5638 c_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); |
5639 | 5639 |
5640 // Target left-click event to child frame. | 5640 // Target left-click event to child frame. |
5641 blink::WebMouseEvent click_event; | 5641 blink::WebMouseEvent click_event; |
5642 click_event.type = blink::WebInputEvent::MouseDown; | 5642 click_event.type = blink::WebInputEvent::MouseDown; |
5643 click_event.button = blink::WebPointerProperties::ButtonLeft; | 5643 click_event.button = blink::WebPointerProperties::Button::Left; |
5644 click_event.x = 15; | 5644 click_event.x = 15; |
5645 click_event.y = 15; | 5645 click_event.y = 15; |
5646 click_event.clickCount = 1; | 5646 click_event.clickCount = 1; |
5647 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 5647 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
5648 | 5648 |
5649 // Prompt the WebContents to dismiss the popup by clicking elsewhere. | 5649 // Prompt the WebContents to dismiss the popup by clicking elsewhere. |
5650 click_event.x = 1; | 5650 click_event.x = 1; |
5651 click_event.y = 1; | 5651 click_event.y = 1; |
5652 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 5652 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
5653 | 5653 |
(...skipping 29 matching lines...) Expand all Loading... |
5683 while (last_b_node_bounds_rect.x() == | 5683 while (last_b_node_bounds_rect.x() == |
5684 b_node->current_frame_host()->GetView()->GetViewBounds().x() && | 5684 b_node->current_frame_host()->GetView()->GetViewBounds().x() && |
5685 last_b_node_bounds_rect.y() == | 5685 last_b_node_bounds_rect.y() == |
5686 b_node->current_frame_host()->GetView()->GetViewBounds().y()) { | 5686 b_node->current_frame_host()->GetView()->GetViewBounds().y()) { |
5687 base::RunLoop run_loop; | 5687 base::RunLoop run_loop; |
5688 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 5688 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
5689 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); | 5689 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); |
5690 run_loop.Run(); | 5690 run_loop.Run(); |
5691 } | 5691 } |
5692 | 5692 |
5693 click_event.button = blink::WebPointerProperties::ButtonLeft; | 5693 click_event.button = blink::WebPointerProperties::Button::Left; |
5694 click_event.x = 15; | 5694 click_event.x = 15; |
5695 click_event.y = 15; | 5695 click_event.y = 15; |
5696 click_event.clickCount = 1; | 5696 click_event.clickCount = 1; |
5697 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 5697 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
5698 | 5698 |
5699 click_event.x = 1; | 5699 click_event.x = 1; |
5700 click_event.y = 1; | 5700 click_event.y = 1; |
5701 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 5701 rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
5702 | 5702 |
5703 filter->Wait(); | 5703 filter->Wait(); |
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7916 // Now go forward three entries from the child1 frame and check that the | 7916 // Now go forward three entries from the child1 frame and check that the |
7917 // history length and offset are not stale in b.com. | 7917 // history length and offset are not stale in b.com. |
7918 EXPECT_TRUE(ExecuteScript(child1, "history.go(3);")); | 7918 EXPECT_TRUE(ExecuteScript(child1, "history.go(3);")); |
7919 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 7919 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
7920 EXPECT_EQ(main_url, root->current_url()); | 7920 EXPECT_EQ(main_url, root->current_url()); |
7921 EXPECT_EQ(child1_last_url, child1->current_url()); | 7921 EXPECT_EQ(child1_last_url, child1->current_url()); |
7922 EXPECT_EQ(child2_last_url, child2->current_url()); | 7922 EXPECT_EQ(child2_last_url, child2->current_url()); |
7923 } | 7923 } |
7924 | 7924 |
7925 } // namespace content | 7925 } // namespace content |
OLD | NEW |