bramski / angular-indexedDB

An angularjs serviceprovider to utilize indexedDB with angular
165 stars 49 forks source link

ShimIndexedDB support #33

Closed Lunatic83 closed 8 years ago

Lunatic83 commented 9 years ago

I'm using your angularjs indexeddb module for iOS support I had to fix putting the following code into angular-indexed-db.js on line 15

indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;

mmmichl commented 9 years ago

@Lunatic83 unfortunately your fix does not work for me with Safari 7.1.6 on OSX. Can you confirm if it works on the latest iOS 8.3? As far as I read here (http://www.raymondcamden.com/2014/9/25/IndexedDB-on-iOS-8--Broken-Bad), indexedDB is still not working correctly on the latest iOS. Additionally I face the same issue as in #15 described.

According to the hint in the indexedDB shim readme, the variable window.indexedDB is also read-only. So you can't even overwrite it (https://github.com/axemclion/IndexedDBShim#known-issues). I think the most flexible solution would be to offer a method in the indexedDBProvider to overwrite the indexedDB variable. In this way you can choose when and with which shim you want to use.

bramski commented 9 years ago

@mmmichl That's not really a big deal as there is a closure variable 'indexedDB` which the library uses at instantiation to determine the correct indexedDB global to use.

bramski commented 9 years ago

@Lunatic83 what's needed here is a harness which can run the karma testing in the xcode safari emulator browser if that's possible. The functionality needs to be confirmable by testing so that we can confidently say that this library works with shimIndexedDB.

mmmichl commented 9 years ago

@bramski unfortunately this is not working in the case of Safari and Safari mobile. The latest version of Safari has an indexedDB implementation, and thus it will use that. But the implementation is so broken, that even after spending couple of hours I couldn't make the tests work. There are different, very strange behaviours. Like not being able to delete a database at all after a certain time, or even getting a upgradeneeded event when deleting a database?!

I don't know a automatic way, but to manually run the tests in a simulator or on a real device my approach was:

  1. run karma with singleRun: false so it does not terminate at the end of the tests
  2. check out your local IP
  3. open Safari on your device or simulator and enter the URL http://[your ip]:8080

The tests will run immediately.

bramski commented 9 years ago

LOL. Yeah that sounds amazingly broken. There's another PR here about doing safari support, so I imagine that is quite busted as well.

But I thought this PR was about using shimIndexedDB, not the native safari indexedDB? Shim uses webSQL; so my assumption would be that if @Lunatic83 fixes this code and runs the cordova emu browser that this PR should be verifiable.

wibimaster commented 8 years ago

Hi,

I have to do the same patch on my side, but it should be great to merge the shimIndexedDB fix ; on iOS 8.3, mobile app, it's necessary.

Can you do this ?

thanks !

bramski commented 8 years ago

@wibimaster someone needs to actually do the work of running this in emu and submitting a proper PR to make this work. If you fork and make a proper PR then I'll definitely merge it. This particular PR is very broken.

wibimaster commented 8 years ago

@bramski Allright, I'll do a fork and a PR for that ; I never used the xcode safari emulator, but I directly test it on a real iPhone device (4S, iOS 8.3) :)

wibimaster commented 8 years ago

Done here : #58 Is it OK for you ?

Thanks !

bramski commented 8 years ago

Much better. Closing this.