Layout Test fast/dom/HTMLTemplateElement/ownerDocument-adoptNode.html is flaky
[WebKit-https.git] / LayoutTests / pointer-lock / mouse-event-delivery.html
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../http/tests/resources/js-test-pre.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;
15
16     targetdiv1 = document.getElementById("target1");
17     targetdiv2 = document.getElementById("target2");
18
19     // Expect change event only for all transitions below.
20     expectedTargetToBeLockedString = "";
21     document.onwebkitpointerlockchange = function ()
22         {
23             testPassed("document.onwebkitpointerlockchange event received.");
24             shouldBe("document.webkitPointerLockElement", expectedTargetToBeLockedString);
25             doNextStep();
26         };
27     document.onwebkitpointerlockerror =
28         function () { testFailed("document.onwebkitpointerlockerror event received."); finishJSTest(); };
29
30     function eventNotExpected(e) {
31         testFailed("Unexpected event " + e.type + " on " + e.currentTarget.id);
32         finishJSTest();
33     }
34     function eventExpected(e) {
35       testPassed("event type: " + e.type + ", target: " + e.target.id + ", received on: " + e.currentTarget.id);
36     }
37
38     todo = [
39         function () {
40             targetdiv1.webkitRequestPointerLock();
41             expectedTargetToBeLockedString = "targetdiv1";
42             // doNextStep() called by onwebkitpointerlockchange handler.
43         },
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();
53             }
54             doNextStepWithUserGesture();
55         },
56         function () {
57             targetdiv2.webkitRequestPointerLock();
58             expectedTargetToBeLockedString = "targetdiv2";
59             // doNextStep() called by onwebkitpointerlockchange handler.
60         },
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();
70             }
71             doNextStepWithUserGesture();
72         },
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();
88             }
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();
95             }
96             doNextStepWithUserGesture();
97         },
98     ];
99     doNextStepWithUserGesture();
100 </script>
101 <script src="../http/tests/resources/js-test-post.js"></script>
102 </body>
103 </html>