RESOLVED FIXED 87696
[FileAPI] Miss FileList test
https://bugs.webkit.org/show_bug.cgi?id=87696
Summary [FileAPI] Miss FileList test
Li Yin
Reported 2012-05-28 23:22:19 PDT
The FileList related test cases are missed, it's necessary to add the attribute test in LayoutTests.
Attachments
Patch (2.46 KB, patch)
2012-05-28 23:32 PDT, Li Yin
no flags
Patch (2.34 KB, patch)
2012-05-29 01:49 PDT, Li Yin
no flags
Patch (2.62 KB, patch)
2012-05-29 05:42 PDT, Li Yin
no flags
Patch (2.60 KB, patch)
2012-05-29 05:46 PDT, Li Yin
no flags
Li Yin
Comment 1 2012-05-28 23:32:25 PDT
Kinuko Yasuda
Comment 2 2012-05-29 01:07:00 PDT
Comment on attachment 144455 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144455&action=review Nice to see tests for this! (Drive-by comment, I'm not a reviewer) > LayoutTests/fast/files/file-list-test.html:16 > + debug("files.length: " + files.length); Might be nicer to use shouldBe() family to make expected values clearer?
Kentaro Hara
Comment 3 2012-05-29 01:17:14 PDT
Comment on attachment 144455 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144455&action=review The change looks OK. > LayoutTests/fast/files/file-list-test.html:17 > + debug("files.item(0): " + files.item(0)); Nit: Maybe we want to pass more than two files for testing? > LayoutTests/fast/files/file-list-test.html:32 > +function runTests() > +{ > + eventSender.beginDragWithFiles(['resources/UTF8.txt']); > + eventSender.mouseMoveTo(10, 10); > + eventSender.mouseUp(); > +} > + > +if (window.eventSender) { > + layoutTestController.dumpAsText(); > + window.onload = runTests; > +} I guess you can simplify the code. - You do not need to call layoutTestController.dumpAsText(). - You can write the <script> after </body>, by which you can avoid hooking window.onload.
Li Yin
Comment 4 2012-05-29 01:49:41 PDT
Li Yin
Comment 5 2012-05-29 01:51:42 PDT
(In reply to comment #2) > (From update of attachment 144455 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=144455&action=review > > Nice to see tests for this! (Drive-by comment, I'm not a reviewer) > > > LayoutTests/fast/files/file-list-test.html:16 > > + debug("files.length: " + files.length); > > Might be nicer to use shouldBe() family to make expected values clearer? Okay, thanks.
Li Yin
Comment 6 2012-05-29 01:52:52 PDT
(In reply to comment #3) > (From update of attachment 144455 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=144455&action=review > > The change looks OK. > > > LayoutTests/fast/files/file-list-test.html:17 > > + debug("files.item(0): " + files.item(0)); > > Nit: Maybe we want to pass more than two files for testing? Add two files in the List > > > LayoutTests/fast/files/file-list-test.html:32 > > +function runTests() > > +{ > > + eventSender.beginDragWithFiles(['resources/UTF8.txt']); > > + eventSender.mouseMoveTo(10, 10); > > + eventSender.mouseUp(); > > +} > > + > > +if (window.eventSender) { > > + layoutTestController.dumpAsText(); > > + window.onload = runTests; > > +} > > I guess you can simplify the code. > > - You do not need to call layoutTestController.dumpAsText(). > - You can write the <script> after </body>, by which you can avoid hooking window.onload. Simply the code, done. Thanks for your review.
Kentaro Hara
Comment 7 2012-05-29 01:55:52 PDT
Comment on attachment 144477 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144477&action=review > LayoutTests/fast/files/file-list-test.html:7 > +<input type="file" name="file" id="file" multiple onchange="onInputFileChange(this.files)"> Nit: name="file" and id="file" are not needed. > LayoutTests/fast/files/file-list-test.html:18 > + shouldBeTrue("files.item(0) instanceof File"); Also you can test files.item(0).name and files.item(1).name to check if the correct files are stored? shouldBeEqualToString('files.item(0).name', 'resources/UTF8.txt'); shouldBeEqualToString('files.item(1).name', 'resources/UTF8-2.txt'); > LayoutTests/fast/files/file-list-test.html:20 > + finishJSTest(); You can remove this.
Li Yin
Comment 8 2012-05-29 05:42:49 PDT
Li Yin
Comment 9 2012-05-29 05:46:41 PDT
Li Yin
Comment 10 2012-05-29 05:50:13 PDT
(In reply to comment #7) > (From update of attachment 144477 [details]) change="onInputFileChange(this.files)"> > > Nit: name="file" and id="file" are not needed. > Done > > LayoutTests/fast/files/file-list-test.html:18 > > + shouldBeTrue("files.item(0) instanceof File"); > > Also you can test files.item(0).name and files.item(1).name to check if the correct files are stored? > > shouldBeEqualToString('files.item(0).name', 'resources/UTF8.txt'); > shouldBeEqualToString('files.item(1).name', 'resources/UTF8-2.txt'); > Done. But it should be shouldBeEqualToString('files.item(0).name', 'UTF8.txt'); File.name is merely the name of the file, without path information :) > > LayoutTests/fast/files/file-list-test.html:20 > > + finishJSTest(); > > You can remove this. Done Thanks for your review.
Kentaro Hara
Comment 11 2012-05-29 06:09:36 PDT
Comment on attachment 144532 [details] Patch OK!
WebKit Review Bot
Comment 12 2012-05-29 09:18:11 PDT
Comment on attachment 144532 [details] Patch Clearing flags on attachment: 144532 Committed r118787: <http://trac.webkit.org/changeset/118787>
WebKit Review Bot
Comment 13 2012-05-29 09:18:16 PDT
All reviewed patches have been landed. Closing bug.
Jian Li
Comment 14 2012-05-29 11:20:13 PDT
Comment on attachment 144532 [details] Patch Thanks for adding test cases for FileList. Here're some minor comments that you could consider addressing them in another patch. View in context: https://bugs.webkit.org/attachment.cgi?id=144532&action=review > LayoutTests/fast/files/file-list-test.html:22 > + shouldBeNull("files.item(999)"); Could you please also add some more tests to cover the cases that 2, null, or undefined is passed as index. Please also test the scenario that no file is selected.
Alexey Proskuryakov
Comment 15 2012-05-29 13:28:03 PDT
EventSender.beginDragWithFiles is not supported by WebKitTestRunner. Skipped the test for WebKit2 in <http://trac.webkit.org/changeset/118825>.
Li Yin
Comment 16 2012-05-29 21:43:48 PDT
(In reply to comment #14) > (From update of attachment 144532 [details]) > Thanks for adding test cases for FileList. Here're some minor comments that you could consider addressing them in another patch. > > View in context: https://bugs.webkit.org/attachment.cgi?id=144532&action=review > > > LayoutTests/fast/files/file-list-test.html:22 > > + shouldBeNull("files.item(999)"); > > Could you please also add some more tests to cover the cases that 2, null, or undefined is passed as index. > There is a bug about the negative index, https://bugs.webkit.org/show_bug.cgi?id=77899 If we want to support negative index, I think the FileList.idl will be changed, and maybe the behavior will be different when the index is null, undefined.(I am not sure.) So, currently, I only cover the expected index. And it will be improved in the bug77899. > Please also test the scenario that no file is selected.
Note You need to log in before you can comment on or make changes to this bug.