Goldsmith
Goldsmith

Reputation: 508

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:

EDIT: This is what the command looks like:

db = openDatabase('my_database', '1.0', 'My database description', 5*1024*1024, function() {});

Upvotes: 9

Views: 3070

Answers (2)

ppo
ppo

Reputation: 21

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.

Upvotes: 2

Kyaw Tun
Kyaw Tun

Reputation: 13141

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

Upvotes: 1

Related Questions