jsdIDebuggerService OnCall hook - how to find the context of the call - Mozilla

This is a discussion on jsdIDebuggerService OnCall hook - how to find the context of the call - Mozilla ; http://mxr.mozilla.org/mozilla/sourc...ervice.idl#536 by context i mean, how can i determine which window object has/parents the code that is currently being executed. For example, if i open multiple instances of the same simple HTML/ JS page in my browser, i get calls ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: jsdIDebuggerService OnCall hook - how to find the context of the call

  1. jsdIDebuggerService OnCall hook - how to find the context of the call

    http://mxr.mozilla.org/mozilla/sourc...ervice.idl#536

    by context i mean, how can i determine which window object has/parents
    the code that is currently being executed.
    For example, if i open multiple instances of the same simple HTML/JS
    page in my browser, i get calls to the OnCall hook before the scripts
    in them are executed. How do i differentiate between different
    windows?

    I've tried traversing the declarations of the types (jsdIScript,
    jsdIStackFrame, ...) in the codebase, but the best i can find is the
    jsdIScript's fileName:
    http://mxr.mozilla.org/mozilla/sourc...ervice.idl#911

    that's not enough though.

  2. Re: jsdIDebuggerService OnCall hook - how to find the context of thecall

    > The only way I know to get the compiling object is to hook
    > onScriptCreated, set a breakpoint in the script object, then look at the
    > calling stack frames when the breakpoint hits. For non-XBL code you need
    > only set the breakpoint on the script with a null functionName.

    yep, managed to complete that point.

    >
    > To get the defining scope, begin at frame.scope and walk back on
    > scope.jsParent. This walk is shown in Firebug as the scope chain in the
    > DOM side panel when you hit a break point.
    >
    > The calling object is just the 'this' pointer for the oldest frame.

    here is where i get problems. i can see the scope chain in the Firebug
    side panel.
    however, when i try to "walk back" on the frame.scope.jsParent until i
    reach the MOA-JS or the window object i'm searching for,
    i can't do it.

    the "this" keyword is only available for the current scope and it can
    only be called like: alert(this)
    alert(frame.scope.this) - gives "undefined". my IDE underlines it as
    an error, so i'm probably trying to
    solve it in the wrong way.

    how exactly would you "walk back and use the 'this' keyword", if you
    have caught the frame value inside a hook?

  3. Re: jsdIDebuggerService OnCall hook - how to find the context of thecall

    Thanks for the input. I found what i needed.

    Here's a little different way to achieve a similar result:
    http://pastebin.mozilla.org/702902
    It's from FireBug's code.

+ Reply to Thread