blob: 198e2fe63d74888a3abd9fbaf8dd5427cc25addd (
plain)
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
|
<!DOCTYPE html>
<html>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<style type="text/css">
button {
color: blue;
}
#target-wrap {
position: relative;
background-color: lightgrey;
width: 200px;
height: 100px;
border: grey 1px solid;
}
#target {
position: relative;
background-color: lightyellow;
width: 100px;
height: 30px;
border: yellow 1px solid;
}
#status-log {
margin: 10px 0;
color: green;
}
</style>
</head>
<body>
<h2>Description</h2>
<p>This test validates that pointer lock will be lost the user agent / window loses focus.</p>
<hr/>
<h2>Manual Test Steps:</h2>
<p>
<ol>
<li>Click the "lockTarget" button to request a pointer lock.</li>
<li>Focus to another tab with keyboard (Ctrl-TAB).</li>
<li>Test is done.</li>
</ol>
</p>
<hr/>
<button onclick="lockTarget();">lockTarget</button>
<div id="target-wrap">
<div id="status-log">Click the "lockTarget" button.</div>
<div id="target">Target</div>
</div>
<hr/>
<div id="log"></div>
<script type="text/javascript" >
var target = document.querySelector('#target'),
status_log = document.querySelector('#status-log');
var leaveTabTest = async_test("Test that pointer lock will be lost when the current Tab loses focus.");
document.addEventListener("pointerlockchange", function() {
if(document.pointerLockElement) {
status_log.innerHTML = "Please leave the current tab.";
} else {
status_log.innerHTML = "Pointer lock exited!";
leaveTabTest.step(function() {
assert_true(document.pointerLockElement === null, "Pointer lock exited!");
});
leaveTabTest.done();
}
});
function lockTarget() {
target.requestPointerLock();
}
</script>
</body>
</html>
|