I have a web site built using WebSQL for offline storage. I use a Web Worker to run some database queries in the background.
In latest version of Chrome 39.0.2171.95 it is not working anymore, it seems like the WebSQL APIs are not loaded. The error I'm getting is:
Uncaught ReferenceError: openDatabase is not defined
index.html
<html>
<head>
<script>
//opening the database works here
var db = openDatabase('db','1.0','db',10);
console.log(db);
//opening the database fails in web worker
var syncWorker = new Worker("worker.js");
syncWorker.postMessage(0);
</script>
</head>
<body></body>
</html>
worker.js
onmessage = function(evt) {
var db = openDatabase('db','1.0','db',10); //produces Uncaught ReferenceError: openDatabase is not defined
console.log(db);
};
But if the web worker is loaded dynamically and not from a file, it works:
http://jsbin.com/warokilodi/12/edit?html,js,console,output
Is there a workaround/fix other than loading the worker dynamically ?
Looks like it isn't a bug and they removed the feature deliberately in Blink:
https://groups.google.com/a/chromium.org/forum/m/#!topic/Blink-dev/SYlD0YVUnQk