SECURITY_ERR: DOM Exception 18 on openDatabase
Asked Answered
P

2

9

I have a web-based Android app that uses WebSQL for storage. For some reason, calling openDatabase at one point (in response to a button click), causes a DOMException with the message "SECURITY_ERR: DOM Exception 18".

Note that I am not using PhoneGap.

The main question I'm asking here is: What are the possible causes for a DOMException 18 on openDatabase?

Some more details: This exception only occurs if the database does not exist yet. If it already exists, it works as expected. The function that makes the openDatabase call is used in another part of the app and works just fine.

What I've tried so far:

  • Reducing the size of the database - shouldn't be an issue since it's being created by another part of the app.
  • I've checked the external storage permissions - again, shouldn't be an issue.
  • I read somewhere that the USB cable being plugged in could cause this issue - not what's causing it in this case.

EDIT: This is what the command looks like:

db = openDatabase('my_database', '1.0', 'My database description', 5*1024*1024, function() {});
Phony answered 25/1, 2013 at 14:19 Comment(4)
is that issue solved...i am facing the same issue...Voiced
Never found out what the cause was. In the end, I found WebSQL stability to be too inconsistent on different Android devices/versions for my needs, so I ended up writing a native interface that turned out to be far better. Though I no longer need an answer to this question, I would still be interested in hearing one, for curiosity's sake.Phony
i solved this issue..strictly called open database inside the device ready function....Voiced
Are you using PhoneGap? (just asking to avoid confusion since the original question was non-PhoneGap)Phony
D
2

I found that it has to do with the allowed size of the database. If you try to open a db that is larger than 50mb on iOS, you get this error.

Drais answered 4/4, 2013 at 5:38 Comment(1)
While I wouldn't be surprised if opendatabase causes the exact same error if you go over the size limit, this is not the case here. Like I said, it's successfully created in another part of the app. Also, I've set the limit to 5 MB.Phony
P
1

According to the spec the spec , it cause by only two

  • The user agent may raise a SECURITY_ERR exception instead of returning a Database object if the request violates a policy decision (e.g. if the user agent is configured to not allow the page to open databases).

  • If origin is not a scheme/host/port tuple, then throw a SECURITY_ERR exception

Picklock answered 26/1, 2013 at 5:17 Comment(2)
Both calls have the same origin, and the user agent is configured prior to the page being loaded.Phony
There should be something. I can figure out only if you show your codePicklock

© 2022 - 2024 — McMap. All rights reserved.