Skip to content

Commit 1f6399f

Browse files
Throw on showPicker() when the <input> is not mutable
This CL makes sure showPicker() throws InvalidStateError DOMException when the HTML input element is either disabled or readonly. Spec: whatwg/html#7769 Bug: 939561 Change-Id: I3c3ad9be897beb17ac110092574331e3af80633c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3563070 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Fr <[email protected]> Cr-Commit-Position: refs/heads/main@{#991363}
1 parent d2bf5df commit 1f6399f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<title>Test showPicker() disabled/readonly requirement</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/testdriver.js"></script>
6+
<script src="/resources/testdriver-vendor.js"></script>
7+
<body></body>
8+
<script type=module>
9+
import inputTypes from "./input-types.js";
10+
11+
for (const inputType of inputTypes) {
12+
test(() => {
13+
const input = document.createElement("input");
14+
input.setAttribute("type", inputType);
15+
input.setAttribute("disabled", "");
16+
17+
assert_throws_dom('InvalidStateError', () => { input.showPicker(); });
18+
}, `input[type=${inputType}] showPicker() throws when disabled`);
19+
}
20+
21+
for (const inputType of inputTypes) {
22+
test(() => {
23+
const input = document.createElement("input");
24+
input.setAttribute("type", inputType);
25+
input.setAttribute("readonly", "");
26+
27+
assert_throws_dom('InvalidStateError', () => { input.showPicker(); });
28+
}, `input[type=${inputType}] showPicker() throws when readonly`);
29+
}
30+
</script>

0 commit comments

Comments
 (0)