From 012feb0947b22d76ceeccc5c3444469b7d077356 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Sun, 4 Nov 2012 07:19:00 -0800 Subject: [PATCH] Bug 793460 - Implement File.lastModifiedDate. r=khuey --HG-- extra : rebase_source : 6ca1c139896f47de428a430e731d39125a0f0435 --- dom/workers/File.cpp | 19 +++++++++++++++++++ dom/workers/test/file_worker.js | 1 + dom/workers/test/test_file.xul | 1 + 3 files changed, 21 insertions(+) diff --git a/dom/workers/File.cpp b/dom/workers/File.cpp index 532f01b9efa..674fc9d9236 100644 --- a/dom/workers/File.cpp +++ b/dom/workers/File.cpp @@ -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 } diff --git a/dom/workers/test/file_worker.js b/dom/workers/test/file_worker.js index a0043ef22d5..92880ffcd8a 100644 --- a/dom/workers/test/file_worker.js +++ b/dom/workers/test/file_worker.js @@ -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); diff --git a/dom/workers/test/test_file.xul b/dom/workers/test/test_file.xul index f5c31e06d4a..e3943c7a672 100644 --- a/dom/workers/test/test_file.xul +++ b/dom/workers/test/test_file.xul @@ -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(); };