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

False positive result for IndexedDB test in firefox private browsing window #1390

Closed
wants to merge 1 commit into from

Conversation

weilu
Copy link

@weilu weilu commented Jul 11, 2014

Firefox in private mode has indexedDB available, however it doesn't seem to be writable. indexedDB.open results in InvalidStateError. And when the readyState is done, the IDBOpenDBRequest object will have an error: DOMError { name: "InvalidStateError", message: "A mutation operation was attempted on a database that did not allow mutations." }.

I'm not sure what's a possible solution to this. If anyone can point me to the right direction, I'm willing to put together a PR to fix this.

@patrickkettner
Copy link
Member

Hey @weilu!
Thanks so much for the report and offer!

The first step would be to try and setup up that situation, and have a try catch setup to catch it. if that error occurs, return false on the addTest interface

let me know if you have any questions or if I can be of any more help!

@weilu
Copy link
Author

weilu commented Jul 11, 2014

@patrickkettner The error only occurs on indexDB.open. So should I just try to open some arbitrary database (e.g. indexedDB.open(Math.random())) and delete it afterwards if the test returns true? What if I open some existing db and then accidentally delete it?

@patrickkettner
Copy link
Member

I would try to create something that is fairly random - 'modernizr-' + Math.random() * 10000 or the like.

@weilu
Copy link
Author

weilu commented Jul 11, 2014

Is there a way to carry out an async test? Turns out InvalidStateError isn't actually being thrown but rather an artefact of firefox debugger. I have to inspect req.error in the req.onerror handler:

var req = db.open(testDBName)
req.onerror = function(event){
      if(req.error && req.error.name === "InvalidStateError") { // req.error instanceof DOMError
        indexeddb = false
      }
}

@patrickkettner
Copy link
Member

yep! Modernizr.addAsyncTest, the blob workers test is an one example of many in the repo

@weilu
Copy link
Author

weilu commented Jul 11, 2014

👍

weilu added a commit to weilu/Modernizr that referenced this pull request Jul 11, 2014
As a side effect, both indexeddb and indexeddb.deletedatabase are async tests now
[closes Modernizr#1390]
As a side effect, both indexeddb and indexeddb.deletedatabase are async tests now
[closes Modernizr#1390]
@weilu
Copy link
Author

weilu commented Aug 7, 2014

bump

patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this pull request Jul 15, 2016
As a side effect, both indexeddb and indexeddb.deletedatabase are async tests now
[closes Modernizr#1390]
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

Successfully merging this pull request may close these issues.

None yet

2 participants