forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointerlockchange-pointerlockerror-events.html
110 lines (108 loc) · 4.09 KB
/
pointerlockchange-pointerlockerror-events.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE HTML>
<html>
<head>
<script src="../http/tests/resources/js-test-pre.js"></script>
<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
</head>
<body>
<div>
<div id="target1"></div>
<div id="target2"></div>
<iframe id="iframe1"></iframe>
<iframe id="iframe2"></iframe>
</div>
<script>
description("Test expected pointerlockchange and pointerlockerror events.")
window.jsTestIsAsync = true;
targetDiv1 = document.getElementById("target1");
targetDiv2 = document.getElementById("target2");
targetIframe1 = document.getElementById("iframe1");
targetIframe2 = document.getElementById("iframe2");
todo = [
function () {
expectNoEvents("Unlock.");
document.exitPointerLock();
doNextStepWithUserGesture();
},
function () {
expectOnlyChangeEvent("Lock targetDiv1.");
targetDiv1.requestPointerLock();
},
function () {
expectOnlyChangeEvent("Unlock again.");
document.exitPointerLock();
},
function () {
expectOnlyChangeEvent("Lock targetDiv1 again.");
targetDiv1.requestPointerLock();
},
function () {
expectOnlyChangeEvent("Lock targetDiv2.");
targetDiv2.requestPointerLock();
},
function () {
expectOnlyChangeEvent("Lock targetDiv2 again.");
targetDiv2.requestPointerLock();
},
function () {
expectOnlyChangeEvent("Unlock targetDiv2.");
document.exitPointerLock();
},
function () {
targetIframe1.src = "about:blank";
targetIframe1.onload = function () { doNextStep(); }
},
function () {
targetIframe2.src = "about:blank";
targetIframe2.onload = function () { doNextStep(); }
},
function () {
expectNoEvents("Lock targetIframe1.");
expectOnlyChangeEvent("Lock targetIframe1 (handler for iframe1).", targetIframe1.contentDocument);
targetIframe1.contentDocument.body.requestPointerLock();
},
function () {
expectNoEvents("Lock targetIframe2.");
expectNoEvents("Lock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
expectOnlyErrorEvent("Lock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
targetIframe2.contentDocument.body.requestPointerLock();
},
function () {
expectNoEvents("Unlock targetIframe2.");
expectOnlyChangeEvent("Unlock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
expectNoEvents("Unlock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
targetIframe1.contentDocument.exitPointerLock();
},
function () {
shouldBeDefined("testRunner.setPointerLockWillFailSynchronously");
testRunner.setPointerLockWillFailSynchronously();
expectOnlyErrorEvent("Lock with synchronous failure.");
targetDiv1.requestPointerLock();
},
function () {
shouldBeDefined("testRunner.setPointerLockWillRespondAsynchronously");
shouldBeDefined("testRunner.didAcquirePointerLock");
shouldBeDefined("testRunner.didNotAcquirePointerLock");
testRunner.setPointerLockWillRespondAsynchronously();
expectOnlyErrorEvent("Lock with asynchronous failure.");
targetDiv1.requestPointerLock();
doNextStep();
},
function () {
testRunner.didNotAcquirePointerLock();
},
function () {
testRunner.setPointerLockWillRespondAsynchronously();
expectOnlyChangeEvent("Lock with asynchronous success.");
targetDiv1.requestPointerLock();
doNextStep();
},
function () {
testRunner.didAcquirePointerLock();
},
];
doNextStep();
</script>
<script src="../http/tests/resources/js-test-post.js"></script>
</body>
</html>