Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / pointer-lock / mouse-event-delivery.html
blobf08b80586f4469e373a5c52a02c4986a16d1893e
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
6 </head>
7 <body id="body">
8 <div>
9 <div id="target1"></div>
10 <div id="target2"></div>
11 </div>
12 <script>
13 description("Test mouse events are routed to lock target.")
14 window.jsTestIsAsync = true;
16 targetdiv1 = document.getElementById("target1");
17 targetdiv2 = document.getElementById("target2");
19 // Expect change event only for all transitions below.
20 expectedTargetToBeLockedString = "";
21 document.onpointerlockchange = function ()
23 testPassed("document.onpointerlockchange event received.");
24 shouldBe("document.pointerLockElement", expectedTargetToBeLockedString);
25 doNextStep();
27 document.onpointerlockerror =
28 function () { testFailed("document.onpointerlockerror event received."); finishJSTest(); };
30 function eventNotExpected(e) {
31 testFailed("Unexpected event " + e.type + " on " + e.currentTarget.id);
32 finishJSTest();
34 function eventExpected(e) {
35 testPassed("event type: " + e.type + ", target: " + e.target.id + ", received on: " + e.currentTarget.id);
38 todo = [
39 function () {
40 targetdiv1.requestPointerLock();
41 expectedTargetToBeLockedString = "targetdiv1";
42 // doNextStep() called by onpointerlockchange handler.
44 function () {
45 debug(" With a lock in place send a click.")
46 targetdiv1.onmousedown = eventExpected;
47 targetdiv2.onmousedown = eventNotExpected;
48 document.body.onmousedown = eventExpected;
49 if (window.eventSender) {
50 window.eventSender.leapForward(1000);
51 window.eventSender.mouseDown();
52 window.eventSender.mouseUp();
54 doNextStepWithUserGesture();
56 function () {
57 targetdiv2.requestPointerLock();
58 expectedTargetToBeLockedString = "targetdiv2";
59 // doNextStep() called by onpointerlockchange handler.
61 function () {
62 debug(" With a lock in place send a click.")
63 targetdiv1.onmousedown = eventNotExpected;
64 targetdiv2.onmousedown = eventExpected;
65 document.body.onmousedown = eventExpected;
66 if (window.eventSender) {
67 window.eventSender.leapForward(1000);
68 window.eventSender.mouseDown();
69 window.eventSender.mouseUp();
71 doNextStepWithUserGesture();
73 function () {
74 debug(" Ensure double clicks work as expected, sending 4 clicks.")
75 targetdiv1.onmousedown = undefined;
76 document.body.onmousedown = undefined;
77 targetdiv2.onmousedown = eventExpected;
78 targetdiv2.onmouseup = eventExpected;
79 targetdiv2.onclick = eventExpected;
80 targetdiv2.ondblclick = eventExpected;
81 debug(" Creating a click and dblclick.");
82 if (window.eventSender) {
83 window.eventSender.leapForward(1000);
84 window.eventSender.mouseDown();
85 window.eventSender.mouseUp();
86 window.eventSender.mouseDown();
87 window.eventSender.mouseUp();
89 debug(" Ensuring no false dblclicks if we continue.");
90 if (window.eventSender) {
91 window.eventSender.mouseDown();
92 window.eventSender.mouseUp();
93 window.eventSender.mouseDown();
94 window.eventSender.mouseUp();
96 doNextStepWithUserGesture();
99 doNextStepWithUserGesture();
100 </script>
101 </body>
102 </html>