mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Stub out several methods for ElementInternals
This begins implementation on form-associated custom elements. This fixes a few WPT tests which I'm importing. Co-authored-by: Sam Atkins <sam@ladybird.org>
This commit is contained in:
parent
7c4fd9f624
commit
85842c1739
Notes:
github-actions[bot]
2025-05-21 14:29:13 +00:00
Author: https://github.com/AtkinsSJ
Commit: 85842c1739
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4813
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/tcl3
9 changed files with 300 additions and 10 deletions
|
|
@ -0,0 +1,6 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 1 tests
|
||||
|
||||
1 Pass
|
||||
Pass Form-related operations and attributes should throw NotSupportedErrors for non-form-associated custom elements.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 2 tests
|
||||
|
||||
2 Pass
|
||||
Pass ElementInternals.setFormValue(null) clears submission value
|
||||
Pass ElementInternals.setFormValue(undefined) clears submission value
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script src="../../resources/testharness.js"></script>
|
||||
<script src="../../resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
class NotFormAssociatedElement extends HTMLElement {}
|
||||
customElements.define('my-element1', NotFormAssociatedElement);
|
||||
const element = new NotFormAssociatedElement();
|
||||
const i = element.attachInternals();
|
||||
|
||||
assert_throws_dom('NotSupportedError', () => i.setFormValue(''));
|
||||
assert_throws_dom('NotSupportedError', () => i.form);
|
||||
assert_throws_dom('NotSupportedError', () => i.setValidity({}));
|
||||
assert_throws_dom('NotSupportedError', () => i.willValidate);
|
||||
assert_throws_dom('NotSupportedError', () => i.validity);
|
||||
assert_throws_dom('NotSupportedError', () => i.validationMessage);
|
||||
assert_throws_dom('NotSupportedError', () => i.checkValidity());
|
||||
assert_throws_dom('NotSupportedError', () => i.reportValidity());
|
||||
assert_throws_dom('NotSupportedError', () => i.labels);
|
||||
}, 'Form-related operations and attributes should throw NotSupportedErrors' +
|
||||
' for non-form-associated custom elements.');
|
||||
</script>
|
||||
</body>
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>ElementInternals.setFormValue(nullish value) should clear submission value</title>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-setformvalue">
|
||||
<script src="../../resources/testharness.js"></script>
|
||||
<script src="../../resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
customElements.define("test-form-element", class extends HTMLElement {
|
||||
static formAssociated = true;
|
||||
constructor() {
|
||||
super();
|
||||
this.i = this.attachInternals();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form-null">
|
||||
<test-form-element id="input-null" name="input-null"></test-form-element>
|
||||
</form>
|
||||
|
||||
<form id="form-undefined">
|
||||
<test-form-element id="input-undefined" name="input-undefined"></test-form-element>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
test(() => {
|
||||
const input = document.getElementById("input-null");
|
||||
input.i.setFormValue("fail");
|
||||
input.i.setFormValue(null);
|
||||
const formData = new FormData(document.getElementById("form-null"));
|
||||
assert_false(formData.has("input-null"));
|
||||
}, "ElementInternals.setFormValue(null) clears submission value");
|
||||
|
||||
test(() => {
|
||||
const input = document.getElementById("input-undefined");
|
||||
input.i.setFormValue("fail");
|
||||
input.i.setFormValue(undefined);
|
||||
const formData = new FormData(document.getElementById("form-undefined"));
|
||||
assert_false(formData.has("input-undefined"));
|
||||
}, "ElementInternals.setFormValue(undefined) clears submission value");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue