Index: LayoutTests/fast/files/workers/resources/worker-read-file-constructor-async.js |
diff --git a/LayoutTests/fast/files/workers/resources/worker-read-file-constructor-async.js b/LayoutTests/fast/files/workers/resources/worker-read-file-constructor-async.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c2c2d4f85252ccadc6887981c146fa9e71d01b28 |
--- /dev/null |
+++ b/LayoutTests/fast/files/workers/resources/worker-read-file-constructor-async.js |
@@ -0,0 +1,37 @@ |
+importScripts("../../resources/read-common.js") |
+ |
+function log(message) |
+{ |
+ postMessage(message); |
+} |
+ |
+function readFiles(index, files) |
+{ |
+ if (index >= files.length) { |
+ log("DONE"); |
+ return; |
+ } |
+ |
+ log("Reading: '" + files[index].name + "'"); |
+ log("Last modified: '" + (new Date(files[index].lastModified)).toUTCString() + "'"); |
+ |
+ var reader = new FileReader(); |
+ var isText = files[index].type.indexOf("text") > -1; |
+ reader.onload = function (e) { |
+ if (isText) { |
+ log("Contents: '" + reader.result + "'"); |
+ log("Length: " + reader.result.length); |
+ } else |
+ log("Length: " + reader.result.byteLength); |
+ readFiles(index + 1, files); |
+ }; |
+ if (isText) |
+ reader.readAsText(files[index]); |
+ else |
+ reader.readAsArrayBuffer(files[index]) |
+} |
+ |
+onmessage = function (e) { |
+ log('Received files in worker'); |
+ readFiles(0, e.data); |
+}; |