RESOLVED FIXED 237192
[InputElement] Add HTMLInputElement::showPicker() method
https://bugs.webkit.org/show_bug.cgi?id=237192
Summary [InputElement] Add HTMLInputElement::showPicker() method
zsun
Reported 2022-02-25 01:34:42 PST
Spec discussions - https://github.com/whatwg/html/issues/6909 Affected WPT tests - imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-cross-origin-iframe.html imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker.html
Attachments
Patch (26.93 KB, patch)
2022-02-25 02:12 PST, zsun
no flags
Patch (57.89 KB, patch)
2022-02-25 08:15 PST, zsun
no flags
Patch (144.55 KB, patch)
2022-02-28 12:26 PST, zsun
no flags
Patch (144.51 KB, patch)
2022-03-11 02:00 PST, zsun
no flags
Patch (141.83 KB, patch)
2022-03-15 04:20 PDT, zsun
no flags
Patch (145.22 KB, patch)
2022-03-22 03:51 PDT, zsun
no flags
Patch (145.10 KB, patch)
2022-03-22 06:24 PDT, zsun
no flags
zsun
Comment 1 2022-02-25 02:12:43 PST
zsun
Comment 2 2022-02-25 08:15:52 PST
Darin Adler
Comment 3 2022-02-27 08:21:53 PST
Need to rebase more progressed tests, at least web-platform-tests/html/dom/idlharness.https.html. I’ll wait to review until after that.
zsun
Comment 4 2022-02-28 12:26:57 PST
Darin Adler
Comment 5 2022-02-28 13:15:12 PST
Comment on attachment 453414 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453414&action=review > Source/WebCore/html/ColorInputType.h:69 > + void openPopupView() final; WebCore::Chrome calls this operation "run the open panel", now this new function calls it "open the pop-up view", and the new public DOM standard function calls it "show the picker". I don’t think it’s valuable to have three different sets of terminology for this in WebKit. Can we get closer to one set of terminology? I don’t mind changing the existing ones if they should be changed. I’d prefer that this function not use a third term, if we can avoid it, unless there’s an important distinction we are expressing. > Source/WebCore/html/HTMLInputElement.cpp:1298 > + return Exception { SecurityError, "HTMLInputElement::showPicker() called from cross-origin iframe." }; Is this the format that we use for function names in these kinds of exceptions? HTMLInputElement::showPicker() looks natural to a C++ programmer, but maybe not so much to a web programmer using JavaScript?
Radar WebKit Bug Importer
Comment 6 2022-03-04 01:35:17 PST
zsun
Comment 7 2022-03-11 02:00:32 PST
Darin Adler
Comment 8 2022-03-14 15:40:29 PDT
Comment on attachment 454459 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=454459&action=review review- because of the incorrect handling of null frame > Source/WebCore/html/HTMLInputElement.cpp:1278 > + if (!m_inputType->isFileUpload() && !m_inputType->isColorControl() && frame) { Normally we would add a function to InputType for something like this named something like allowsShowPickerAcrossFrames. > Source/WebCore/html/HTMLInputElement.cpp:1284 > + auto* window = frame->window(); The code above checks frame for null, but then this deferences frame without a null check. I suggest we consider an early exit to silently and do nothing when the frame is null. Or treat a null frame the same as a null window perhaps.
zsun
Comment 9 2022-03-15 04:20:19 PDT
zsun
Comment 10 2022-03-21 11:56:00 PDT
(In reply to Darin Adler from comment #8) > Comment on attachment 454459 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=454459&action=review > > review- because of the incorrect handling of null frame > > > Source/WebCore/html/HTMLInputElement.cpp:1278 > > + if (!m_inputType->isFileUpload() && !m_inputType->isColorControl() && frame) { > > Normally we would add a function to InputType for something like this named > something like allowsShowPickerAcrossFrames. > > > Source/WebCore/html/HTMLInputElement.cpp:1284 > > + auto* window = frame->window(); > > The code above checks frame for null, but then this deferences frame without > a null check. I suggest we consider an early exit to silently and do nothing > when the frame is null. Or treat a null frame the same as a null window > perhaps. Thanks very much for the suggestions. The review comments have been addressed. PTAL. Thank you.
Darin Adler
Comment 11 2022-03-21 12:23:25 PDT
Comment on attachment 454691 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=454691&action=review Looks really good, but still some sticking points, sadly. > Source/WebCore/html/HTMLInputElement.cpp:1279 > + m_inputType->allowsShowPickerAcrossFrames(); This isn’t checking the result and returning it. Needs to be more like this: if (auto result = m_inputType->allowsShowPickerAcrossFrames(); result.hasException()) return result; And, we need to add test cases for this. The fact that no tests failed proves we aren’t covering this with tests at all. > Source/WebCore/html/InputType.cpp:520 > +ExceptionOr<void> InputType::allowsShowPickerAcrossFrames() What I was referring to was a boolean-returning "allowsShowPickerAcrossFrames" function overridden by file upload and color controls. So there is no isFileUpload and isColorControl function call. Would you consider that? I did *not* mean that all of this logic would be moved into the InputType base class.
zsun
Comment 12 2022-03-22 03:51:56 PDT
Darin Adler
Comment 13 2022-03-22 05:21:14 PDT
Comment on attachment 455360 [details] Patch Looks good although it needs to be rebased. Now I am confused, though, about how showPicker needs cross frame checks for everything except file and color, but is only implemented for file and color. So what are the cases where showPicker needs to forbid cross-frame access, and how are we testing those cases? Is it about preparation for some future expansion?
zsun
Comment 14 2022-03-22 06:24:05 PDT
zsun
Comment 15 2022-03-22 06:42:52 PDT
(In reply to Darin Adler from comment #13) > Comment on attachment 455360 [details] > Patch > > Looks good although it needs to be rebased. Now I am confused, though, about > how showPicker needs cross frame checks for everything except file and > color, but is only implemented for file and color. So what are the cases > where showPicker needs to forbid cross-frame access, and how are we testing > those cases? Is it about preparation for some future expansion? Maybe check the top message (from @domenic) at https://github.com/whatwg/html/pull/7319#discussion_r759633854?
Darin Adler
Comment 16 2022-03-22 07:46:49 PDT
Read that, and that top message indicates that in *Chrome* they have other pickers besides these two. So the code makes sense assuming it was written *for* Chromium. In WebKit at the moment, it's dead code, untested and nearly untestable. Could test it because it presumably manifests as a slightly different exception when you call this on an input that has no picker. I’m not sure it’s great to have this dead code in WebKit, but not super harmful either.
Darin Adler
Comment 17 2022-03-23 04:42:19 PDT
Comment on attachment 455368 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=455368&action=review > Source/WebCore/ChangeLog:6 > + Reviewed by Darin Adler. Stray space here
EWS
Comment 18 2022-03-23 04:53:16 PDT
Committed r291742 (248774@main): <https://commits.webkit.org/248774@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 455368 [details].
Darin Adler
Comment 19 2022-03-23 08:06:01 PDT
One more clarification we need here: Is it correct that when called on an HTMLInputElement of a type that has no picker, that showPicker should check cross-frame and user gesture status, throw exceptions if either of those applies, but then if neither applies, silently do nothing? That is the behavior we currently have implemented. Is that what we intend?
zsun
Comment 20 2022-03-23 08:41:35 PDT
(In reply to Darin Adler from comment #19) > One more clarification we need here: > > Is it correct that when called on an HTMLInputElement of a type that has no > picker, that showPicker should check cross-frame and user gesture status, > throw exceptions if either of those applies, but then if neither applies, > silently do nothing? > > That is the behavior we currently have implemented. Is that what we intend? As per the first two points at https://github.com/whatwg/html/issues/6909#issuecomment-956747809, I guess it's intentional?
Darin Adler
Comment 21 2022-03-23 08:48:40 PDT
No, the comment talks about actually showing pickers. What I am asking about is where we do the cross-frame and user gesture checks, but then do *nothing* and do not show a picker. Doing nothing is not the same as showing a picker.
zsun
Comment 22 2022-03-23 09:08:27 PDT
(In reply to Darin Adler from comment #21) > No, the comment talks about actually showing pickers. What I am asking about > is where we do the cross-frame and user gesture checks, but then do > *nothing* and do not show a picker. Doing nothing is not the same as showing > a picker. I'm not sure for the moment. Let me check on it.
zsun
Comment 23 2022-03-24 02:31:14 PDT
*** Bug 234009 has been marked as a duplicate of this bug. ***
zsun
Comment 25 2022-03-24 10:11:00 PDT
(In reply to Darin Adler from comment #21) > No, the comment talks about actually showing pickers. What I am asking about > is where we do the cross-frame and user gesture checks, but then do > *nothing* and do not show a picker. Doing nothing is not the same as showing > a picker. According to https://github.com/whatwg/html/issues/6909#issuecomment-1077776931, it seems that doing nothing is the intention.
Darin Adler
Comment 26 2022-03-24 11:32:59 PDT
OK, thanks for following up with the others on this.
Domenic Denicola
Comment 27 2022-03-31 09:48:54 PDT
FYI we are planning to make this method throw for non-mutable controls: see https://github.com/whatwg/html/issues/7767 and https://github.com/whatwg/html/pull/7769 . I will file a separate WebKit bug once the spec PR is reviewed and merged; by that time we will likely have web platform tests ready as well.
Tim Nguyen (:ntim)
Comment 28 2022-06-08 03:21:13 PDT
*** Bug 234009 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.