RESOLVED FIXED 100085
fast/forms/file/input-file-write-files.html should cover correct setting value
https://bugs.webkit.org/show_bug.cgi?id=100085
Summary fast/forms/file/input-file-write-files.html should cover correct setting value
Li Yin
Reported 2012-10-23 01:08:59 PDT
When the files attribute is changed to be read only, the test is still passed, since it lacked verification of correct setting value.
Attachments
Patch (8.17 KB, patch)
2012-10-23 18:59 PDT, Li Yin
no flags
Patch (13.04 KB, patch)
2012-10-25 23:37 PDT, Li Yin
no flags
Patch (13.23 KB, patch)
2012-10-26 00:52 PDT, Li Yin
no flags
Patch (1.56 KB, patch)
2012-11-05 19:00 PST, Li Yin
no flags
Patch (1.62 KB, patch)
2012-11-06 00:06 PST, Li Yin
no flags
Patch (1.71 KB, patch)
2012-11-13 18:54 PST, Li Yin
no flags
Patch (1.79 KB, patch)
2012-11-13 19:04 PST, Li Yin
no flags
Alexey Proskuryakov
Comment 1 2012-10-23 13:48:05 PDT
(see discussion in big 99546)
Li Yin
Comment 2 2012-10-23 18:59:27 PDT
Li Yin
Comment 3 2012-10-23 19:50:14 PDT
Add Nico Weber to the list, because he designed the test.
Kentaro Hara
Comment 4 2012-10-25 00:07:07 PDT
Comment on attachment 170291 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=170291&action=review > LayoutTests/fast/forms/file/input-file-value.html:8 > +<div id="console"></div> Nit: This is not needed. > LayoutTests/fast/forms/file/input-file-value.html:24 > + file.value = "foo"; // should do nothing > + shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt"); > + shouldBe("file.files.length", "1"); > + > + file.value = ""; // clear FileList I don't fully understand the semantics of file.value. Why does file.value="foo" do nothing but file.value="" clears the file list? > LayoutTests/fast/forms/file/input-file-write-files.html:9 > +<div id="console"></div> Nit: This is not needed. > LayoutTests/fast/forms/file/input-file-write-files.html:28 > + file1.files = null; > + shouldBe("file1.files.length", "1"); > + shouldBeEqualToString("file1.files.item(0).name", "foo.txt"); > > -function handleDragOver(e) { > - e.stopPropagation(); > - e.preventDefault(); > + file1.files = file2.files; Ditto. Would you elaborate on the expected semantics of file.files?
Li Yin
Comment 5 2012-10-25 01:27:10 PDT
Comment on attachment 170291 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=170291&action=review >> LayoutTests/fast/forms/file/input-file-value.html:24 >> + file.value = ""; // clear FileList > > I don't fully understand the semantics of file.value. Why does file.value="foo" do nothing but file.value="" clears the file list? From Spec: http://dev.w3.org/html5/spec/single-page.html#dom-input-value-filename On setting, if the new value is the empty string, it must empty the list of selected files; otherwise, it must throw an InvalidStateError exception. In fact, currently WebKit can't throw exception when the value is not empty string. It should be a bug. >> LayoutTests/fast/forms/file/input-file-write-files.html:28 >> + file1.files = file2.files; > > Ditto. Would you elaborate on the expected semantics of file.files? This is a correct value setting, we need verify the files attribute is writable or not. If the files attribute is read only, the setting can't work correctly. This is the main improvement compared with the origin test.
Kentaro Hara
Comment 6 2012-10-25 01:48:59 PDT
OK. Then I would suggest: - Write a test so that it strictly follows the spec, even the test fails. - Just leave a FAIL line in the expected files. - For FAILed test cases, add a comment that explains the FAIL is intentional.
Li Yin
Comment 7 2012-10-25 01:56:53 PDT
Hi Kentaro, Thanks for your comments. Because the value attribute is not the key point of this bug. So I want to keep it unchanged. And I will file a new bug to track the value attribute issue. Do you think it is Okay?
Kentaro Hara
Comment 8 2012-10-25 02:00:19 PDT
(In reply to comment #7) > Hi Kentaro, > Thanks for your comments. > Because the value attribute is not the key point of this bug. So I want to keep it unchanged. > And I will file a new bug to track the value attribute issue. Do you think it is Okay? Makes sense, but I think it would make more sense to fix it in this bug. The key point of this bug should be clarifying how the actual behavior is (intentionally) different from the speced behavior.
Li Yin
Comment 9 2012-10-25 23:37:39 PDT
Li Yin
Comment 10 2012-10-25 23:39:54 PDT
(In reply to comment #8) > (In reply to comment #7) > > Hi Kentaro, > > Thanks for your comments. > > Because the value attribute is not the key point of this bug. So I want to keep it unchanged. > > And I will file a new bug to track the value attribute issue. Do you think it is Okay? > > Makes sense, but I think it would make more sense to fix it in this bug. The key point of this bug should be clarifying how the actual behavior is (intentionally) different from the speced behavior. Done. Please review the patch. Thanks in advance.
Kentaro Hara
Comment 11 2012-10-25 23:51:04 PDT
Comment on attachment 170828 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=170828&action=review > LayoutTests/fast/forms/file/input-file-write-files.html:28 > + file1.files = file2.files; > + shouldBe("file1.files.length", "1"); > + shouldBeEqualToString("file1.files.item(0).name", "bar.txt"); Just a confirmation: This behavior violates the spec, right? Then I would prefer writing the test like this: // This test fails. // 'files' attribute should be readonly in the spec (http://...) but is implemented as non-readonly in WebKit. // See discussion in https://bugs.webkit.org/show_bug.cgi?id=87154#c15. shouldBeEqualToString("file1.files.item(0).name", "foo.txt"); Just a confirmation: Other behaviors in your patch are conformed to the spec, right?
Li Yin
Comment 12 2012-10-26 00:31:39 PDT
(In reply to comment #11) > (From update of attachment 170828 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=170828&action=review > > > LayoutTests/fast/forms/file/input-file-write-files.html:28 > > + file1.files = file2.files; > > + shouldBe("file1.files.length", "1"); > > + shouldBeEqualToString("file1.files.item(0).name", "bar.txt"); > > Just a confirmation: This behavior violates the spec, right? Then I would prefer writing the test like this: Yes, this is the different from the Spec, but this change is internal, and it seems that W3C will change the spec. WebKit did the easier implementation. > > // This test fails. > // 'files' attribute should be readonly in the spec (http://...) but is implemented as non-readonly in WebKit. > // See discussion in https://bugs.webkit.org/show_bug.cgi?id=87154#c15. > shouldBeEqualToString("file1.files.item(0).name", "foo.txt"); If we implement like this, it will fail. According to implementation of WebKit, the setting function can work correctly. It should be shouldBeEqualToString("file1.files.item(0).name", "bar.txt"); > > > Just a confirmation: Other behaviors in your patch are conformed to the spec, right? Yes.
Kentaro Hara
Comment 13 2012-10-26 00:37:38 PDT
(In reply to comment #12) > > > LayoutTests/fast/forms/file/input-file-write-files.html:28 > > > + file1.files = file2.files; > > > + shouldBe("file1.files.length", "1"); > > > + shouldBeEqualToString("file1.files.item(0).name", "bar.txt"); > > > > Just a confirmation: This behavior violates the spec, right? Then I would prefer writing the test like this: > > Yes, this is the different from the Spec, but this change is internal, and it seems that W3C will change the spec. WebKit did the easier implementation. Understood. Would you write the situation as a comment in the test so that people won't get confused in the future again?
Li Yin
Comment 14 2012-10-26 00:52:37 PDT
Li Yin
Comment 15 2012-10-26 00:53:45 PDT
(In reply to comment #13) > (In reply to comment #12) > > > > LayoutTests/fast/forms/file/input-file-write-files.html:28 > > > > + file1.files = file2.files; > > > > + shouldBe("file1.files.length", "1"); > > > > + shouldBeEqualToString("file1.files.item(0).name", "bar.txt"); > > > > > > Just a confirmation: This behavior violates the spec, right? Then I would prefer writing the test like this: > > > > Yes, this is the different from the Spec, but this change is internal, and it seems that W3C will change the spec. WebKit did the easier implementation. > > Understood. Would you write the situation as a comment in the test so that people won't get confused in the future again? Done. Add the comments in test. Thanks.
Kentaro Hara
Comment 16 2012-10-26 00:55:40 PDT
Comment on attachment 170841 [details] Patch OK, thanks for the patch.
WebKit Review Bot
Comment 17 2012-10-26 03:18:29 PDT
Comment on attachment 170841 [details] Patch Clearing flags on attachment: 170841 Committed r132599: <http://trac.webkit.org/changeset/132599>
WebKit Review Bot
Comment 18 2012-10-26 03:18:34 PDT
All reviewed patches have been landed. Closing bug.
Xan Lopez
Comment 19 2012-11-05 02:03:55 PST
FWIW, this broke the GObject DOM bindings, since it made an incompatible change to the IDL file (exceptions don't break the JS API, but they do break GObject's, adding an extra GError parameter). Something similar happened a few weeks ago, see https://bugs.webkit.org/show_bug.cgi?id=91704
Li Yin
Comment 20 2012-11-05 19:00:45 PST
Reopening to attach new patch.
Li Yin
Comment 21 2012-11-05 19:00:53 PST
Li Yin
Comment 22 2012-11-05 19:04:32 PST
Fix the GObject bindings compatibility issue. Look: https://bugs.webkit.org/show_bug.cgi?id=91704#c19
Build Bot
Comment 23 2012-11-05 21:40:16 PST
Li Yin
Comment 24 2012-11-06 00:06:55 PST
Kentaro Hara
Comment 25 2012-11-06 00:54:07 PST
Comment on attachment 172501 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=172501&action=review > Source/WebCore/html/HTMLInputElement.idl:63 > +#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT > [TreatNullAs=NullString] attribute DOMString value setter raises(DOMException); > +#else > + [TreatNullAs=NullString] attribute DOMString value; > +#endif Does this mean that GObject cannot handle any IDL attribute that can raise exceptions? If that's the case, it would make more sense to skip raising exceptions in CodeGeneratorGObject.pm, rather than surrounding all IDL attributes with #if macro.
Li Yin
Comment 26 2012-11-06 04:15:49 PST
(In reply to comment #25) > (From update of attachment 172501 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=172501&action=review > > > Source/WebCore/html/HTMLInputElement.idl:63 > > +#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT > > [TreatNullAs=NullString] attribute DOMString value setter raises(DOMException); > > +#else > > + [TreatNullAs=NullString] attribute DOMString value; > > +#endif > > Does this mean that GObject cannot handle any IDL attribute that can raise exceptions? If that's the case, it would make more sense to skip raising exceptions in CodeGeneratorGObject.pm, rather than surrounding all IDL attributes with #if macro. I don't think that is true, because there are still other attributes that can raise exceptions, such as setRangeText, https://trac.webkit.org/browser/trunk/Source/WebCore/html/HTMLInputElement.idl#L82
Kentaro Hara
Comment 27 2012-11-06 04:17:45 PST
(In reply to comment #26) > I don't think that is true, because there are still other attributes that can raise exceptions, such as setRangeText, https://trac.webkit.org/browser/trunk/Source/WebCore/html/HTMLInputElement.idl#L82 Then what's the difference between HTMLInputElement.value and setRangeText? (We don't want to mess up IDL files by inserting macros.)
Li Yin
Comment 28 2012-11-06 04:31:30 PST
(In reply to comment #27) > (In reply to comment #26) > > I don't think that is true, because there are still other attributes that can raise exceptions, such as setRangeText, https://trac.webkit.org/browser/trunk/Source/WebCore/html/HTMLInputElement.idl#L82 > > Then what's the difference between HTMLInputElement.value and setRangeText? (We don't want to mess up IDL files by inserting macros.) I am also confused about it, maybe setValue have two function definitions in HTMLInputElement.h, one can raise exception, another one can not. I think this is the only difference. I am unfamiliar with GObject binding related code, and expect experts' words.
Kentaro Hara
Comment 29 2012-11-06 04:37:53 PST
(In reply to comment #19) > FWIW, this broke the GObject DOM bindings, since it made an incompatible change to the IDL file (exceptions don't break the JS API, but they do break GObject's, adding an extra GError parameter). Something similar happened a few weeks ago, see https://bugs.webkit.org/show_bug.cgi?id=91704 I read bug 91704 and remembered the problem... Xan Lopez: The problem is that this change breaks GObject API's compatibility, right? If that's the case, as discussed in bug 91704, it would look reasonable to avoid the problem by #if macro in IDL files.
Xan Lopez
Comment 30 2012-11-13 00:43:52 PST
(In reply to comment #29) > > I read bug 91704 and remembered the problem... > > Xan Lopez: The problem is that this change breaks GObject API's compatibility, right? If that's the case, as discussed in bug 91704, it would look reasonable to avoid the problem by #if macro in IDL files. Yes, exactly. The problem is not that we cannot handle exceptions (we can!), but that this was changed in an incompatible way in an API that is exported. The attached patch would of course fix the issue, assuming it is correct to have variations in the IDL like this. Thanks for quick replies (this somehow fell through the cracks in my inbox!).
Alexey Proskuryakov
Comment 31 2012-11-13 08:22:19 PST
> assuming it is correct to have variations in the IDL like this. Yes, I think so. I'd put an explanatory comment though - some people might incorrectly assume that the difference is due to Objective C bindings. Preserving existing behavior for those may be important too, so I'm not asking to limit this fix to Gtk.
Li Yin
Comment 32 2012-11-13 17:08:35 PST
(In reply to comment #31) > > assuming it is correct to have variations in the IDL like this. > > Yes, I think so. I'd put an explanatory comment though - some people might incorrectly assume that the difference is due to Objective C bindings. Preserving existing behavior for those may be important too, so I'm not asking to limit this fix to Gtk. Thanks for your explanation. Kentaro: Could you please have a look again? Thanks in advance.
Kentaro Hara
Comment 33 2012-11-13 17:11:14 PST
Comment on attachment 172501 [details] Patch Looks reasonable. As ap commented, please add a comment about the situation before landing.
Li Yin
Comment 34 2012-11-13 18:54:53 PST
Li Yin
Comment 35 2012-11-13 18:56:06 PST
(In reply to comment #33) > (From update of attachment 172501 [details]) > Looks reasonable. As ap commented, please add a comment about the situation before landing. Fixed. Thanks.
Kentaro Hara
Comment 36 2012-11-13 18:58:12 PST
Comment on attachment 174049 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=174049&action=review > Source/WebCore/html/HTMLInputElement.idl:59 > +#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT Would you add a comment on this line, adding a link to the discussion in bugzilla?
Li Yin
Comment 37 2012-11-13 19:04:30 PST
Li Yin
Comment 38 2012-11-13 19:21:38 PST
(In reply to comment #36) > (From update of attachment 174049 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=174049&action=review > > > Source/WebCore/html/HTMLInputElement.idl:59 > > +#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT > > Would you add a comment on this line, adding a link to the discussion in bugzilla? Done. Thanks.
Kentaro Hara
Comment 39 2012-11-13 19:34:04 PST
Comment on attachment 174050 [details] Patch ok
WebKit Review Bot
Comment 40 2012-11-13 21:35:43 PST
Comment on attachment 174050 [details] Patch Clearing flags on attachment: 174050 Committed r134538: <http://trac.webkit.org/changeset/134538>
WebKit Review Bot
Comment 41 2012-11-13 21:35:50 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.