LibWeb/HTML: Update HTMLButtonElement.type to match spec changes
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Corresponds to part of https://github.com/whatwg/html/pull/9841 and then
https://github.com/whatwg/html/pull/11047

Adding `Auto` as a type state feels a little odd, as it's not an actual
type allowed in HTML. However, it's the default state when the value is
missing or invalid, which works out the same, as long as we never
serialize "auto", which we don't.
This commit is contained in:
Sam Atkins 2025-02-20 17:01:28 +00:00 committed by Tim Ledbetter
commit ff1ef07160
Notes: github-actions[bot] 2025-02-22 15:00:37 +00:00
6 changed files with 149 additions and 9 deletions

View file

@ -0,0 +1,64 @@
<!DOCTYPE html>
<link rel=author href="mailto:lwarlow@igalia.com">
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<iframe name=foo></iframe>
<form id="form" target=foo action="about:blank">
<button id=reset-in-form type=reset commandfor=mypopover command=toggle-popover>reset</button>
<button id=submit-in-form type=submit commandfor=mypopover command=toggle-popover>submit</button>
<button id=button-in-form type=button commandfor=mypopover command=toggle-popover>type=button</button>
<button id=invalid-in-form type=invalid commandfor=mypopover command=toggle-popover>invalid</button>
<button id=missing-in-form commandfor=mypopover command=toggle-popover>missing</button>
<button id=missing-in-form-command-only command=toggle-popover>missing with command only</button>
<button id=missing-in-form-commandfor-only commandfor=mypopover >missing with commandfor only</button>
</form>
<button id=reset-attr-form type=reset commandfor=mypopover command=toggle-popover form=form>reset</button>
<button id=submit-attr-form type=submit commandfor=mypopover command=toggle-popover form=form>submit</button>
<button id=button-attr-form type=button commandfor=mypopover command=toggle-popover form=form>type=button</button>
<button id=invalid-attr-form type=invalid commandfor=mypopover command=toggle-popover form=form>invalid</button>
<button id=missing-attr-form commandfor=mypopover command=toggle-popover form=form>missing</button>
<button id=missing-attr-form-command-only command=toggle-popover form=form>missing with command only</button>
<button id=missing-attr-form-commandfor-only commandfor=mypopover form=form>missing with commandfor only</button>
<button id=reset-outside-form type=reset commandfor=mypopover command=toggle-popover>reset</button>
<button id=submit-outside-form type=submit commandfor=mypopover command=toggle-popover>submit</button>
<button id=button-outside-form type=button commandfor=mypopover command=toggle-popover>type=button</button>
<button id=invalid-outside-form type=invalid commandfor=mypopover command=toggle-popover>invalid</button>
<button id=missing-outside-form commandfor=mypopover command=toggle-popover>missing</button>
<button id=missing-outside-form-command-only command=toggle-popover>missing with command only</button>
<button id=missing-outside-form-commandfor-only commandfor=mypopover>missing with commandfor only</button>
<script>
const data = {
'reset-in-form': 'reset',
'submit-in-form': 'submit',
'button-in-form': 'button',
'invalid-in-form': 'submit',
'missing-in-form': 'button',
'missing-in-form-command-only': 'button',
'missing-in-form-commandfor-only': 'button',
'reset-attr-form': 'reset',
'submit-attr-form': 'submit',
'button-attr-form': 'button',
'invalid-attr-form': 'submit',
'missing-attr-form': 'button',
'missing-attr-form-command-only': 'button',
'missing-attr-form-commandfor-only': 'button',
'reset-outside-form': 'reset',
'submit-outside-form': 'submit',
'button-outside-form': 'button',
'invalid-outside-form': 'submit',
'missing-outside-form': 'button',
'missing-outside-form-command-only': 'button',
'missing-outside-form-commandfor-only': 'button',
};
Object.entries(data).map(([id, expectedType]) => {
test(() => {
const button = document.getElementById(id);
assert_equals(button.type, expectedType, `type of ${id} should be ${expectedType}`);
}, `Button with id ${id} should reflect type correctly`);
});
</script>