The default bug view has changed. See this FAQ.

Implement lastModifiedDate property for the File interface

RESOLVED FIXED in mozilla15

Status

()

Core
DOM
RESOLVED FIXED
6 years ago
4 years ago

People

(Reporter: sonny, Assigned: dougt)

Tracking

({dev-doc-complete})

Trunk
mozilla15
dev-doc-complete
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20100101 Firefox/5.0
Build ID: 20110619063910




Expected results:

According to http://www.w3.org/TR/FileAPI/#dfn-file the file interface should have a lastModifiedDate property.

Updated

6 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Other → All
Keywords: dev-doc-needed

Comment 1

5 years ago
FWIW this crashes sample file upload code that works just fine w/Chrome; would be nice to have this working! :)
(Assignee)

Updated

5 years ago
Assignee: nobody → doug.turner
(Assignee)

Comment 2

5 years ago
Created attachment 625670 [details] [diff] [review]
patch v.1
Attachment #625670 - Flags: review?(mounir)
Comment on attachment 625670 [details] [diff] [review]
patch v.1

Review of attachment 625670 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with the comments applied.

::: content/base/src/nsDOMFile.cpp
@@ +130,5 @@
>  
>  NS_IMETHODIMP
> +nsDOMFileBase::GetLastModifiedDate(JSContext* cx, JS::Value *aLastModifiedDate)
> +{
> +  *aLastModifiedDate = JSVAL_NULL;

Please do this instead:
aLastModifiedDate->setNull();

@@ +131,5 @@
>  NS_IMETHODIMP
> +nsDOMFileBase::GetLastModifiedDate(JSContext* cx, JS::Value *aLastModifiedDate)
> +{
> +  *aLastModifiedDate = JSVAL_NULL;
> +  return NS_OK;

I would whether throw NS_ERROR_NOT_IMPLEMENTED or call NS_ASSERTION. Or both even ;)

@@ +427,5 @@
>  NS_IMETHODIMP
> +nsDOMFileFile::GetLastModifiedDate(JSContext* cx, JS::Value *aLastModifiedDate)
> +{
> +  PRTime msecs;
> +  mFile->GetLastModifiedTime(&msecs);

AFAICT, this is returning a PRInt64 not PRTime. I know PRTime is typedef to PRInt64 but still...

@@ +430,5 @@
> +  PRTime msecs;
> +  mFile->GetLastModifiedTime(&msecs);
> +  JSObject* date = JS_NewDateObjectMsec(cx, msecs);
> +  if (date) {
> +    *aLastModifiedDate = OBJECT_TO_JSVAL(date);

aLastModifiedDate->setObject(date);

@@ +433,5 @@
> +  if (date) {
> +    *aLastModifiedDate = OBJECT_TO_JSVAL(date);
> +  }
> +  else {
> +    *aLastModifiedDate = JSVAL_NULL;

aLastModifieddate->setNull();

::: content/base/test/test_bug403852.html
@@ +33,5 @@
>  var domFile = fileList.files[0];
>  
>  is(domFile.name, "prefs.js", "fileName should be prefs.js");
>  
> +ok(domFile.lastModifiedDate, "lastModifiedDate must be present");

ok("lastModifiedDate" in domFile, "...") would be better.

@@ +34,5 @@
>  
>  is(domFile.name, "prefs.js", "fileName should be prefs.js");
>  
> +ok(domFile.lastModifiedDate, "lastModifiedDate must be present");
> +var d = new Date(testFile.lastModifiedTime);

nit: can you move that line with the block below.
Attachment #625670 - Flags: review?(mounir) → review+
(Assignee)

Comment 4

5 years ago
>  this is returning a PRInt64 not PRTime. I know PRTime is typedef to PRInt64 but still...

They are typed the same per docs.


> I would whether throw NS_ERROR_NOT_IMPLEMENTED or call NS_ASSERTION. Or both even ;)

I am not sure what we should do here.  Maybe ask Jonas (the editor?) and followup.


https://hg.mozilla.org/integration/mozilla-inbound/rev/877e541590c2
(Assignee)

Comment 5

5 years ago
PRTime followup:
  https://hg.mozilla.org/integration/mozilla-inbound/rev/09b1b0fe568a
https://hg.mozilla.org/mozilla-central/rev/877e541590c2
https://hg.mozilla.org/mozilla-central/rev/09b1b0fe568a
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla15
Comment on attachment 625670 [details] [diff] [review]
patch v.1

Review of attachment 625670 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/base/src/nsDOMFile.cpp
@@ +434,5 @@
> +    *aLastModifiedDate = OBJECT_TO_JSVAL(date);
> +  }
> +  else {
> +    *aLastModifiedDate = JSVAL_NULL;
> +  }

Actually, aLastModifieddate->setObjectOrNull(date);
Depends on: 793459, 793460
Duplicate of this bug: 390776

Comment 9

4 years ago
https://developer.mozilla.org/en-US/docs/Firefox_15_for_developers
https://developer.mozilla.org/en-US/docs/DOM/File
https://developer.mozilla.org/en-US/docs/DOM/File.lastModifiedDate
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.