Skip to content
Permalink
Browse files
input.showPicker() should throw when input is readonly/disabled
https://bugs.webkit.org/show_bug.cgi?id=240302

Reviewed by Tim Nguyen.

LayoutTests/imported/w3c:

* web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly-expected.txt: Added.
* web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html: Added.

Source/WebCore:

When input is readonly or disabled, input.showPicker() should throw InvalidStateError.

Test: imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::showPicker):

Canonical link: https://commits.webkit.org/250532@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294163 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ziransun committed May 13, 2022
1 parent 8d3d784 commit 00de4db0cd347701165f620886a8653440985072
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 45 deletions.
@@ -1,3 +1,13 @@
2022-05-13 Ziran Sun <zsun@igalia.com>

input.showPicker() should throw when input is readonly/disabled
https://bugs.webkit.org/show_bug.cgi?id=240302

Reviewed by Tim Nguyen.

* web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly-expected.txt: Added.
* web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html: Added.

2022-05-13 Tim Nguyen <ntim@apple.com>

Clean up some html/semantics/forms/ test expectations
@@ -1,46 +1,46 @@

FAIL input[type=button] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=checkbox] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=color] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=date] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=datetime-local] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=email] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=file] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=hidden] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=image] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=month] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=number] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=password] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=radio] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=range] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=reset] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=search] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=submit] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=tel] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=text] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=time] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=url] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=week] showPicker() throws when disabled assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
PASS input[type=button] showPicker() doesn't throw when readonly
PASS input[type=checkbox] showPicker() doesn't throw when readonly
PASS input[type=color] showPicker() doesn't throw when readonly
FAIL input[type=date] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=datetime-local] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=email] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
PASS input[type=file] showPicker() doesn't throw when readonly
PASS input[type=hidden] showPicker() doesn't throw when readonly
PASS input[type=image] showPicker() doesn't throw when readonly
FAIL input[type=month] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=number] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=password] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
PASS input[type=radio] showPicker() doesn't throw when readonly
PASS input[type=range] showPicker() doesn't throw when readonly
PASS input[type=reset] showPicker() doesn't throw when readonly
FAIL input[type=search] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
PASS input[type=submit] showPicker() doesn't throw when readonly
FAIL input[type=tel] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=text] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=time] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=url] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
FAIL input[type=week] showPicker() throws when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "NotAllowedError: Input showPicker() requires a user gesture." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
PASS input[type=button] showPicker() throws when disabled
PASS input[type=checkbox] showPicker() throws when disabled
PASS input[type=color] showPicker() throws when disabled
PASS input[type=date] showPicker() throws when disabled
PASS input[type=datetime-local] showPicker() throws when disabled
PASS input[type=email] showPicker() throws when disabled
PASS input[type=file] showPicker() throws when disabled
PASS input[type=hidden] showPicker() throws when disabled
PASS input[type=image] showPicker() throws when disabled
PASS input[type=month] showPicker() throws when disabled
PASS input[type=number] showPicker() throws when disabled
PASS input[type=password] showPicker() throws when disabled
PASS input[type=radio] showPicker() throws when disabled
PASS input[type=range] showPicker() throws when disabled
PASS input[type=reset] showPicker() throws when disabled
PASS input[type=search] showPicker() throws when disabled
PASS input[type=submit] showPicker() throws when disabled
PASS input[type=tel] showPicker() throws when disabled
PASS input[type=text] showPicker() throws when disabled
PASS input[type=time] showPicker() throws when disabled
PASS input[type=url] showPicker() throws when disabled
PASS input[type=week] showPicker() throws when disabled
FAIL input[type=button] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
FAIL input[type=checkbox] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
FAIL input[type=color] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
PASS input[type=date] showPicker() throws when readonly
PASS input[type=datetime-local] showPicker() throws when readonly
PASS input[type=email] showPicker() throws when readonly
FAIL input[type=file] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
FAIL input[type=hidden] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
FAIL input[type=image] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
PASS input[type=month] showPicker() throws when readonly
PASS input[type=number] showPicker() throws when readonly
PASS input[type=password] showPicker() throws when readonly
FAIL input[type=radio] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
FAIL input[type=range] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
FAIL input[type=reset] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
PASS input[type=search] showPicker() throws when readonly
FAIL input[type=submit] showPicker() doesn't throw when readonly assert_throws_dom: function "() => { input.showPicker(); }" threw object "InvalidStateError: Input showPicker() cannot be used on immutable controls." that is not a DOMException NotAllowedError: property "code" is equal to 11, expected 0
PASS input[type=tel] showPicker() throws when readonly
PASS input[type=text] showPicker() throws when readonly
PASS input[type=time] showPicker() throws when readonly
PASS input[type=url] showPicker() throws when readonly
PASS input[type=week] showPicker() throws when readonly

@@ -1,3 +1,17 @@
2022-05-13 Ziran Sun <zsun@igalia.com>

input.showPicker() should throw when input is readonly/disabled
https://bugs.webkit.org/show_bug.cgi?id=240302

Reviewed by Tim Nguyen.

When input is readonly or disabled, input.showPicker() should throw InvalidStateError.

Test: imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::showPicker):

2022-05-13 Michael Catanzaro <mcatanzaro@redhat.com>

-Wreturn-type warning in PathOperation.cpp
@@ -1242,7 +1242,10 @@ ExceptionOr<void> HTMLInputElement::showPicker()
auto* frame = document().frame();
if (!frame)
return { };


if (isDisabledOrReadOnly())
return Exception { InvalidStateError, "Input showPicker() cannot be used on immutable controls."_s };

// In cross-origin iframes it should throw a "SecurityError" DOMException except on file and color. In same-origin iframes it should work fine.
// https://github.com/whatwg/html/issues/6909#issuecomment-917138991
if (!m_inputType->allowsShowPickerAcrossFrames()) {

0 comments on commit 00de4db

Please sign in to comment.