jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.07k stars 220 forks source link

Doesn't work in Chrome packaged app #94

Closed lavelle closed 10 years ago

lavelle commented 10 years ago

BrowserFS doesn't work in a Chrome app, because it uses document.write for an IE polyfill which is not supported in Chrome apps. Could we add some feature detection to only run this if it's not running in a Chrome app/extension?

There's another error which occurs where the BrowserFS global isn't available, but I'm guessing this is because the script terminates before it attaches itself due to the previous error.

lavelle commented 10 years ago

It also attempts to use window.localStorage, even when using a different backend, like in-memory. This isn't available for Chrome apps, they need to request the permission chrome.storage.local. It would also be nice to create a wrapper function that returns one of these based on a feature-detect too, for compatibility, but it doesn't break other backends like the first issue does, so it's lower priority.

perimosocordiae commented 10 years ago

In the Chrome app, is document.write undefined? If so, we can add that to the check for document.

lavelle commented 10 years ago

No, unfortunately, it's a function which throws an error. But doing the inverse check for window.chrome should be enough.

perimosocordiae commented 10 years ago

I was about to say that this won't work, because IE11 and Opera and others define window.chrome, but we only need this VBScript injection for old IE versions. So that should work nicely.

perimosocordiae commented 10 years ago

I wasn't able to test the patch on old IE versions, but I'll close this for now.