-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'keyup' and 'keypress' to 'activation triggering input event' #6818
Conversation
This at the very least needs tests. Can you restore the PR template? |
WPTs with user activation are tricky because they have to rely on a gated API like popup or fullscreen. I know fullscreen has interop problems with activation consumption, so popup seems to be the only good choice here. (Wish we had some movement in #4008, at least for sake of better WPTs.) |
I don't know all the details here, but we can easily send keys via web driver (and detect the events). Quick search finds the following, which maybe we can use?: @mustaqahmed, if you can describe what you need, we can try to cook something up. If we hit issues, that's actually good... as it's incentive to fix things in Web Driver or WPT! |
Web-driver key dispatch works (i.e. activates the page correctly), I meant asserting this activation state is the main hurdle in WPTs. You have to rely on a user-activation gated API like popup, or rely on a tentative API. See the WPTs in html/user-activation), I think |
@marcoscaceres Please let me know if writing a WPT like this one makes sense to you. |
@mustaqahmed yes, but that could be written in a way that is a bit more linear using promises/async/await. Like, can get a little bit more fancy with them (easier to read, debug, and maintain): promise_test(async t => {
const clickPromise = new Promise(resolve => {
window.addEventListener("click",resolve);
});
test_driver.click(document.body);
await clickPromise;
const win = window.open();
assert_true(Boolean(win));
}, "Popup with click"); For your case with the keys, I suggest doing something similar to the follow (I've not tested this code, just pseudo code): function keyPress(element, keys) {
test_driver.send_keys(element, keys);
const pressPromise = new Promise((resolve) => {
element.addEventListener("keypress", resolve, { once: true });
});
return pressPromise; // Returns the Event
}
promise_test(async t => {
const input = document.createElement("input");
input.type = "text";
document.body.appendChild(input);
input.focus();
await keyPress(input, "a");
await keyPress(input, "b");
await keyPress(input, "c");
assert_equals(input.value, "abc");
const event = keyPress(input, "d");
// assert_true() something to do with the event?
}, "Keypress events must be sent blah blah make sure this is really descriptive and matches the spec"); |
Just as an aside, .send_keys() let's you send multiple keys, so you could get a bit fancier. Anyway, feel feel to ping me over on the WTP side once you have a test up and I can help review it - or we can bounce ideas there how to best test things. |
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
Testing with popup seems tricky because popup blocker is disabled in WPT setup! web-platform-tests/wpt#30777 |
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
I don't recall having issues with popups, to be honest? I think that as long as you " Do |
All existing tests I saw want popups to open. For our case, the test needs to block a popup without user activation, so that we can determine the availability of user activation. Fortunately, all of Chrome, Firefox and Safari seem to consume user activation on fullscreen, so I am working now on a fullscreen-based tests instead. |
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6
Just landed a WPT for |
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3159551 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#926812}
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3159551 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#926812}
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3159551 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#926812}
As per #3849 (comment) I think we need to mention the |
@annevk I agree, thanks. The challenge with May I suggest doing that bigger change separately? It would also unblock @marcoscaceres's PointerLock PR mentioned above. |
I think it would be unfortunate for the spec to start mandating that Esc keyup and Esc keypress were activation-triggering, as they would if we accepted this PR as-is. So I think the issue needs to be taken care of holistically. |
That's fair, thanks. Let's discuss about an incremental-yet-acceptable path in the issue. I will dump some ideas there today. |
…ress and keyup events., a=testonly Automatic update from web-platform-tests 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3159551 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#926812} -- wpt-commits: aa4a6c240131c34425819ecd981423332f9028f0 wpt-pr: 30777
…ress and keyup events., a=testonly Automatic update from web-platform-tests 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3159551 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#926812} -- wpt-commits: aa4a6c240131c34425819ecd981423332f9028f0 wpt-pr: 30777
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3159551 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#926812}
We can close this PR now: we recently landed a clearer definition of "activation triggering input events" (through #7248) which covers the changes proposed here. |
These tests are for the following HTML PR: whatwg/html#6818 Also renamed the existing click event test for consistency. Change-Id: If77750f4159828b68bd91a4b48f46606421b7df6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3159551 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#926812} NOKEYCHECK=True GitOrigin-RevId: d0d9a5b51f501f0f901dfe3a097b028b06c4b907
Please see w3c/pointerlock#70 over on Pointerlock for details.
(See WHATWG Working Mode: Changes for more details.)
cc @mustaqahmed
/interaction.html ( diff )