-
Notifications
You must be signed in to change notification settings - Fork 54
/
activation-thru-contextmenu-event-manual.html
59 lines (55 loc) · 1.83 KB
/
activation-thru-contextmenu-event-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
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<title>User activation with 'contextmenu' event</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: 250px;
height: 150px;
float: left;
background-color: green;
}
#done {
float: left;
padding: 20px;
margin: 10px;
}
</style>
<script type="text/javascript">
let activation_event_fired = false;
function run() {
let success = false;
let test_contextmenu = async_test("'contextmenu' can call vibrate.");
on_event(document.getElementById("done"), "click", () => {
test_contextmenu.step(() => {
assert_true(activation_event_fired, "activation event has fired");
});
test_contextmenu.done();
});
on_event(document.getElementById("target"), "contextmenu", (e) => {
test_contextmenu.step(() => {
e.preventDefault();
assert_true(navigator.vibrate(200), "navigator.vibrate is successful");
activation_event_fired = true;
});
});
}
</script>
</head>
<body onload="run()">
<h1>User activation with 'contextmenu' event</h1>
<h4>Tests that a 'contextmenu' event is treated like a user activation.</h4>
<ol>
<li>Right-click or long-press on green.</li>
<li>Click or tap on Done.</li>
</ol>
<div id="target"></div>
<input type="button" id="done" value="Done" />
</body>
</html>