Skip to content

Commit 3704e78

Browse files
Fine-tune wpts for user-activation triggers to match spec proposal.
Proposed HTML PR: whatwg/html#7248 Manually verified that these tests pass in Firefox. Change-Id: I910158680a3741290ba9beef2c29050c11763be0
1 parent bbf5ec1 commit 3704e78

6 files changed

+149
-108
lines changed

html/user-activation/activation-thru-contextmenu-event.html

Lines changed: 0 additions & 77 deletions
This file was deleted.

html/user-activation/activation-trigger-click.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

html/user-activation/activation-trigger-keypress.html renamed to html/user-activation/activation-trigger-keyboard-enter.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<script src="resources/utils.js"></script>
99
</head>
1010
<body>
11-
<h1>Test for keypress activation trigger</h1>
12-
<p>Tests that a popup is allowed with user activation from a keypress event.</p>
11+
<h1>Test for keyboard activation trigger for ENTER key</h1>
12+
<p>Tests user activation from a ENTER keyboard event.</p>
1313
<input type="text" autofocus />
1414
<ol id="instructions">
1515
<li>Press ENTER key.
@@ -19,18 +19,25 @@ <h1>Test for keypress activation trigger</h1>
1919
const ENTER_KEY = '\uE007';
2020
test_driver.send_keys(document.body, ENTER_KEY);
2121

22+
let keydown_event = getEvent('keydown');
23+
let keypress_event = getEvent('keypress');
2224
let keyup_event = getEvent('keyup');
2325

24-
await getEvent('keypress');
26+
await keydown_event;
2527
let consumed = await consumeTransientActivation();
2628
assert_true(consumed,
27-
"ENTER keypress event should result in activation");
29+
"ENTER keydown event should result in activation");
30+
31+
await keypress_event;
32+
consumed = await consumeTransientActivation();
33+
assert_false(consumed,
34+
"ENTER keypress should have no activation after keydown consumption");
2835

2936
await keyup_event;
3037
consumed = await consumeTransientActivation();
3138
assert_false(consumed,
32-
"ENTER keyup should have no activation after keypress consumption");
33-
}, "Activation through keyboard event");
39+
"ENTER keyup should have no activation after keydown consumption");
40+
}, "Activation through ENTER keyboard event");
3441
</script>
3542
</body>
3643
</html>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/resources/testdriver.js"></script>
7+
<script src="/resources/testdriver-vendor.js"></script>
8+
<script src="resources/utils.js"></script>
9+
</head>
10+
<body>
11+
<h1>Test for keyboard activation trigger for ESCAPE key</h1>
12+
<p>Tests missing user activation from a ESCAPE keyboard event.</p>
13+
<input type="text" autofocus />
14+
<ol id="instructions">
15+
<li>Press ESCAPE key.
16+
</ol>
17+
<script>
18+
promise_test(async () => {
19+
const ESCAPE_KEY = '\uE00C';
20+
test_driver.send_keys(document.body, ESCAPE_KEY);
21+
22+
let keydown_event = getEvent('keydown');
23+
let keyup_event = getEvent('keyup');
24+
25+
await keydown_event;
26+
let consumed = await consumeTransientActivation();
27+
assert_false(consumed,
28+
"ESCAPE keydown event should not result in activation");
29+
30+
await keyup_event;
31+
consumed = await consumeTransientActivation();
32+
assert_false(consumed,
33+
"ESCAPE keyup should have no activation after keydown consumption");
34+
}, "Activation through ESCAPE keyboard event");
35+
</script>
36+
</body>
37+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/resources/testdriver.js"></script>
7+
<script src="/resources/testdriver-vendor.js"></script>
8+
<script src="resources/utils.js"></script>
9+
</head>
10+
<body>
11+
<h1>Test for click activation trigger</h1>
12+
<p>Tests user activation from a mouse click.</p>
13+
<ol id="instructions">
14+
<li>Click anywhere in the document.
15+
</ol>
16+
<script>
17+
promise_test(async () => {
18+
test_driver.click(document.body);
19+
20+
let mousedown_event = getEvent('mousedown');
21+
let mouseup_event = getEvent('mouseup');
22+
let click_event = getEvent('click');
23+
24+
await mousedown_event;
25+
let consumed = await consumeTransientActivation();
26+
assert_true(consumed,
27+
"mousedown event should result in activation");
28+
29+
await mouseup_event;
30+
consumed = await consumeTransientActivation();
31+
assert_false(consumed,
32+
"mouseup should have no activation after mousedown consumption");
33+
34+
await click_event;
35+
consumed = await consumeTransientActivation();
36+
assert_false(consumed,
37+
"click should have no activation after mousedown consumption");
38+
}, "Activation through left-click mouse event");
39+
</script>
40+
</body>
41+
</html>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/resources/testdriver.js"></script>
7+
<script src="/resources/testdriver-actions.js"></script>
8+
<script src="/resources/testdriver-vendor.js"></script>
9+
<script src="resources/utils.js"></script>
10+
</head>
11+
<body>
12+
<h1>Test for right-click activation trigger</h1>
13+
<p>Tests user activation from a mouse right-click.</p>
14+
<ol id="instructions">
15+
<li>Right-click anywhere in the document.
16+
</ol>
17+
<script>
18+
promise_test(async () => {
19+
var actions = new test_driver.Actions();
20+
actions_promise = actions
21+
.pointerMove(0, 0, {origin: document.body})
22+
.pointerDown({button: actions.ButtonType.RIGHT})
23+
.pointerUp({button: actions.ButtonType.RIGHT})
24+
.send();
25+
26+
// In most non-Windows platforms the right-click context-menu appears on mousedown, so
27+
// mouseup and auxclick events are not received by the page if the menu is modal. We
28+
// are suppressing the context-menu to guarantee receiving those later events.
29+
document.body.addEventListener("contextmenu", e => e.preventDefault());
30+
31+
let mousedown_event = getEvent('mousedown');
32+
let mouseup_event = getEvent('mouseup');
33+
let auxclick_event = getEvent('auxclick');
34+
let contextmenu_event = getEvent('contextmenu');
35+
36+
await mousedown_event;
37+
let consumed = await consumeTransientActivation();
38+
assert_true(consumed,
39+
"mousedown event should result in activation");
40+
41+
await mouseup_event;
42+
consumed = await consumeTransientActivation();
43+
assert_false(consumed,
44+
"mouseup should have no activation after mousedown consumption");
45+
46+
await auxclick_event;
47+
consumed = await consumeTransientActivation();
48+
assert_false(consumed,
49+
"auxclick should have no activation after mousedown consumption");
50+
51+
await contextmenu_event;
52+
consumed = await consumeTransientActivation();
53+
assert_false(consumed,
54+
"contextmenu should have no activation after mousedown consumption");
55+
}, "Activation through right-click mouse event");
56+
</script>
57+
</body>
58+
</html>

0 commit comments

Comments
 (0)