Files
sousa-gecko/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-constraint-validation.html
T
zhoupeng 5b11f3b478 Bug 1930517 [wpt PR 49102] - The validity.customError should return true if the object element has a custom error, a=testonly
Automatic update from web-platform-tests
The `validity.customError` should return true if the object element has a custom error

According to specifications [1]:
- The `setCustomValidity(error)` method steps are:
-   1. Set error to the result of normalizing newlines given error.
-   2. Set the custom validity error message to error.
- `element.validity.customError`:
-   Returns true if the element has a custom error; false otherwise.
When the object element uses `setCustomValidity` to set a custom
error, the element's `validity.customError` should be set to true.
`HTMLObjectElement` does not need to override related functions.

[1]:
https://html.spec.whatwg.org/multipage/#dom-validitystate-customerror

Bug: 40781343
Change-Id: I99500d2ffed863ba9ed7c760c36ca6d0c08c6978
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5999040
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Peng Zhou <zhoupeng.1996@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#1381597}

--

wpt-commits: b3a67da1c157d32761ba88a03dd7f8489174527a
wpt-pr: 49102
2024-11-13 09:24:35 +00:00

22 lines
771 B
HTML

<!doctype html>
<title>The object element's constraint validation.</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-object-element">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-validitystate-customerror">
<link rel="author" title="Peng Zhou" href="mailto:zhoupeng.1996@bytedance.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<object id="element"></object>
<script>
function check() {
assert_false(element.willValidate);
assert_true(element.checkValidity());
assert_true(element.reportValidity());
}
test(() => {
check();
element.setCustomValidity("custom error");
check();
}, "the object element's constraint validation is correct")
</script>