Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for web workers #1166

Closed
indolering opened this issue Dec 20, 2013 · 6 comments
Closed

Unit tests for web workers #1166

indolering opened this issue Dec 20, 2013 · 6 comments

Comments

@indolering
Copy link

Since moving to browserfy, PouchDB in web workers should work in any web browser which supports web workers database access using the async IndexDB API without any additional modifications.

Currently, only Chrome supports indexDB access from webworkers, however, there has been a recent flurry of activity on over at Bugzilla and it looks like it's close to being implemented.

The "only" thing left is creating unit tests.

@calvinmetcalf
Copy link
Member

so the switch to browserify removed the references to window, so in principle there is no reason you can't use it in a web worker (besides the lack of indexed db). have you tried using it to connect to an http database yet? you can use importScripts to load pouchdb

Due to poor design of the web worker api libraries can not create web workers so pouch would be restricted to operating 100% inside a web worker or not at all in the worker, e.g. no custom message passing algorithms like @daleharvey suggested on the mailing list, you might be able to hack it together for chrome and firefox but IE is a no go there.

@indolering
Copy link
Author

Great, I haven't tried it yet I have just been getting a steady stream of emails from that bugzilla ticket and figured I would post here.

In my use-case, I don't even need postMessage. I'm trying to mix http and https content but since Firefox blocks http JS in https sites I have to go the other way around: have an http site load an https worker. But the http site doesn't need to communicate with the worker, the worker is just updating client-side storage in the background for when the site can be https only.

Maybe we should change the ticket to "Create unit tests for web workers" ?

@calvinmetcalf
Copy link
Member

yes we can consider this a unit test for workers ticket.

For now you could try loading a https iframe

calvinmetcalf added a commit that referenced this issue Dec 20, 2013
@calvinmetcalf
Copy link
Member

as it turns out there is a reference to window in the ajax section, so I fixed that and have a pull for that plus basic tests that just create a db, put a doc in, and get it agin.

@indolering
Copy link
Author

Fucking A', that was fast! I'm using this as the backend to Speech.is, your contribs will be put to good use : )

calvinmetcalf added a commit that referenced this issue Dec 21, 2013
calvinmetcalf added a commit that referenced this issue Dec 22, 2013
@calvinmetcalf
Copy link
Member

merged 8f73143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants