Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / pointer-lock / pointerlockchange-pointerlockerror-events.html
blobc571b9b7ea066baf529578fc80ee44335a08d792
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>
8 <div>
9 <div id="target1"></div>
10 <div id="target2"></div>
11 <iframe id="iframe1"></iframe>
12 <iframe id="iframe2"></iframe>
13 </div>
14 <script>
15 description("Test expected pointerlockchange and pointerlockerror events.")
16 window.jsTestIsAsync = true;
18 targetDiv1 = document.getElementById("target1");
19 targetDiv2 = document.getElementById("target2");
20 targetIframe1 = document.getElementById("iframe1");
21 targetIframe2 = document.getElementById("iframe2");
23 // Events must not bubble from document.
24 function errorIfEventsBubble() {
25 testFailed("Events must not bubble to the window.");
26 finishJSTest();
28 window.addEventListener("pointerlockchange", errorIfEventsBubble);
29 window.addEventListener("pointerlockerror", errorIfEventsBubble);
31 todo = [
32 function () {
33 expectNoEvents("Unlock.");
34 document.exitPointerLock();
35 doNextStepWithUserGesture();
37 function () {
38 expectOnlyChangeEvent("Lock targetDiv1.");
39 targetDiv1.requestPointerLock();
41 function () {
42 expectOnlyChangeEvent("Unlock again.");
43 document.exitPointerLock();
45 function () {
46 expectOnlyChangeEvent("Lock targetDiv1 again.");
47 targetDiv1.requestPointerLock();
49 function () {
50 expectOnlyChangeEvent("Lock targetDiv2.");
51 targetDiv2.requestPointerLock();
53 function () {
54 expectOnlyChangeEvent("Lock targetDiv2 again.");
55 targetDiv2.requestPointerLock();
57 function () {
58 expectOnlyChangeEvent("Unlock targetDiv2.");
59 document.exitPointerLock();
61 function () {
62 targetIframe1.src = "about:blank";
63 targetIframe1.onload = function () { doNextStep(); }
65 function () {
66 targetIframe2.src = "about:blank";
67 targetIframe2.onload = function () { doNextStep(); }
69 function () {
70 expectNoEvents("Lock targetIframe1.");
71 expectOnlyChangeEvent("Lock targetIframe1 (handler for iframe1).", targetIframe1.contentDocument);
72 targetIframe1.contentDocument.body.requestPointerLock();
74 function () {
75 expectNoEvents("Lock targetIframe2.");
76 expectNoEvents("Lock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
77 expectOnlyErrorEvent("Lock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
78 targetIframe2.contentDocument.body.requestPointerLock();
80 function () {
81 expectNoEvents("Unlock targetIframe2.");
82 expectOnlyChangeEvent("Unlock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
83 expectNoEvents("Unlock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
84 targetIframe1.contentDocument.exitPointerLock();
86 function () {
87 shouldBeDefined("testRunner.setPointerLockWillFailSynchronously");
88 testRunner.setPointerLockWillFailSynchronously();
89 expectOnlyErrorEvent("Lock with synchronous failure.");
90 targetDiv1.requestPointerLock();
92 function () {
93 shouldBeDefined("testRunner.setPointerLockWillRespondAsynchronously");
94 shouldBeDefined("testRunner.didAcquirePointerLock");
95 shouldBeDefined("testRunner.didNotAcquirePointerLock");
96 testRunner.setPointerLockWillRespondAsynchronously();
97 expectOnlyErrorEvent("Lock with asynchronous failure.");
98 targetDiv1.requestPointerLock();
99 doNextStep();
101 function () {
102 testRunner.didNotAcquirePointerLock();
104 function () {
105 testRunner.setPointerLockWillRespondAsynchronously();
106 expectOnlyChangeEvent("Lock with asynchronous success.");
107 targetDiv1.requestPointerLock();
108 doNextStep();
110 function () {
111 testRunner.didAcquirePointerLock();
114 doNextStep();
115 </script>
116 </body>
117 </html>