Files
tubestation/testing/web-platform/tests/input-events/input-events-arrow-key-on-number-input-delete-document.html
Utkarsh Pathak cba9b74276 Bug 1899975 [wpt PR 46561] - Dispatch BeforeInput Event for number input spin button and Arrow key, a=testonly
Automatic update from web-platform-tests
Dispatch BeforeInput Event for number input spin button and Arrow key

https://w3c.github.io/uievents/#event-type-beforeinput
A user agent MUST dispatch beforeinput event when the DOM is about to be updated.

Bug: 40948436
Change-Id: Idc894f4e7427a81e684b37cc10749b4386e5aa7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5443103
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Utkarsh Pathak <utpathak@microsoft.com>
Reviewed-by: Sanket Joshi <sajos@microsoft.com>
Reviewed-by: Anupam Snigdha <snianu@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1308524}

--

wpt-commits: 6f491c45bc5182275419be89a0820c2deaddc6b0
wpt-pr: 46561
2024-06-05 09:01:16 +00:00

37 lines
1.1 KiB
HTML

<!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>
</head>
<body>
<iframe id="iframe"></iframe>
<script>
promise_test(async function() {
const child = document.getElementById("iframe");
const childDocument = child.contentDocument;
const inputElement = childDocument.createElement('input');
inputElement.type = "number";
childDocument.body.appendChild(inputElement);
let events = [];
inputElement.addEventListener("beforeinput", () => {
child.remove();
events.push("beforeinput");
});
inputElement.addEventListener("input", () => {
evenst.push("input");
});
inputElement.addEventListener("change", () => {
events.push("change");
});
inputElement.focus();
await new test_driver.send_keys(inputElement, "\uE013");
assert_array_equals(events, ['beforeinput']);
}, "Number input should not crash and not fire subsequent events when event handler removes document");
</script>
</body>
</html>