The following minimal HTML file results in an error in the browser's console. File is undefined when accessed from a web worker in Chrome.
I am somewhat puzzled by this: it is working perfectly well with Firefox and I'd expect Chrome to have this already ironed out, at in a development version (the problem seems present in Chrome 22, 23, and 24).
Am I missing something, or is there a workaround to get it to work with Chrome (or may be even other browsers) ?
<html>
<body>
<script type="text/javascript">
// File seems to be defined
var slice = File.prototype.webkitSlice;
window.URL = window.URL || window.webkitURL;
// File is not defined when creating the worker below
var blob = new Blob(["var slice = File.prototype.webkitSlice;"]);
var blobURL = window.URL.createObjectURL(blob);
// Getting:
// Uncaught TypeError: Cannot read property 'prototype' of undefined
var worker = new Worker(blobURL);
</script>
</body>
</html>
If you change File to Blob, your script works. File inherits from Blob.
var blob = new Blob(["var slice = Blob.prototype.webkitSlice;"]);
For anyone following: crbug.com/147503
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With