Skip to content

Commit

Permalink
Bug 1737628 [wpt PR 31373] - Fine-tune wpts for user-activation trigg…
Browse files Browse the repository at this point in the history
…ers to match spec proposal., a=testonly

Automatic update from web-platform-tests
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

--

wpt-commits: 3704e78870c66cf9424a1bebfa441198335c002c
wpt-pr: 31373
  • Loading branch information
mustaqahmed authored and moz-wptsync-bot committed Oct 29, 2021
1 parent c15301f commit 93cd854
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 108 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<script src="resources/utils.js"></script>
</head>
<body>
<h1>Test for keypress activation trigger</h1>
<p>Tests that a popup is allowed with user activation from a keypress event.</p>
<h1>Test for keyboard activation trigger for ENTER key</h1>
<p>Tests user activation from a ENTER keyboard event.</p>
<input type="text" autofocus />
<ol id="instructions">
<li>Press ENTER key.
Expand All @@ -19,18 +19,25 @@ <h1>Test for keypress activation trigger</h1>
const ENTER_KEY = '\uE007';
test_driver.send_keys(document.body, ENTER_KEY);

let keydown_event = getEvent('keydown');
let keypress_event = getEvent('keypress');
let keyup_event = getEvent('keyup');

await getEvent('keypress');
await keydown_event;
let consumed = await consumeTransientActivation();
assert_true(consumed,
"ENTER keypress event should result in activation");
"ENTER keydown event should result in activation");

await keypress_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"ENTER keypress should have no activation after keydown consumption");

await keyup_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"ENTER keyup should have no activation after keypress consumption");
}, "Activation through keyboard event");
"ENTER keyup should have no activation after keydown consumption");
}, "Activation through ENTER keyboard event");
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<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>
<script src="resources/utils.js"></script>
</head>
<body>
<h1>Test for keyboard activation trigger for ESCAPE key</h1>
<p>Tests missing user activation from a ESCAPE keyboard event.</p>
<input type="text" autofocus />
<ol id="instructions">
<li>Press ESCAPE key.
</ol>
<script>
promise_test(async () => {
const ESCAPE_KEY = '\uE00C';
test_driver.send_keys(document.body, ESCAPE_KEY);

let keydown_event = getEvent('keydown');
let keyup_event = getEvent('keyup');

await keydown_event;
let consumed = await consumeTransientActivation();
assert_false(consumed,
"ESCAPE keydown event should not result in activation");

await keyup_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"ESCAPE keyup should have no activation after keydown consumption");
}, "Activation through ESCAPE keyboard event");
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<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>
<script src="resources/utils.js"></script>
</head>
<body>
<h1>Test for click activation trigger</h1>
<p>Tests user activation from a mouse click.</p>
<ol id="instructions">
<li>Click anywhere in the document.
</ol>
<script>
promise_test(async () => {
test_driver.click(document.body);

let mousedown_event = getEvent('mousedown');
let mouseup_event = getEvent('mouseup');
let click_event = getEvent('click');

await mousedown_event;
let consumed = await consumeTransientActivation();
assert_true(consumed,
"mousedown event should result in activation");

await mouseup_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"mouseup should have no activation after mousedown consumption");

await click_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"click should have no activation after mousedown consumption");
}, "Activation through left-click mouse event");
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/utils.js"></script>
</head>
<body>
<h1>Test for right-click activation trigger</h1>
<p>Tests user activation from a mouse right-click.</p>
<ol id="instructions">
<li>Right-click anywhere in the document.
</ol>
<script>
promise_test(async () => {
var actions = new test_driver.Actions();
actions_promise = actions
.pointerMove(0, 0, {origin: document.body})
.pointerDown({button: actions.ButtonType.RIGHT})
.pointerUp({button: actions.ButtonType.RIGHT})
.send();

// In most non-Windows platforms the right-click context-menu appears on mousedown, so
// mouseup and auxclick events are not received by the page if the menu is modal. We
// are suppressing the context-menu to guarantee receiving those later events.
document.body.addEventListener("contextmenu", e => e.preventDefault());

let mousedown_event = getEvent('mousedown');
let mouseup_event = getEvent('mouseup');
let auxclick_event = getEvent('auxclick');
let contextmenu_event = getEvent('contextmenu');

await mousedown_event;
let consumed = await consumeTransientActivation();
assert_true(consumed,
"mousedown event should result in activation");

await mouseup_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"mouseup should have no activation after mousedown consumption");

await auxclick_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"auxclick should have no activation after mousedown consumption");

await contextmenu_event;
consumed = await consumeTransientActivation();
assert_false(consumed,
"contextmenu should have no activation after mousedown consumption");
}, "Activation through right-click mouse event");
</script>
</body>
</html>

0 comments on commit 93cd854

Please sign in to comment.