OLD | NEW |
| (Empty) |
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-pref
ixed.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; | |
17 | |
18 targetDiv1 = document.getElementById("target1"); | |
19 targetDiv2 = document.getElementById("target2"); | |
20 targetIframe1 = document.getElementById("iframe1"); | |
21 targetIframe2 = document.getElementById("iframe2"); | |
22 | |
23 // Events must not bubble from document. | |
24 function errorIfEventsBubble() { | |
25 testFailed("Events must not bubble to the window."); | |
26 finishJSTest(); | |
27 } | |
28 window.addEventListener("webkitpointerlockchange", errorIfEventsBubble); | |
29 window.addEventListener("webkitpointerlockerror", errorIfEventsBubble); | |
30 | |
31 todo = [ | |
32 function () { | |
33 expectNoEvents("Unlock."); | |
34 document.webkitExitPointerLock(); | |
35 doNextStepWithUserGesture(); | |
36 }, | |
37 function () { | |
38 expectOnlyChangeEvent("Lock targetDiv1."); | |
39 targetDiv1.webkitRequestPointerLock(); | |
40 }, | |
41 function () { | |
42 expectOnlyChangeEvent("Unlock again."); | |
43 document.webkitExitPointerLock(); | |
44 }, | |
45 function () { | |
46 expectOnlyChangeEvent("Lock targetDiv1 again."); | |
47 targetDiv1.webkitRequestPointerLock(); | |
48 }, | |
49 function () { | |
50 expectOnlyChangeEvent("Lock targetDiv2."); | |
51 targetDiv2.webkitRequestPointerLock(); | |
52 }, | |
53 function () { | |
54 expectOnlyChangeEvent("Lock targetDiv2 again."); | |
55 targetDiv2.webkitRequestPointerLock(); | |
56 }, | |
57 function () { | |
58 expectOnlyChangeEvent("Unlock targetDiv2."); | |
59 document.webkitExitPointerLock(); | |
60 }, | |
61 function () { | |
62 targetIframe1.src = "about:blank"; | |
63 targetIframe1.onload = function () { doNextStep(); } | |
64 }, | |
65 function () { | |
66 targetIframe2.src = "about:blank"; | |
67 targetIframe2.onload = function () { doNextStep(); } | |
68 }, | |
69 function () { | |
70 expectNoEvents("Lock targetIframe1."); | |
71 expectOnlyChangeEvent("Lock targetIframe1 (handler for iframe1).", t
argetIframe1.contentDocument); | |
72 targetIframe1.contentDocument.body.webkitRequestPointerLock(); | |
73 }, | |
74 function () { | |
75 expectNoEvents("Lock targetIframe2."); | |
76 expectNoEvents("Lock targetIframe2 (handler for iframe1).", targetIf
rame1.contentDocument); | |
77 expectOnlyErrorEvent("Lock targetIframe2 (handler for iframe2).", ta
rgetIframe2.contentDocument); | |
78 targetIframe2.contentDocument.body.webkitRequestPointerLock(); | |
79 }, | |
80 function () { | |
81 expectNoEvents("Unlock targetIframe2."); | |
82 expectOnlyChangeEvent("Unlock targetIframe2 (handler for iframe1).",
targetIframe1.contentDocument); | |
83 expectNoEvents("Unlock targetIframe2 (handler for iframe2).", target
Iframe2.contentDocument); | |
84 targetIframe1.contentDocument.webkitExitPointerLock(); | |
85 }, | |
86 function () { | |
87 shouldBeDefined("testRunner.setPointerLockWillFailSynchronously"); | |
88 testRunner.setPointerLockWillFailSynchronously(); | |
89 expectOnlyErrorEvent("Lock with synchronous failure."); | |
90 targetDiv1.webkitRequestPointerLock(); | |
91 }, | |
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.webkitRequestPointerLock(); | |
99 doNextStep(); | |
100 }, | |
101 function () { | |
102 testRunner.didNotAcquirePointerLock(); | |
103 }, | |
104 function () { | |
105 testRunner.setPointerLockWillRespondAsynchronously(); | |
106 expectOnlyChangeEvent("Lock with asynchronous success."); | |
107 targetDiv1.webkitRequestPointerLock(); | |
108 doNextStep(); | |
109 }, | |
110 function () { | |
111 testRunner.didAcquirePointerLock(); | |
112 }, | |
113 ]; | |
114 doNextStep(); | |
115 </script> | |
116 </body> | |
117 </html> | |
OLD | NEW |