1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/test/fileReaderSync_worker.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,25 @@ 1.4 +var reader = new FileReaderSync(); 1.5 + 1.6 +/** 1.7 + * Expects an object containing a file and an encoding then uses a 1.8 + * FileReaderSync to read the file. Returns an object containing the 1.9 + * file read a binary string, text, url and ArrayBuffer. 1.10 + */ 1.11 +onmessage = function(event) { 1.12 + var file = event.data.file; 1.13 + var encoding = event.data.encoding; 1.14 + 1.15 + var rtnObj = new Object(); 1.16 + 1.17 + if (encoding != undefined) { 1.18 + rtnObj.text = reader.readAsText(file, encoding); 1.19 + } else { 1.20 + rtnObj.text = reader.readAsText(file); 1.21 + } 1.22 + 1.23 + rtnObj.bin = reader.readAsBinaryString(file); 1.24 + rtnObj.url = reader.readAsDataURL(file); 1.25 + rtnObj.arrayBuffer = reader.readAsArrayBuffer(file); 1.26 + 1.27 + postMessage(rtnObj); 1.28 +};