Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
jeff_sawatzky
Posts: 29
Registered: ‎04-01-2013
My Device: Z10
Accepted Solution

BB10.2 with Cordova 3.2.0 giving Security Error on openDatabase WITH REPRO STEPS

[ Edited ]

I have a cordova 3.2.0 app that uses the Web SQL api. Everything work fine on iOS and Android, but when I add the blackberry10 platform and try to run it on the simulator (BB10_2_0X.1155) the app gives me a security error when I try to do the openDatabase call.

 

Perhaps cordova isn't adding the correct permissions to the config.xml during the build? Here is the config.xml that it creates for me:

 

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:rim="http://www.blackberry.com/ns/widgets">
<feature name="Camera" value="Camera" />
<feature name="Device" value="Device" />
<rim:smileytongue:ermissions>
<rim:smileytongue:ermit>read_device_identifying_information</rim:smileytongue:ermit>
</rim:smileytongue:ermissions>
<feature name="Notification" value="Notification" />
<feature name="File" value="File" />
<feature name="FileTransfer" value="FileTransfer" />
<feature name="media-capture" value="Capture" />
<feature name="NetworkStatus" value="NetworkStatus" />
<feature name="SplashScreen" value="SplashScreen" />
<name>MyApp</name>
<description>
MyApp description
</description>
<author email="support@myapp.com" href="http://www.myapp.com">
MyApp
</author>
<content src="index.html" />
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
</widget>

Please use plain text.
Developer
jeff_sawatzky
Posts: 29
Registered: ‎04-01-2013
My Device: Z10

Re: BB10.2 with Cordova 3.2.0 giving Security Error on openDatabase

[ Edited ]

Ok, here are some repro steps....

 

  1. install cordova 3.2.0
  2. create a fresh project: 
    1. cordova create hello com.example.hello HelloWorld
    2. cd hello
    3. cordova platform add blackberry10
  3. edit index.js and add the following to the bottom of the "receivedEvent" function:

    if (id === 'deviceready') {
        try {
            var db = openDatabase('TestDB', '1.0', 'TestDB', 51943040);
            alert('success');
        } catch (e) {
            alert(e.message);
        }
    }

  4. run the app on the device or simulator. As you can see, you will get an alert with "SecurityError: DOM Exception 18"
Please use plain text.
Developer
jeff_sawatzky
Posts: 29
Registered: ‎04-01-2013
My Device: Z10

Re: BB10.2 with Cordova 3.2.0 giving Security Error on openDatabase

So, it seems like if I reduce the size of the database (I set it to 5242880) it works fine. Maybe openDatabase tries to create the database with the exact size instead of letting it grow? I don't know.
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: BB10.2 with Cordova 3.2.0 giving Security Error on openDatabase

The way I've seen it done in the past is reserving 5MB like so:
5 * 1024 * 1024

Which equates to your 5242880.

If you try this approach, even reserving larger numbers (i.e. 10 * 1024 * 1024), do you still see issues? I'm curious whether reserving fractions of MB (i.e. your original is ~49.5MB) could be causing the issue.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
jeff_sawatzky
Posts: 29
Registered: ‎04-01-2013
My Device: Z10

Re: BB10.2 with Cordova 3.2.0 giving Security Error on openDatabase

I tried with the following values and each time received a security error:
50*1024*1024
40*1024*1024
30*1024*1024

However, the following worked:
20*1024*1024

So I don't think it is a "fraction issue", I think it has something to do with a max db size somewhere, and I was going over it.
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: BB10.2 with Cordova 3.2.0 giving Security Error on openDatabase

Sounds about right. Thanks for the additional info!

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.