blob: 0045e20788189a8b118a9363490bfa17c067a736 (
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
|
<!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/multipage/interaction.html#tracking-user-activation">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
#target {
width: 40ex;
background-color: yellow;
}
</style>
<script type="text/javascript">
let keydown_event_fired = false;
let keyup_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(() => {
if (keydown_event_fired)
keyup_event_fired = true;
assert_true(keydown_event_fired, "keydown event fired before keyup");
assert_false(navigator.userActivation.isActive, "No user activation on keyup");
});
});
// Inject mouse inputs.
const escape_key = "\uE00C";
test_driver
.send_keys(textbox_elem, escape_key)
.then(() => {
assert_true(keyup_event_fired, "keydown event fired before 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>
|