Diff
Modified: trunk/LayoutTests/ChangeLog (109197 => 109198)
--- trunk/LayoutTests/ChangeLog 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/LayoutTests/ChangeLog 2012-02-29 06:51:03 UTC (rev 109198)
@@ -1,3 +1,21 @@
+2012-02-28 Kinuko Yasuda <[email protected]>
+
+ Add size field to Metadata in FileSystem API
+ https://bugs.webkit.org/show_bug.cgi?id=79813
+
+ Changed fast/filesystem/op-get-metadata test to also test if
+ getMetadata returns correct file sizes.
+
+ Reviewed by David Levin.
+
+ * fast/filesystem/op-get-metadata-expected.txt:
+ * fast/filesystem/resources/op-get-metadata.js:
+ * fast/filesystem/resources/op-tests-helper.js:
+ (createTestEnvironment.Helper.this.createSuccessCallback.entry.createWriter): Added.
+ (createTestEnvironment.Helper.this.createSuccessCallback):
+ (createTestEnvironment.Helper.this.createNextEntry):
+ (runOperationTest.OperationTestHelper.this.testMetadataSuccessCallback):
+
2012-02-28 Dmitry Lomov <[email protected]>
[JSC] Implement ArrayBuffer transfer
Modified: trunk/LayoutTests/fast/filesystem/op-get-metadata-expected.txt (109197 => 109198)
--- trunk/LayoutTests/fast/filesystem/op-get-metadata-expected.txt 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/LayoutTests/fast/filesystem/op-get-metadata-expected.txt 2012-02-29 06:51:03 UTC (rev 109198)
@@ -2,15 +2,23 @@
PASS Succeeded: "/".getMetadata()
PASS Succeeded: "/".getDirectory("/a")
PASS Succeeded: "/a".getMetadata()
-PASS this.environment["/a.modificationTime"] is >= this.roundedStartDate
+PASS this.environment["/a.returned.modificationTime"] is >= this.roundedStartDate
+PASS Succeeded: "/file1".getMetadata()
+PASS this.environment["/file1.returned.modificationTime"] is >= this.roundedStartDate
+PASS Succeeded: "/file2".getMetadata()
+PASS this.environment["/file2.returned.modificationTime"] is >= this.roundedStartDate
+PASS this.environment["/file2.size"] is this.environment["/file2.returned.size"]
+PASS Succeeded: "/file3".getMetadata()
+PASS this.environment["/file3.returned.modificationTime"] is >= this.roundedStartDate
+PASS this.environment["/file3.size"] is this.environment["/file3.returned.size"]
PASS Succeeded: "/".getFile("/b")
PASS Succeeded: "/b".getMetadata()
-PASS this.environment["/b.modificationTime"] is >= this.roundedStartDate
+PASS this.environment["/b.returned.modificationTime"] is >= this.roundedStartDate
PASS Succeeded: "/tmp".remove()
PASS this.expectedErrorCode + "" is "1"
-PASS this.environment["/a.modificationTime"] is >= this.environment["/.modificationTime"]
-PASS this.environment["/b.modificationTime"] is >= this.environment["/.modificationTime"]
-PASS this.environment["/b.modificationTime"] is >= this.environment["/a.modificationTime"]
+PASS this.environment["/a.returned.modificationTime"] is >= this.environment["/.returned.modificationTime"]
+PASS this.environment["/b.returned.modificationTime"] is >= this.environment["/.returned.modificationTime"]
+PASS this.environment["/b.returned.modificationTime"] is >= this.environment["/a.returned.modificationTime"]
Finished running tests.
PASS successfullyParsed is true
Modified: trunk/LayoutTests/fast/filesystem/resources/op-get-metadata.js (109197 => 109198)
--- trunk/LayoutTests/fast/filesystem/resources/op-get-metadata.js 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/LayoutTests/fast/filesystem/resources/op-get-metadata.js 2012-02-29 06:51:03 UTC (rev 109198)
@@ -3,18 +3,24 @@
name: 'GetMetadata',
precondition: [
{fullPath:'/tmp'},
+ {fullPath:'/file1', size:0},
+ {fullPath:'/file2', size:10},
+ {fullPath:'/file3', size:100},
],
tests: [
function(helper) { helper.getMetadata('/'); },
function(helper) { helper.getDirectory('/', '/a', {create:true}); },
function(helper) { helper.getMetadata('/a'); },
+ function(helper) { helper.getMetadata('/file1'); },
+ function(helper) { helper.getMetadata('/file2'); },
+ function(helper) { helper.getMetadata('/file3'); },
function(helper) { helper.getFile('/', '/b', {create:true}); },
function(helper) { helper.getMetadata('/b'); },
function(helper) { helper.remove('/tmp'); },
function(helper) { helper.getMetadata('/tmp', FileError.NOT_FOUND_ERR); },
- function(helper) { helper.shouldBeGreaterThanOrEqual('/a.modificationTime', '/.modificationTime'); },
- function(helper) { helper.shouldBeGreaterThanOrEqual('/b.modificationTime', '/.modificationTime'); },
- function(helper) { helper.shouldBeGreaterThanOrEqual('/b.modificationTime', '/a.modificationTime'); }
+ function(helper) { helper.shouldBeGreaterThanOrEqual('/a.returned.modificationTime', '/.returned.modificationTime'); },
+ function(helper) { helper.shouldBeGreaterThanOrEqual('/b.returned.modificationTime', '/.returned.modificationTime'); },
+ function(helper) { helper.shouldBeGreaterThanOrEqual('/b.returned.modificationTime', '/a.returned.modificationTime'); }
],
postcondition: [ ],
},
Modified: trunk/LayoutTests/fast/filesystem/resources/op-tests-helper.js (109197 => 109198)
--- trunk/LayoutTests/fast/filesystem/resources/op-tests-helper.js 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/LayoutTests/fast/filesystem/resources/op-tests-helper.js 2012-02-29 06:51:03 UTC (rev 109198)
@@ -31,9 +31,22 @@
this.errorCallback = errorCallback;
this.environment = {};
- this.createSuccessCallback = function(entry)
+ this.createSuccessCallback = function(entry, size)
{
+ if (entry.isFile && size > 0) {
+ entry.createWriter(bindCallback(this, function(writer) {
+ writer.truncate(size);
+ writer._onerror_ = bindCallback(this, this.createErrorCallback);
+ writer._onwriteend_ = bindCallback(this, function() {
+ this.environment[entry.fullPath] = entry;
+ this.environment[entry.fullPath + '.size'] = size;
+ this.createNextEntry();
+ });
+ }), bindCallback(this, this.createErrorCallback));
+ return;
+ }
this.environment[entry.fullPath] = entry;
+ this.environment[entry.fullPath + '.size'] = 0;
this.createNextEntry();
}
@@ -53,7 +66,7 @@
if (entry.isDirectory)
fileSystem.root.getDirectory(entry.fullPath, {create:true}, bindCallback(this, this.createSuccessCallback), bindCallback(this, this.createErrorCallback));
else
- fileSystem.root.getFile(entry.fullPath, {create:true}, bindCallback(this, this.createSuccessCallback), bindCallback(this, this.createErrorCallback));
+ fileSystem.root.getFile(entry.fullPath, {create:true}, bindCallback(this, this.createSuccessCallback, entry.size), bindCallback(this, this.createErrorCallback));
};
};
@@ -211,12 +224,18 @@
{
if (!this.expectedErrorCode) {
testPassed('Succeeded: ' + this.stage);
- var symbol = entry + '.modificationTime';
+ var symbol = entry + '.returned.modificationTime';
this.environment[symbol] = metadata.modificationTime;
-
var entryMetadataString = this.getSymbolString(symbol);
- if (entry != '/')
+ if (entry != '/') {
shouldBeGreaterThanOrEqual.apply(this, [entryMetadataString, 'this.roundedStartDate']);
+ }
+ if (metadata.size) {
+ this.environment[entry + '.returned.size'] = metadata.size;
+ var entrySizeString = this.getSymbolString(entry + '.returned.size');
+ var expectedSizeString = this.getSymbolString(entry + '.size');
+ shouldBe.apply(this, [expectedSizeString, entrySizeString]);
+ }
this.runNextTest();
} else
testFailed('Unexpectedly succeeded while ' + this.stage);
Modified: trunk/Source/WebCore/ChangeLog (109197 => 109198)
--- trunk/Source/WebCore/ChangeLog 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/Source/WebCore/ChangeLog 2012-02-29 06:51:03 UTC (rev 109198)
@@ -1,3 +1,21 @@
+2012-02-28 Kinuko Yasuda <[email protected]>
+
+ Add size field to Metadata in FileSystem API
+ https://bugs.webkit.org/show_bug.cgi?id=79813
+
+ Reviewed by David Levin.
+
+ Test: fast/filesystem/op-get-metadata.html
+
+ * fileapi/FileSystemCallbacks.cpp:
+ (WebCore::MetadataCallbacks::didReadMetadata):
+ * fileapi/Metadata.h:
+ (WebCore::Metadata::create):
+ (WebCore::Metadata::modificationTime):
+ (WebCore::Metadata::size): Added.
+ (WebCore::Metadata::Metadata):
+ * fileapi/Metadata.idl:
+
2012-02-28 Dmitry Lomov <[email protected]>
[JSC] Implement ArrayBuffer transfer
Modified: trunk/Source/WebCore/fileapi/FileSystemCallbacks.cpp (109197 => 109198)
--- trunk/Source/WebCore/fileapi/FileSystemCallbacks.cpp 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/Source/WebCore/fileapi/FileSystemCallbacks.cpp 2012-02-29 06:51:03 UTC (rev 109198)
@@ -268,7 +268,7 @@
void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata)
{
if (m_successCallback)
- m_successCallback->handleEvent(Metadata::create(metadata.modificationTime).get());
+ m_successCallback->handleEvent(Metadata::create(metadata).get());
m_successCallback.clear();
}
Modified: trunk/Source/WebCore/fileapi/Metadata.h (109197 => 109198)
--- trunk/Source/WebCore/fileapi/Metadata.h 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/Source/WebCore/fileapi/Metadata.h 2012-02-29 06:51:03 UTC (rev 109198)
@@ -33,32 +33,34 @@
#if ENABLE(FILE_SYSTEM)
+#include "FileMetadata.h"
#include <wtf/RefCounted.h>
namespace WebCore {
class Metadata : public RefCounted<Metadata> {
public:
- static PassRefPtr<Metadata> create(double modificationTime)
+ static PassRefPtr<Metadata> create(const FileMetadata& platformMetadata)
{
- return adoptRef(new Metadata(modificationTime));
+ return adoptRef(new Metadata(platformMetadata));
}
static PassRefPtr<Metadata> create(Metadata* metadata)
{
- return adoptRef(new Metadata(metadata->m_modificationTime));
+ return adoptRef(new Metadata(metadata->m_platformMetadata));
}
- // Needs to return epoch time in milliseconds for Date.
- double modificationTime() const { return m_modificationTime * 1000.0; }
+ // Needs to return epoch time in milliseconds for Date while FileMetadata's modificationTime is in seconds.
+ double modificationTime() const { return m_platformMetadata.modificationTime * 1000.0; }
+ unsigned long long size() const { return static_cast<unsigned long long>(m_platformMetadata.length); }
private:
- Metadata(double modificationTime)
- : m_modificationTime(modificationTime)
+ Metadata(const FileMetadata& platformMetadata)
+ : m_platformMetadata(platformMetadata)
{
}
- double m_modificationTime;
+ FileMetadata m_platformMetadata;
};
} // namespace
Modified: trunk/Source/WebCore/fileapi/Metadata.idl (109197 => 109198)
--- trunk/Source/WebCore/fileapi/Metadata.idl 2012-02-29 06:49:07 UTC (rev 109197)
+++ trunk/Source/WebCore/fileapi/Metadata.idl 2012-02-29 06:51:03 UTC (rev 109198)
@@ -34,5 +34,6 @@
JSNoStaticTables
] Metadata {
readonly attribute Date modificationTime;
+ readonly attribute unsigned long long size;
};
}