Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: LayoutTests/fast/files/workers/resources/worker-read-file-constructor-async.js

Issue 100023005: Make cloning of File objects more useful. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reupload Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/files/workers/worker-read-file-constructor-async.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+};
« no previous file with comments | « no previous file | LayoutTests/fast/files/workers/worker-read-file-constructor-async.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698