OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/pointer_lock_browsertest.h" | 5 #include "content/browser/pointer_lock_browsertest.h" |
6 | 6 |
7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/browser/renderer_host/render_widget_host_impl.h" | 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
9 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 9 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 // Add a mouse move event listener to the root frame. | 192 // Add a mouse move event listener to the root frame. |
193 EXPECT_TRUE(ExecuteScript( | 193 EXPECT_TRUE(ExecuteScript( |
194 root, | 194 root, |
195 "var x; var y; var mX; var mY; document.addEventListener('mousemove', " | 195 "var x; var y; var mX; var mY; document.addEventListener('mousemove', " |
196 "function(e) {x = e.x; y = e.y; mX = e.movementX; mY = e.movementY;});")); | 196 "function(e) {x = e.x; y = e.y; mX = e.movementX; mY = e.movementY;});")); |
197 | 197 |
198 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove, | 198 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove, |
199 blink::WebInputEvent::NoModifiers, | 199 blink::WebInputEvent::NoModifiers, |
200 blink::WebInputEvent::TimeStampForTesting); | 200 blink::WebInputEvent::TimeStampForTesting); |
201 mouse_event.x = 10; | 201 mouse_event.setPositionInWidget(10, 11); |
202 mouse_event.y = 11; | |
203 mouse_event.movementX = 12; | 202 mouse_event.movementX = 12; |
204 mouse_event.movementY = 13; | 203 mouse_event.movementY = 13; |
205 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); | 204 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); |
206 | 205 |
207 // Make sure that the renderer handled the input event. | 206 // Make sure that the renderer handled the input event. |
208 MainThreadFrameObserver root_observer(root_view->GetRenderWidgetHost()); | 207 MainThreadFrameObserver root_observer(root_view->GetRenderWidgetHost()); |
209 root_observer.Wait(); | 208 root_observer.Wait(); |
210 | 209 |
211 int x, y, movementX, movementY; | 210 int x, y, movementX, movementY; |
212 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 211 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
(...skipping 26 matching lines...) Expand all Loading... |
239 // Add a mouse move event listener to the child frame. | 238 // Add a mouse move event listener to the child frame. |
240 EXPECT_TRUE(ExecuteScript( | 239 EXPECT_TRUE(ExecuteScript( |
241 child, | 240 child, |
242 "var x; var y; var mX; var mY; document.addEventListener('mousemove', " | 241 "var x; var y; var mX; var mY; document.addEventListener('mousemove', " |
243 "function(e) {x = e.x; y = e.y; mX = e.movementX; mY = e.movementY;});")); | 242 "function(e) {x = e.x; y = e.y; mX = e.movementX; mY = e.movementY;});")); |
244 | 243 |
245 gfx::Point transformed_point; | 244 gfx::Point transformed_point; |
246 root_view->TransformPointToCoordSpaceForView(gfx::Point(0, 0), child_view, | 245 root_view->TransformPointToCoordSpaceForView(gfx::Point(0, 0), child_view, |
247 &transformed_point); | 246 &transformed_point); |
248 | 247 |
249 mouse_event.x = -transformed_point.x() + 14; | 248 mouse_event.setPositionInWidget(-transformed_point.x() + 14, |
250 mouse_event.y = -transformed_point.y() + 15; | 249 -transformed_point.y() + 15); |
251 mouse_event.movementX = 16; | 250 mouse_event.movementX = 16; |
252 mouse_event.movementY = 17; | 251 mouse_event.movementY = 17; |
253 // We use root_view intentionally as the RenderWidgetHostInputEventRouter is | 252 // We use root_view intentionally as the RenderWidgetHostInputEventRouter is |
254 // responsible for correctly routing the event to the child frame. | 253 // responsible for correctly routing the event to the child frame. |
255 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); | 254 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); |
256 | 255 |
257 // Make sure that the renderer handled the input event. | 256 // Make sure that the renderer handled the input event. |
258 MainThreadFrameObserver child_observer(child_view->GetRenderWidgetHost()); | 257 MainThreadFrameObserver child_observer(child_view->GetRenderWidgetHost()); |
259 child_observer.Wait(); | 258 child_observer.Wait(); |
260 | 259 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 EXPECT_TRUE(ExecuteScript( | 336 EXPECT_TRUE(ExecuteScript( |
338 root, | 337 root, |
339 "var x; var y; var mX; var mY; document.addEventListener('mousewheel', " | 338 "var x; var y; var mX; var mY; document.addEventListener('mousewheel', " |
340 "function(e) {x = e.x; y = e.y; dX = e.deltaX; dY = e.deltaY;});")); | 339 "function(e) {x = e.x; y = e.y; dX = e.deltaX; dY = e.deltaY;});")); |
341 MainThreadFrameObserver root_observer(root_view->GetRenderWidgetHost()); | 340 MainThreadFrameObserver root_observer(root_view->GetRenderWidgetHost()); |
342 root_observer.Wait(); | 341 root_observer.Wait(); |
343 | 342 |
344 blink::WebMouseWheelEvent wheel_event( | 343 blink::WebMouseWheelEvent wheel_event( |
345 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, | 344 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, |
346 blink::WebInputEvent::TimeStampForTesting); | 345 blink::WebInputEvent::TimeStampForTesting); |
347 wheel_event.x = 10; | 346 wheel_event.setPositionInWidget(10, 11); |
348 wheel_event.y = 11; | |
349 wheel_event.deltaX = -12; | 347 wheel_event.deltaX = -12; |
350 wheel_event.deltaY = -13; | 348 wheel_event.deltaY = -13; |
351 router->RouteMouseWheelEvent(root_view, &wheel_event, ui::LatencyInfo()); | 349 router->RouteMouseWheelEvent(root_view, &wheel_event, ui::LatencyInfo()); |
352 | 350 |
353 // Make sure that the renderer handled the input event. | 351 // Make sure that the renderer handled the input event. |
354 root_observer.Wait(); | 352 root_observer.Wait(); |
355 | 353 |
356 int x, y, deltaX, deltaY; | 354 int x, y, deltaX, deltaY; |
357 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 355 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
358 root, "window.domAutomationController.send(x);", &x)); | 356 root, "window.domAutomationController.send(x);", &x)); |
(...skipping 27 matching lines...) Expand all Loading... |
386 child, | 384 child, |
387 "var x; var y; var mX; var mY; document.addEventListener('mousewheel', " | 385 "var x; var y; var mX; var mY; document.addEventListener('mousewheel', " |
388 "function(e) {x = e.x; y = e.y; dX = e.deltaX; dY = e.deltaY;});")); | 386 "function(e) {x = e.x; y = e.y; dX = e.deltaX; dY = e.deltaY;});")); |
389 MainThreadFrameObserver child_observer(child_view->GetRenderWidgetHost()); | 387 MainThreadFrameObserver child_observer(child_view->GetRenderWidgetHost()); |
390 child_observer.Wait(); | 388 child_observer.Wait(); |
391 | 389 |
392 gfx::Point transformed_point; | 390 gfx::Point transformed_point; |
393 root_view->TransformPointToCoordSpaceForView(gfx::Point(0, 0), child_view, | 391 root_view->TransformPointToCoordSpaceForView(gfx::Point(0, 0), child_view, |
394 &transformed_point); | 392 &transformed_point); |
395 | 393 |
396 wheel_event.x = -transformed_point.x() + 14; | 394 wheel_event.setPositionInWidget(-transformed_point.x() + 14, |
397 wheel_event.y = -transformed_point.y() + 15; | 395 -transformed_point.y() + 15); |
398 wheel_event.deltaX = -16; | 396 wheel_event.deltaX = -16; |
399 wheel_event.deltaY = -17; | 397 wheel_event.deltaY = -17; |
400 // We use root_view intentionally as the RenderWidgetHostInputEventRouter is | 398 // We use root_view intentionally as the RenderWidgetHostInputEventRouter is |
401 // responsible for correctly routing the event to the child frame. | 399 // responsible for correctly routing the event to the child frame. |
402 router->RouteMouseWheelEvent(root_view, &wheel_event, ui::LatencyInfo()); | 400 router->RouteMouseWheelEvent(root_view, &wheel_event, ui::LatencyInfo()); |
403 | 401 |
404 // Make sure that the renderer handled the input event. | 402 // Make sure that the renderer handled the input event. |
405 child_observer.Wait(); | 403 child_observer.Wait(); |
406 | 404 |
407 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 405 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
408 child, "window.domAutomationController.send(x);", &x)); | 406 child, "window.domAutomationController.send(x);", &x)); |
409 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 407 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
410 child, "window.domAutomationController.send(y);", &y)); | 408 child, "window.domAutomationController.send(y);", &y)); |
411 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 409 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
412 child, "window.domAutomationController.send(dX);", &deltaX)); | 410 child, "window.domAutomationController.send(dX);", &deltaX)); |
413 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 411 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
414 child, "window.domAutomationController.send(dY);", &deltaY)); | 412 child, "window.domAutomationController.send(dY);", &deltaY)); |
415 EXPECT_EQ(14, x); | 413 EXPECT_EQ(14, x); |
416 EXPECT_EQ(15, y); | 414 EXPECT_EQ(15, y); |
417 EXPECT_EQ(16, deltaX); | 415 EXPECT_EQ(16, deltaX); |
418 EXPECT_EQ(17, deltaY); | 416 EXPECT_EQ(17, deltaY); |
419 } | 417 } |
420 | 418 |
421 } // namespace content | 419 } // namespace content |
OLD | NEW |