Firefox: "Permission denied ... Components.classes"

Discussion in 'Javascript' started by kj, Feb 3, 2008.

  1. kj

    kj Guest

    Hi!

    I'd like to implement a "global error observer" [GEO] for my
    JavaScript scripts. The ideal GEO would be one that would be able
    to detect any error or exception whatsoever (including those
    triggered by throw), and optionally execute some code in response.

    I realize that the implementation of a GEO is probably intimately
    tied to the browser, but for starters, I'd be happy to be able to
    do this for Firefox.

    My first (very naive) approach was to define an onerror event
    handler for the 'body' element, but I immediately discovered that
    this misses the exceptions raised by "throw". I want something
    better.

    I spent some time trying to figure out how Firebug
    (http://www.getfirebug.com) does it, and I determined that it relies
    on an "addObserver" method of a certain "observer-service" class.
    To load this class, Firebug executes the equivalent of this:

    var C = Components;
    var _CC = C.classes; // *bombs*
    var _CI = Components.interfaces;
    var c_name = '@mozilla.org/observer-service;1';
    var iface_name = 'nsIObserverService';
    var observer_service = _CC[ c_name ].getService( _CI[ iface_name ] );

    But when I try to execute this code (specifically, the line indicated
    with the comment) I get the error

    [Exception... "'Permission denied to get property UnnamedClass.classes' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

    Does anyone know how I can get around this problem?

    TIA!

    kynn

    --
    NOTE: In my address everything before the first period is backwards;
    and the last period, and everything after it, should be discarded.
     
    kj, Feb 3, 2008
    #1
    1. Advertising

  2. kj <> writes:

    > [Exception... "'Permission denied to get property
    > UnnamedClass.classes' when calling method:
    > [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e
    > (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]
    >
    > Does anyone know how I can get around this problem?


    Sounds like that stuff is not accessible to user scripts. Lots of things
    in mozilla are restricted like that for obvious reasons.

    Run the code from a FF extension (or use greasemonkey).

    Joost.
     
    Joost Diepenmaat, Feb 3, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeremy
    Replies:
    2
    Views:
    639
    Jeremy
    Jul 1, 2004
  2. Jim Corey

    firefox questions

    Jim Corey, Jul 7, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    329
    Chris R. Timmons
    Jul 8, 2004
  3. Greg Burns

    authentication w/ firefox

    Greg Burns, Jul 23, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    631
    Bob Lehmann
    Jul 23, 2004
  4. JohnZing
    Replies:
    1
    Views:
    3,403
    =?Utf-8?B?S2VuIENveCBbTWljcm9zb2Z0IE1WUF0=?=
    Oct 5, 2004
  5. VK
    Replies:
    9
    Views:
    123
Loading...

Share This Page