-
Notifications
You must be signed in to change notification settings - Fork 54
/
no-activation-thru-escape-key-manual.html
52 lines (47 loc) · 1.81 KB
/
no-activation-thru-escape-key-manual.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
<!DOCTYPE html>
<html>
<head>
<title>No user activation through 'Escape' key</title>
<meta name="timeout" content="long">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<link rel="author" title="Google" href="http://www.google.com "/>
<link rel="help" href="https://html.spec.whatwg.org/#triggered-by-user-activation">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#target {
width: 40ex;
background-color: yellow;
}
</style>
<script type="text/javascript">
let keydown_event_fired = false;
function run() {
let textbox_elem = document.getElementById("target");
let test_esc_key = async_test("'Escape' key doesn't activate a page.");
test_esc_key.step(() => {
assert_true(!!navigator.userActivation, "This test requires user activation query API");
});
textbox_elem.focus();
on_event(textbox_elem, "keydown", () => {
test_esc_key.step(() => {
keydown_event_fired = true;
assert_false(navigator.userActivation.isActive, "No user activation on keydown");
});
});
on_event(textbox_elem, "keyup", () => {
test_esc_key.step(() => {
assert_true(keydown_event_fired, "keydown event fired before keyup");
assert_false(navigator.userActivation.isActive, "No user activation on keyup");
});
test_esc_key.done();
});
}
</script>
</head>
<body onload="run()">
<h1>No user activation through 'Escape' key</h1>
<h4>Tests that pressing/releasing 'Escape' key is not treated as a user activation.</h4>
<input id="target" value="Press and release the 'Esc' key." />
</body>
</html>