Bug 793460 - Implement File.lastModifiedDate. r=khuey

--HG--
extra : rebase_source : 6ca1c139896f47de428a430e731d39125a0f0435
This commit is contained in:
Andrea Marchesini 2012-11-04 07:19:00 -08:00
parent bdcaabf99f
commit 012feb0947
3 changed files with 21 additions and 0 deletions

View File

@ -349,6 +349,23 @@ private:
aVp.set(STRING_TO_JSVAL(jsName));
return true;
}
static JSBool
GetLastModifiedDate(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSMutableHandleValue aVp)
{
nsIDOMFile* file = GetInstancePrivate(aCx, aObj, "lastModifiedDate");
if (!file) {
return false;
}
JS::Value value;
if (NS_FAILED(file->GetLastModifiedDate(aCx, &value))) {
return false;
}
aVp.set(value);
return true;
}
};
JSClass File::sClass = {
@ -361,6 +378,8 @@ JSClass File::sClass = {
JSPropertySpec File::sProperties[] = {
{ "name", 0, PROPERTY_FLAGS, JSOP_WRAPPER(GetName),
JSOP_WRAPPER(js_GetterOnlyPropertyStub) },
{ "lastModifiedDate", 0, PROPERTY_FLAGS, JSOP_WRAPPER(GetLastModifiedDate),
JSOP_WRAPPER(js_GetterOnlyPropertyStub) },
{ "mozFullPath", 0, PROPERTY_FLAGS, JSOP_WRAPPER(GetMozFullPath),
JSOP_WRAPPER(js_GetterOnlyPropertyStub) },
{ 0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER }

View File

@ -9,6 +9,7 @@ onmessage = function(event) {
rtnObj.size = file.size;
rtnObj.type = file.type;
rtnObj.name = file.name;
rtnObj.lastModifiedDate = file.lastModifiedDate;
rtnObj.mozFullPath = file.mozFullPath;
postMessage(rtnObj);

View File

@ -69,6 +69,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=123456
is(event.data.size, expectedSize, "size proproperty accessed from worker is not the same as on main thread.");
is(event.data.type, expectedType, "type proproperty accessed from worker is incorrect.");
is(event.data.name, file.name, "name proproperty accessed from worker is incorrect.");
is(event.data.lastModifiedDate.toString(), file.lastModifiedDate.toString(), "lastModifiedDate proproperty accessed from worker is incorrect.");
is(event.data.mozFullPath, file.mozFullPath, "mozFullPath proproperty accessed from worker is not the same as on main thread.");
finish();
};