tags:

views:

217

answers:

1

Hello everyone. I have some problems with Web workers in javascript. I would like to open sqlite database from worker and make sync, but it always ends up with error: Can't find variable: openDatabase

Here is my code

//index.html 
new Worker(worker.js)

//worker.js
openDatabase(...)

Why worker doesn't have permissions to openDatabase method? I tried the same with alert() method and got the same error. I know I can use importScripts() method to load some external files but I want to use global javascript method.

So is there a way how to solve this problem? Or I can't do anything more complicated in workers? Thank you for your help

+1  A: 

This has been brought up a couple of times without the definitive answer.

It looks that this is what this bug is about: https://bugs.webkit.org/show_bug.cgi?id=22725

[edit] (And if you search bugs.webkit.org you can see that some other features are also not yet exposed in the workers. alert() is not supposed to exist in the workers' scope though.)

Nickolay