-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added WPTs for user-activation from keypress and keyup events.
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
- Loading branch information
1 parent
d02695a
commit df2e094
Showing
4 changed files
with
97 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!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 that a popup is allowed with user activation from a click event.</p> | ||
<ol id="instructions"> | ||
<li>Click anywhere in the document. | ||
</ol> | ||
<script> | ||
let test_mouse_event = async_test("Activation through click"); | ||
let first_click_received = false; | ||
|
||
window.addEventListener("click", async () => { | ||
if (first_click_received) | ||
test_mouse_event.done(); | ||
else | ||
first_click_received = true; | ||
|
||
let consumed = await consumeTransientActivation(); | ||
test_mouse_event.step_func(() => { | ||
assert_true(consumed, "click event should activate"); | ||
}); | ||
}); | ||
|
||
test_driver.click(document.body); | ||
test_driver.click(document.body); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!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 keypress activation trigger</h1> | ||
<p>Tests that a popup is allowed with user activation from a keypress event.</p> | ||
<input type="text" autofocus /> | ||
<ol id="instructions"> | ||
<li>Press ENTER key. | ||
</ol> | ||
<script> | ||
const ENTER_KEY = '\uE007'; | ||
let test_key_event = async_test("Activation through keyboard event"); | ||
let first_keypress_received = false; | ||
|
||
window.addEventListener("keypress", async () => { | ||
if (first_keypress_received) | ||
test_key_event.done(); | ||
else | ||
first_keypress_received = true; | ||
|
||
let consumed = await consumeTransientActivation(); | ||
test_key_event.step_func(() => { | ||
assert_true(consumed, "ENTER keypress activation consumed"); | ||
}); | ||
}); | ||
|
||
window.addEventListener("keyup", async () => { | ||
let consumed = await consumeTransientActivation(); | ||
test_key_event.step_func(() => { | ||
assert_true(first_keypress_received, "ENTER keypress received before keyup"); | ||
assert_false(consumed, "ENTER keyup no activation after keypress consumption"); | ||
}); | ||
}); | ||
|
||
test_driver.send_keys(document.body, ENTER_KEY); | ||
test_driver.send_keys(document.body, ENTER_KEY); | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters