Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SECURITY_ERR: DOM Exception 18 on openDatabase

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() {});
like image 707
Goldsmith Avatar asked Jan 25 '13 14:01

Goldsmith


2 Answers

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.

like image 92
ppo Avatar answered Nov 10 '22 20:11

ppo


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

like image 24
Kyaw Tun Avatar answered Nov 10 '22 18:11

Kyaw Tun