summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html')
-rw-r--r--testing/web-platform/tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html b/testing/web-platform/tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html
new file mode 100644
index 0000000000..8fdffc158f
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<title>Test showPicker() disabled/readonly requirement</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<body></body>
+<script type=module>
+import inputTypes from "./input-types.js";
+
+for (const inputType of inputTypes) {
+ test(() => {
+ const input = document.createElement("input");
+ input.setAttribute("type", inputType);
+ input.setAttribute("disabled", "");
+
+ assert_throws_dom('InvalidStateError', () => { input.showPicker(); });
+ }, `input[type=${inputType}] showPicker() throws when disabled`);
+}
+
+const noReadonlySupport = ['button', 'checkbox', 'color', 'file',
+'hidden', 'image', 'radio', 'range', 'reset', 'submit'];
+for (const inputType of inputTypes) {
+ if (!noReadonlySupport.includes(inputType)) {
+ test(() => {
+ const input = document.createElement("input");
+ input.setAttribute("type", inputType);
+ input.setAttribute("readonly", "");
+
+ assert_throws_dom('InvalidStateError', () => { input.showPicker(); });
+ }, `input[type=${inputType}] showPicker() throws when readonly`);
+ } else {
+ test(() => {
+ const input = document.createElement("input");
+ input.setAttribute("type", inputType);
+ input.setAttribute("readonly", "");
+
+ // Missing user gesture activation throws.
+ assert_throws_dom('NotAllowedError', () => { input.showPicker(); });
+ }, `input[type=${inputType}] showPicker() doesn't throw when readonly`);
+ }
+}
+</script>