[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

ericu at chromium.org ericu at chromium.org
Sun Feb 20 23:01:16 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit bc3647f03fc545c168b7749c14a2fe9cf58da522
Author: ericu at chromium.org <ericu at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jan 15 02:26:35 2011 +0000

    2011-01-14  Eric Uhrhane  <ericu at chromium.org>
    
            Reviewed by David Levin.
    
            Add tests for FileWriterSync
            https://bugs.webkit.org/show_bug.cgi?id=50720
    
            * fast/filesystem/resources/file-writer-sync-truncate-extend.js: Added.
            * fast/filesystem/workers/file-writer-sync-truncate-extend.html: Added.
            * fast/filesystem/workers/file-writer-sync-truncate-extend-expected.txt: Added.
            * fast/filesystem/resources/file-writer-sync-write-overlapped.js: Added.
            * fast/filesystem/workers/file-writer-sync-write-overlapped.html: Added.
            * fast/filesystem/workers/file-writer-sync-write-overlapped-expected.txt: Added.
            * fast/filesystem/resources/file-writer-utils.js:
            (assert): Make assert throw, rather than continue.
            (cleanUp): Always call finishJSTest, even without fileEntryForCleanup.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75864 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 794da35..bca3acf 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2011-01-14  Eric Uhrhane  <ericu at chromium.org>
+
+        Reviewed by David Levin.
+
+        Add tests for FileWriterSync
+        https://bugs.webkit.org/show_bug.cgi?id=50720
+
+        * fast/filesystem/resources/file-writer-sync-truncate-extend.js: Added.
+        * fast/filesystem/workers/file-writer-sync-truncate-extend.html: Added.
+        * fast/filesystem/workers/file-writer-sync-truncate-extend-expected.txt: Added.
+        * fast/filesystem/resources/file-writer-sync-write-overlapped.js: Added.
+        * fast/filesystem/workers/file-writer-sync-write-overlapped.html: Added.
+        * fast/filesystem/workers/file-writer-sync-write-overlapped-expected.txt: Added.
+        * fast/filesystem/resources/file-writer-utils.js:
+        (assert): Make assert throw, rather than continue.
+        (cleanUp): Always call finishJSTest, even without fileEntryForCleanup.
+
 2011-01-14  Oliver Hunt  <oliver at apple.com>
 
         Reviewed by Stephanie Lewis.
diff --git a/LayoutTests/fast/filesystem/resources/file-writer-sync-truncate-extend.js b/LayoutTests/fast/filesystem/resources/file-writer-sync-truncate-extend.js
new file mode 100644
index 0000000..3a0c05c
--- /dev/null
+++ b/LayoutTests/fast/filesystem/resources/file-writer-sync-truncate-extend.js
@@ -0,0 +1,42 @@
+if (this.importScripts) {
+    importScripts('../resources/fs-worker-common.js');
+    importScripts('../resources/fs-test-util.js');
+    importScripts('../resources/file-writer-utils.js');
+}
+
+description("Test using FileWriterSync.truncate to extend a file.");
+
+// Start with an empty FileSystem.
+var fileSystem = requestFileSystemSync(this.TEMPORARY, 100);
+removeAllInDirectorySync(fileSystem.root);
+
+// Prepare a file with sample contents.
+var entry = fileSystem.root.getFile('a', {create:true, exclusive:true});
+var writer = entry.createWriter();
+assert(!writer.position);
+var builder = new BlobBuilder();
+var testData = "test data";
+builder.append(testData);
+writer.write(builder.getBlob());
+assert(writer.length == testData.length);
+assert(writer.position == writer.length);
+
+// Extend the file via truncate.
+var extensionLength = 10;
+writer.truncate(writer.length + extensionLength);
+
+// Verify the contents.
+assert(writer.length == testData.length + extensionLength);
+assert(writer.position == testData.length);
+var file = entry.file();
+var reader = new FileReaderSync();
+var contents = reader.readAsBinaryString(file);
+var i;
+for (i = 0; i < testData.length; ++i)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(i));
+for (; i < writer.length; ++i)
+    assert(!contents.charCodeAt(i));
+
+testPassed("Truncate extension verified.");
+var successfullyParsed = true;
+finishJSTest();
diff --git a/LayoutTests/fast/filesystem/resources/file-writer-sync-write-overlapped.js b/LayoutTests/fast/filesystem/resources/file-writer-sync-write-overlapped.js
new file mode 100644
index 0000000..37adc59
--- /dev/null
+++ b/LayoutTests/fast/filesystem/resources/file-writer-sync-write-overlapped.js
@@ -0,0 +1,94 @@
+if (this.importScripts) {
+    importScripts('../resources/fs-worker-common.js');
+    importScripts('../resources/fs-test-util.js');
+    importScripts('../resources/file-writer-utils.js');
+}
+
+description("Test using FileWriterSync.seek to write overlapping existing data in a file.");
+
+// Start with an empty FileSystem.
+var fileSystem = requestFileSystemSync(this.TEMPORARY, 100);
+removeAllInDirectorySync(fileSystem.root);
+
+// Prepare a file with sample contents.
+var entry = fileSystem.root.getFile('a', {create:true, exclusive:true});
+var writer = entry.createWriter();
+assert(!writer.position);
+var builder = new BlobBuilder();
+var testData = "test data";
+builder.append(testData);
+var blob = builder.getBlob();
+writer.write(blob);
+assert(writer.length == testData.length);
+assert(writer.position == writer.length);
+
+// Seek back to from the end, then overwrite, extending the file.
+var extensionOffset = -4;
+writer.seek(extensionOffset);
+writer.write(blob);
+
+// Verify the contents.
+assert(writer.length == 2 * testData.length + extensionOffset);
+assert(writer.position == writer.length);
+var file = entry.file();
+var reader = new FileReaderSync();
+var contents = reader.readAsBinaryString(file);
+var i;
+for (i = 0; i < testData.length + extensionOffset; ++i)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(i));
+var j;
+for (j = 0; i < writer.length; ++i, ++j)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(j));
+testPassed("Overlapped write 1 verified.");
+
+// Truncate back to empty and reset the contents.
+writer.truncate(0);
+assert(!writer.position);
+assert(!writer.length);
+writer.write(blob);
+assert(writer.length == testData.length);
+assert(writer.position == writer.length);
+
+// Seek forward from the beginning, then overwrite, extending the file.
+extensionOffset = 4;
+writer.seek(extensionOffset);
+writer.write(blob);
+assert(writer.length == testData.length + extensionOffset);
+assert(writer.position == writer.length);
+
+// Verify the contents.
+contents = reader.readAsBinaryString(file);
+for (i = 0; i < extensionOffset; ++i)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(i));
+for (j = 0; i < writer.length; ++i, ++j)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(j));
+testPassed("Overlapped write 2 verified.");
+
+// Truncate back to empty and reset the contents.
+writer.truncate(0);
+assert(!writer.position);
+assert(!writer.length);
+writer.write(blob);
+writer.write(blob);
+assert(writer.length == 2 * testData.length);
+assert(writer.position == writer.length);
+
+// Seek forward from the beginning, then overwrite in the middle of the file.
+extensionOffset = 4;
+writer.seek(extensionOffset);
+writer.write(blob);
+assert(writer.length == 2 * testData.length);
+assert(writer.position == testData.length + extensionOffset);
+
+// Verify the contents.
+contents = reader.readAsBinaryString(file);
+for (i = 0; i < extensionOffset; ++i)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(i));
+for (j = 0; i < testData.length + extensionOffset; ++i, ++j)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(j));
+for (j = extensionOffset; i < writer.length; ++i, ++j)
+    assert(contents.charCodeAt(i) == testData.charCodeAt(j));
+testPassed("Overlapped write 3 verified.");
+
+var successfullyParsed = true;
+finishJSTest();
diff --git a/LayoutTests/fast/filesystem/resources/file-writer-utils.js b/LayoutTests/fast/filesystem/resources/file-writer-utils.js
index 91d52b2..7ed41c8 100644
--- a/LayoutTests/fast/filesystem/resources/file-writer-utils.js
+++ b/LayoutTests/fast/filesystem/resources/file-writer-utils.js
@@ -16,20 +16,25 @@ function onError(e)
 
 function assert(s)
 {
-    if (!s)
-        onError(new Error("Assertion failed. "));
+    if (!s) {
+        var e = new Error("Assertion failed. ");
+        onError(e);
+        throw e;
+    }
 }
 
 var fileEntryForCleanup;  // Set as soon as we have one.
 
 function cleanUp()
 {
-    try {
-        if (fileEntryForCleanup)
+    if (fileEntryForCleanup) {
+        try {
             fileEntryForCleanup.remove(finishJSTest, finishJSTest);
-    } catch (ex) {
-        finishJSTest();
+            return;
+        } catch (ex) {
+        }
     }
+    finishJSTest();
 }
 
 // Generic function that gets a File from a FileEntry and calls a custom verification function on it.
diff --git a/LayoutTests/fast/filesystem/workers/file-writer-sync-truncate-extend-expected.txt b/LayoutTests/fast/filesystem/workers/file-writer-sync-truncate-extend-expected.txt
new file mode 100644
index 0000000..f953615
--- /dev/null
+++ b/LayoutTests/fast/filesystem/workers/file-writer-sync-truncate-extend-expected.txt
@@ -0,0 +1,10 @@
+[Worker] Test using FileWriterSync.truncate to extend a file.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Starting worker: ../resources/file-writer-sync-truncate-extend.js
+PASS [Worker] Truncate extension verified.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/filesystem/workers/file-writer-sync-truncate-extend.html b/LayoutTests/fast/filesystem/workers/file-writer-sync-truncate-extend.html
new file mode 100644
index 0000000..0e353f4
--- /dev/null
+++ b/LayoutTests/fast/filesystem/workers/file-writer-sync-truncate-extend.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+    <link rel="stylesheet" href="../../js/resources/js-test-style.css">
+    <title>File Writer Sync Truncate-To-Extend</title>
+    <script src="../../js/resources/js-test-pre.js"></script>
+    <script src="../resources/fs-worker-test-util.js"></script>
+ </head>
+ <body>
+    <div id="description"></div>
+    <div id="console"></div>
+    <script>
+        startWorker("../resources/file-writer-sync-truncate-extend.js");
+        window.successfullyParsed = true;
+    </script>
+    <script src="../../js/resources/js-test-post.js"></script>
+ </body>
+</html>
+
+
diff --git a/LayoutTests/fast/filesystem/workers/file-writer-sync-write-overlapped-expected.txt b/LayoutTests/fast/filesystem/workers/file-writer-sync-write-overlapped-expected.txt
new file mode 100644
index 0000000..a00ba1f
--- /dev/null
+++ b/LayoutTests/fast/filesystem/workers/file-writer-sync-write-overlapped-expected.txt
@@ -0,0 +1,12 @@
+[Worker] Test using FileWriterSync.seek to write overlapping existing data in a file.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Starting worker: ../resources/file-writer-sync-write-overlapped.js
+PASS [Worker] Overlapped write 1 verified.
+PASS [Worker] Overlapped write 2 verified.
+PASS [Worker] Overlapped write 3 verified.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/filesystem/workers/file-writer-sync-write-overlapped.html b/LayoutTests/fast/filesystem/workers/file-writer-sync-write-overlapped.html
new file mode 100644
index 0000000..85d14be
--- /dev/null
+++ b/LayoutTests/fast/filesystem/workers/file-writer-sync-write-overlapped.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+    <link rel="stylesheet" href="../../js/resources/js-test-style.css">
+    <title>File Writer Sync Truncate-To-Extend</title>
+    <script src="../../js/resources/js-test-pre.js"></script>
+    <script src="../resources/fs-worker-test-util.js"></script>
+ </head>
+ <body>
+    <div id="description"></div>
+    <div id="console"></div>
+    <script>
+        startWorker("../resources/file-writer-sync-write-overlapped.js");
+        window.successfullyParsed = true;
+    </script>
+    <script src="../../js/resources/js-test-post.js"></script>
+ </body>
+</html>
+
+

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list