Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 4 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/invokers/invoketarget-on-input-number.tentative.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8" />
<meta name="author" title="Luke Warlow" href="mailto:lwarlow@igalia.com" />
<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/invoker-utils.js"></script>
<input type="number" id="invokee" value="0">
<button id="invokerbutton" commandfor="invokee"></button>
<script>
function reset() {
invokee.value = 0;
invokerbutton.removeAttribute('command');
}
// step-up
promise_test(async function (t) {
t.add_cleanup(reset);
assert_equals(invokee.valueAsNumber, 0);
invokerbutton.setAttribute("command", "step-up");
await clickOn(invokerbutton);
assert_equals(invokee.valueAsNumber, 1);
}, "invoking number input with step-up action increments value");
promise_test(async function (t) {
t.add_cleanup(reset);
assert_equals(invokee.valueAsNumber, 0);
invokerbutton.setAttribute("command", "sTeP-uP");
await clickOn(invokerbutton);
assert_equals(invokee.valueAsNumber, 1);
}, "invoking number input with step-up action (case-insensitive) increments value");
promise_test(async function (t) {
t.add_cleanup(reset);
assert_equals(invokee.valueAsNumber, 0);
invokerbutton.setAttribute("command", "step-up");
invokee.addEventListener("command", (e) => e.preventDefault(), {
once: true,
});
await clickOn(invokerbutton);
assert_equals(invokee.valueAsNumber, 0);
}, "invoking number input with step-up action and preventDefault does not increment value");
// step-down
promise_test(async function (t) {
t.add_cleanup(reset);
assert_equals(invokee.valueAsNumber, 0);
invokerbutton.setAttribute("command", "step-down");
await clickOn(invokerbutton);
assert_equals(invokee.valueAsNumber, -1);
}, "invoking number input with step-down action decrements value");
promise_test(async function (t) {
t.add_cleanup(reset);
assert_equals(invokee.valueAsNumber, 0);
invokerbutton.setAttribute("command", "sTeP-dOwN");
await clickOn(invokerbutton);
assert_equals(invokee.valueAsNumber, -1);
}, "invoking number input with step-down action (case-insensitive) decrements value");
promise_test(async function (t) {
t.add_cleanup(reset);
assert_equals(invokee.valueAsNumber, 0);
invokerbutton.setAttribute("command", "step-down");
invokee.addEventListener("command", (e) => e.preventDefault(), {
once: true,
});
await clickOn(invokerbutton);
assert_equals(invokee.valueAsNumber, 0);
}, "invoking number input with step-down action and preventDefault does not decrement value");
</script>