Commit 6d5a411f authored by jianli@chromium.org's avatar jianli@chromium.org
Browse files

Add lastModifiedDate attribute to File interface per File API spec

https://bugs.webkit.org/show_bug.cgi?id=49895

Reviewed by David Levin.

WebCore:

lastModifiedDate is not supported for GObject bindings because Date is
not support in code generation.

Test: http/tests/local/fileapi/file-last-modified.html

* fileapi/File.cpp:
(WebCore::File::lastModifiedDate):
* fileapi/File.h:
* fileapi/File.idl:

LayoutTests:

* http/tests/local/fileapi/file-last-modified-expected.txt: Added.
* http/tests/local/fileapi/file-last-modified.html: Added.
* http/tests/local/fileapi/script-tests/file-last-modified.js: Added.
* http/tests/resources/file-last-modified.php: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c84a1d48
2010-12-20 Jian Li <jianli@chromium.org>
Reviewed by David Levin.
Add lastModifiedDate attribute to File interface per File API spec
https://bugs.webkit.org/show_bug.cgi?id=49895
* http/tests/local/fileapi/file-last-modified-expected.txt: Added.
* http/tests/local/fileapi/file-last-modified.html: Added.
* http/tests/local/fileapi/script-tests/file-last-modified.js: Added.
* http/tests/resources/file-last-modified.php: Added.
2010-12-20 Oliver Hunt <oliver@apple.com>
Reviewed by Geoffrey Garen.
......
Test File.lastModifiedDate.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS event.dataTransfer contains a File object on drop.
PASS file.lastModifiedDate verified
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../../../fast/js/resources/js-test-style.css">
<script src="../../../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/setup-file-input-element-for-drag.js"></script>
<script src="script-tests/file-last-modified.js"></script>
<script src="../../../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
description("Test File.lastModifiedDate.");
function onFileDrop(file, filePath)
{
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://127.0.0.1:8000/resources/file-last-modified.php?path=../local/fileapi/" + filePath, false);
xhr.send();
var expectedDate = new Date(parseInt(xhr.responseText) * 1000);
var actualDate = file.lastModifiedDate;
if (expectedDate.toString() == actualDate.toString())
testPassed("file.lastModifiedDate verified");
else
testFailed("file.lastModifiedDate incorrect");
}
function runTest()
{
var testFilePath = "../resources/file-for-drag-to-send.txt";
setFileInputDropCallback(function(file) { onFileDrop(file, testFilePath); });
eventSender.beginDragWithFiles([testFilePath]);
moveMouseToCenterOfElement(fileInput);
eventSender.mouseUp();
}
if (window.eventSender) {
runTest();
// Clean up after ourselves
removeFileInputElement();
} else {
testFailed("This test is not interactive, please run using DumpRenderTree");
}
var successfullyParsed = true;
<?php
date_default_timezone_set('UTC');
$filePath = $_GET['path'];
if (file_exists($filePath)) {
echo date("U", filemtime($filePath));
}
?>
2010-12-20 Jian Li <jianli@chromium.org>
Reviewed by David Levin.
Add lastModifiedDate attribute to File interface per File API spec
https://bugs.webkit.org/show_bug.cgi?id=49895
lastModifiedDate is not supported for GObject bindings because Date is
not support in code generation.
Test: http/tests/local/fileapi/file-last-modified.html
* fileapi/File.cpp:
(WebCore::File::lastModifiedDate):
* fileapi/File.h:
* fileapi/File.idl:
2010-12-20 Mark Rowe <mrowe@apple.com>
Reviewed by Dan Bernstein.
......
......@@ -28,6 +28,8 @@
#include "FileSystem.h"
#include "MIMETypeRegistry.h"
#include <wtf/CurrentTime.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
......@@ -68,6 +70,16 @@ File::File(const String& relativePath, const String& path)
}
#endif
double File::lastModifiedDate() const
{
time_t modificationTime;
if (!getFileModificationTime(m_path, modificationTime))
return 0;
// Needs to return epoch time in milliseconds for Date.
return modificationTime * 1000.0;
}
unsigned long long File::size() const
{
// FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to
......
......@@ -60,6 +60,7 @@ public:
const String& path() const { return m_path; }
const String& name() const { return m_name; }
double lastModifiedDate() const;
#if ENABLE(DIRECTORY_UPLOAD)
// Returns the relative path of this file in the context of a directory selection.
const String& webkitRelativePath() const { return m_relativePath; }
......@@ -91,4 +92,4 @@ private:
} // namespace WebCore
#endif // FileList_h
#endif // File_h
......@@ -31,6 +31,9 @@ module html {
NoStaticTables
] File : Blob {
readonly attribute DOMString name;
#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT
readonly attribute Date lastModifiedDate;
#endif
#if defined(ENABLE_DIRECTORY_UPLOAD) && ENABLE_DIRECTORY_UPLOAD
readonly attribute DOMString webkitRelativePath;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment