Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6164337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:58:34+00:00 2026-05-23T21:58:34+00:00

(cross-posted on Mozilla: http://forums.mozillazine.org/viewtopic.php?f=7&t=2254955 ) I’m trying to work with the Mozilla storageService .

  • 0

(cross-posted on Mozilla: http://forums.mozillazine.org/viewtopic.php?f=7&t=2254955 )

I’m trying to work with the Mozilla storageService. In the following code, the user is asked to grant the creation of a local database (‘database.sqlite’) and a table is created.

<html>
<head>
<script type="text/javascript">
var con=null;
function executeStatement()
    {
    try
        {
        var stmt=con.createStatement("SELECT * FROM instances");
        }
    catch(e)
        {
        alert("Cannot execute statement :"+e);
        }
    }

function init()
    {
    try
        {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        }
    catch (e)
        {
        alert("Permission to write to file was denied.");
        return;
        }

    try
        {
        var file = Components.classes["@mozilla.org/file/directory_service;1"]
                     .getService(Components.interfaces.nsIProperties)
                     .get("Home", Components.interfaces.nsIFile);
        file.append("database.sqlite");

        var storageService = Components.classes["@mozilla.org/storage/service;1"]
                        .getService(Components.interfaces.mozIStorageService);
        con = storageService.openDatabase(file);
        con.executeSimpleSQL(
            "CREATE TABLE IF NOT EXISTS instances("+
                "id INTEGER PRIMARY KEY AUTOINCREMENT"+
            ")"
            );
        }
    catch(e)
        {
        alert(e);
        }

    }


window.addEventListener("load", init,true); 
</script>
</head>
<body>
<button onClick="executeStatement();">Test</button>
</body>
</html>

But when I click on the button to invoke the method executeStatement, I get the following exception:

Cannot execute statement :Error: Permission denied for <file://> to
call method UnnamedClass.createStatement

why ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:58:35+00:00Added an answer on May 23, 2026 at 9:58 pm

    That’s just how enablePrivilege works – you have to call it in every function requiring the privileges. See also The only option is to include that block of code into each of my functions?

    While we’re at it, I’ll quote bz’s comment from that thread:

    I strongly suggest you look into not using enablePrivilege at all. It’s deprecated and on its way to being removed. – Boris Zbarsky Jul 13 at 14:10

    …

    The replacement is using an extension. I’m not sure how clearly documented this is, but upcoming Firefox versions will warn when you use enablePrivilege, and you can no longer use enablePrivilege to do cross-site XMLHttpRequest. There’s mention of this in some places (e.g. https://developer.mozilla.org/en/Mochitest#How_can_I_get_around_the_error_.22Permission_denied_to_get_property_XPCComponents.classes.22.3f ) but a lot more documentation to update yet. – Boris Zbarsky Jul 14 at 5:11

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Cross-post http://perlmonks.org/index.pl?node_id=979710 I'm trying to create a text file from some XML using Perl
I had posted this question on MSDN Forum http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/f00e3406-354d-4f54-acce-7b7f0ad4c90f But I am not getting
I posted a problem I'm having with the FlowPlayer jQuery plugin at http://static.flowplayer.org/forum/1/29367 ,
[cross posted again to Mahalo answers] My Perl/Tk script has an initial spreadsheet like
[Cross-posted from lib-curl mailing list] I have a single threaded app (MSVC C++ 2005)
This is already cross-posted at MS Connect: https://connect.microsoft.com/VisualStudio/feedback/details/560451 I am attempting to override the
I'm trying to work around the randomForest package limit of 32 levels for factors.
Hi I am trying out a simple java http server NanoHTTPD: http://elonen.iki.fi/code/nanohttpd/ Today I
Cross-posted from the Cukes Google Group: I have experimented with a number of methods
I cross-posted in Javaranch too. I did my due diligence by doing Google search.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.