summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/fileReadSlice_worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/workers/test/fileReadSlice_worker.js')
-rw-r--r--dom/workers/test/fileReadSlice_worker.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/dom/workers/test/fileReadSlice_worker.js b/dom/workers/test/fileReadSlice_worker.js
new file mode 100644
index 000000000..2c10b7d76
--- /dev/null
+++ b/dom/workers/test/fileReadSlice_worker.js
@@ -0,0 +1,16 @@
+/**
+ * Expects an object containing a blob, a start index and an end index
+ * for slicing. Returns the contents of the blob read as text.
+ */
+onmessage = function(event) {
+ var blob = event.data.blob;
+ var start = event.data.start;
+ var end = event.data.end;
+
+ var slicedBlob = blob.slice(start, end);
+
+ var fileReader = new FileReaderSync();
+ var text = fileReader.readAsText(slicedBlob);
+
+ postMessage(text);
+};