Support Web Workers

Web workers don't have access to `window`, so I replaced explicit `window` references with an implicit local/global reference.  

I also added a test, but I was only able to test locally in chrome.  Also, note that Firefox does not support IndexDB access from within a web worker yet (https://bugzilla.mozilla.org/show_bug.cgi?id=701634).