RESOLVED FIXED 87709
File.lastModifiedDate must return null if the modified time info is not available
https://bugs.webkit.org/show_bug.cgi?id=87709
Summary File.lastModifiedDate must return null if the modified time info is not avail...
Kinuko Yasuda
Reported 2012-05-29 01:44:41 PDT
File.lastModifiedDate must return null if the modified time info is not available. http://dev.w3.org/2006/webapi/FileAPI/#dfn-lastModifiedDate "The last modified date of the file. On getting, if user agents can make this information available, this MUST return a new Date[HTML] object initialized to the last modified date of the file; otherwise, this MUST return null."
Attachments
Patch (22.10 KB, patch)
2012-05-29 01:58 PDT, Kinuko Yasuda
no flags
Patch (22.56 KB, patch)
2012-05-29 02:07 PDT, Kinuko Yasuda
no flags
Archive of layout-test-results from ec2-cr-linux-01 (838.62 KB, application/zip)
2012-05-29 05:04 PDT, WebKit Review Bot
no flags
fixed one-char typo (21.58 KB, patch)
2012-05-29 05:25 PDT, Kinuko Yasuda
no flags
Patch (11.77 KB, patch)
2012-05-30 02:20 PDT, Kinuko Yasuda
no flags
adding why comment (1.72 KB, patch)
2012-05-31 00:14 PDT, Kinuko Yasuda
no flags
Kinuko Yasuda
Comment 1 2012-05-29 01:58:31 PDT
Kinuko Yasuda
Comment 2 2012-05-29 02:07:23 PDT
Kinuko Yasuda
Comment 3 2012-05-29 02:11:41 PDT
I'm slightly separated if I should use custom binding for this one. (Date(0) itself is totally valid while conventionally we use the value 0 to indicate 'null' value in File and elsewhere in webkit)
Kentaro Hara
Comment 4 2012-05-29 02:11:45 PDT
Comment on attachment 144484 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144484&action=review r+ for IDL, V8 bindings, and JSC bindings. We want to avoid custom bindings, but it seems unavoidable. > Source/WebCore/ChangeLog:10 > + Per File API spec, File.lastModifiedDate must return null if the > + modified time info is not available. > + http://dev.w3.org/2006/webapi/FileAPI/#dfn-lastModifiedDate What's the behavior of other browsers?
Kinuko Yasuda
Comment 5 2012-05-29 02:43:24 PDT
(In reply to comment #4) > (From update of attachment 144484 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=144484&action=review > > r+ for IDL, V8 bindings, and JSC bindings. We want to avoid custom bindings, but it seems unavoidable. > > > Source/WebCore/ChangeLog:10 > > + Per File API spec, File.lastModifiedDate must return null if the > > + modified time info is not available. > > + http://dev.w3.org/2006/webapi/FileAPI/#dfn-lastModifiedDate > > What's the behavior of other browsers? Safari 5.1 behaves in the same way as the current chrome does (i.e. returns "Jan 01 1970" date/time if unavailable), and as far as I checked FireFox/IE don't support it yet. [Some more note: there's ongoing discussion to make 'lastModifiedDate' attribute static, and in that case this test will become invalid as we will be returning the same date/time without querying (I'll deprecate this test then), but the change itself should remain valid since there will still be a chance where 'lastModifiedDate' is not available when we capture file metadata]
Kentaro Hara
Comment 6 2012-05-29 02:49:33 PDT
Comment on attachment 144484 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144484&action=review >>> Source/WebCore/ChangeLog:10 >>> + http://dev.w3.org/2006/webapi/FileAPI/#dfn-lastModifiedDate >> >> What's the behavior of other browsers? > > Safari 5.1 behaves in the same way as the current chrome does (i.e. returns "Jan 01 1970" date/time if unavailable), and as far as I checked FireFox/IE don't support it yet. > [Some more note: there's ongoing discussion to make 'lastModifiedDate' attribute static, and in that case this test will become invalid as we will be returning the same date/time without querying (I'll deprecate this test then), but the change itself should remain valid since there will still be a chance where 'lastModifiedDate' is not available when we capture file metadata] Thank you very much for the clarification. The change looks reasonable.
WebKit Review Bot
Comment 7 2012-05-29 05:04:50 PDT
Comment on attachment 144484 [details] Patch Attachment 144484 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12853227 New failing tests: http/tests/local/fileapi/file-last-modified-after-delete.html
WebKit Review Bot
Comment 8 2012-05-29 05:04:55 PDT
Created attachment 144527 [details] Archive of layout-test-results from ec2-cr-linux-01 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-01 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Kinuko Yasuda
Comment 9 2012-05-29 05:25:13 PDT
Created attachment 144528 [details] fixed one-char typo
Darin Adler
Comment 10 2012-05-29 13:17:22 PDT
Comment on attachment 144528 [details] fixed one-char typo Seems like it would be better to use a separate boolean or a NaN to represent the fact that a date is not available rather than using the number 0. Generally speaking, instead of a custom binding, I’d like to see our binding machinery support this ability to return null for a date, perhaps by having the date-returning internal DOM functions return a boolean and use an out argument for the date, or something else along those lines.
Kentaro Hara
Comment 11 2012-05-29 21:53:45 PDT
Comment on attachment 144528 [details] fixed one-char typo View in context: https://bugs.webkit.org/attachment.cgi?id=144528&action=review > Source/WebCore/bindings/v8/custom/V8FileCustom.cpp:45 > + return v8DateOrNull(modifiedDate); Just right now I've landed a patch to pass Isolate to v8DateOrNull(). Please change this to v8DateOrNull(modifiedDate, info.GetIsolate()). (Though please consider if we could kill the custom bindings as darin@ pointed out.)
Kinuko Yasuda
Comment 12 2012-05-29 23:28:26 PDT
(In reply to comment #10) > (From update of attachment 144528 [details]) > Seems like it would be better to use a separate boolean or a NaN to represent the fact that a date is not available rather than using the number 0. I have considered using NaN, but I was afraid NaN may not be really portable (though I just found that both js and v8 code use numeric_limits<>::quiet_NaN without any guards so it looks to be ok to assume we can use it) and we need to change all related code to take care of NaN specifically. > Generally speaking, instead of a custom binding, I’d like to see our binding machinery support this ability to return null for a date, perhaps by having the date-returning internal DOM functions return a boolean and use an out argument for the date, or something else along those lines. Sounds reasonable. Since current code assumes 0 is uninitialized value not only in File but at several places I'd like to land this one for now (with haraken's v8DateOrNull update) but file a new bug to track the Date issue.
Kinuko Yasuda
Comment 13 2012-05-29 23:39:16 PDT
(In reply to comment #12) > (In reply to comment #10) > > (From update of attachment 144528 [details] [details]) > > Seems like it would be better to use a separate boolean or a NaN to represent the fact that a date is not available rather than using the number 0. > > I have considered using NaN, but I was afraid NaN may not be really portable (though I just found that both js and v8 code use numeric_limits<>::quiet_NaN without any guards so it looks to be ok to assume we can use it) and we need to change all related code to take care of NaN specifically. > > > Generally speaking, instead of a custom binding, I’d like to see our binding machinery support this ability to return null for a date, perhaps by having the date-returning internal DOM functions return a boolean and use an out argument for the date, or something else along those lines. > > Sounds reasonable. Since current code assumes 0 is uninitialized value not only in File but at several places I'd like to land this one for now (with haraken's v8DateOrNull update) but file a new bug to track the Date issue. Filed a separate bug for the Date issue: http://webkit.org/b/87826
Kinuko Yasuda
Comment 14 2012-05-30 02:20:46 PDT
Kentaro Hara
Comment 15 2012-05-30 02:25:56 PDT
Comment on attachment 144761 [details] Patch This is a great idea. Maybe we can reduce other custom bindings by using the ImplementedAs trick:)
Kinuko Yasuda
Comment 16 2012-05-30 02:35:42 PDT
Thanks, credit goes to tkent-san :D I'll be submitting if the test looks ok.
WebKit Review Bot
Comment 17 2012-05-30 06:57:51 PDT
Comment on attachment 144761 [details] Patch Clearing flags on attachment: 144761 Committed r118920: <http://trac.webkit.org/changeset/118920>
WebKit Review Bot
Comment 18 2012-05-30 06:57:57 PDT
All reviewed patches have been landed. Closing bug.
Alexey Proskuryakov
Comment 19 2012-05-30 11:47:28 PDT
Skipped http/tests/local/fileapi/file-last-modified-after-delete.html on WK2, because beginDragWithFiles is not implemented there.
Darin Adler
Comment 20 2012-05-30 12:45:33 PDT
Comment on attachment 144761 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144761&action=review > Source/WebCore/fileapi/File.cpp:148 > + double value = lastModifiedDate(); > + return (!value) ? std::numeric_limits<double>::quiet_NaN() : value; This needs a why comment. The comment in File.h is not all that useful, but it would be here where the code is doing this. My comment would be something like this: // The lastModifiedDate function uses 0 to represent a failure, but the DOM uses a JavaScript null. // Our JavaScript DOM binding maps NaN to JavaScript null, so we need to map 0 to NaN. // FIXME: If we used NaN instead of 0 to represent the lack of a modification time, then we would not need this any more.
Kinuko Yasuda
Comment 21 2012-05-31 00:14:11 PDT
Created attachment 145003 [details] adding why comment
Kinuko Yasuda
Comment 22 2012-05-31 00:15:25 PDT
(In reply to comment #20) > (From update of attachment 144761 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=144761&action=review > > > Source/WebCore/fileapi/File.cpp:148 > > + double value = lastModifiedDate(); > > + return (!value) ? std::numeric_limits<double>::quiet_NaN() : value; > > This needs a why comment. The comment in File.h is not all that useful, but it would be here where the code is doing this. My comment would be something like this: > > // The lastModifiedDate function uses 0 to represent a failure, but the DOM uses a JavaScript null. > // Our JavaScript DOM binding maps NaN to JavaScript null, so we need to map 0 to NaN. > // FIXME: If we used NaN instead of 0 to represent the lack of a modification time, then we would not need this any more. Uploaded a separate tiny patch to add the comment. https://bugs.webkit.org/attachment.cgi?id=145003
Kinuko Yasuda
Comment 23 2012-05-31 01:00:40 PDT
Reopening until the comment fix gets in.
Kinuko Yasuda
Comment 24 2012-06-06 04:17:05 PDT
Comment on attachment 145003 [details] adding why comment Addressing this issue in https://bugs.webkit.org/show_bug.cgi?id=87826 rather than fixing the comment.
Note You need to log in before you can comment on or make changes to this bug.