Why is IndexedDB not supported in extentions?

As one of the maintainers of PouchDB, an in browser database we receive fairly regular bug reports about supporting various ‘kinda web’ like environment. Most of these arent a surprise however I was surprised that Chrome, Firefox and Safari have 3 distinct add on environments that are all incompatible with the API’s they expose to web content.

It seems like we should support IndexedDB inside addons, it would let addon authors reuse the vast amount of projects that have been built based on web technologies without adding burden on library auther to support yet another specific api

Cheers
Dale

I use it just fine in a bootstrapped add-on. No idea about jetpack. I plan to test WebExtensions soon.

The environment that Chrome provides for the main extension logic (aka. the background page or event page) is a very web-like environment with a window object and associated DOM APIs. If WebExtensions wants to make porting easy, they will need to do the same thing.

In Firefox you can get hold of IndexedDB and other DOM APIs via a hidden Window object. For example, here is how the fetch() API can be accessed:

var hiddenWindow = require('sdk/addon/window').window;
hiddenWindow.fetch(<url>)

I haven’t tried accessing IndexedDB in the same way, but it might be possible.

1 Like

WebExtensions seem to be allowing access to indexedDB global as well. But there are deeper issues with that API that need ironing out before it’s usable.

I failed to mention that you need to Cu.importGlobalProperties(['indexedDB']); to get it to work for bootstrapped add-ons.