Re: jsdIStackFrame.eval not restoring the stack frame

[email protected] Fri, 22 Mar 2013 00:19:15 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Message-ID <[email protected]>
hi

Have you fegure out why? I am facing the same problem now.

Thanks

On Tuesday, September 6, 2011 10:11:20 AM UTC-7, Pablo Barenbaum wrote:
> Hello,
> 
> I am using the JavaScript Debugger Service to set a breakpoint on a
> script, and trying to evaluate arbitrary code in said script's stack
> frame, using jsdIStackFrame.eval(...) from the "onExecute" breakpoint
> hook.
> 
> However, it seems that after the call to jsdIStackFrame.eval, the
> previous stack frame is *not* restored. I haven't found a
> specification of what jsdIStackFrame.eval should do, so I am not sure
> if this is a bug or actually expected behaviour.
> 
> I have set up the following (non-conformant :)) .html example to
> reproduce the behaviour:
> 
> ----
> 
> <html>
> <script type='text/javascript'>
> function toggle_jsd() {
> 
>  
> netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
>  
> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
> 
>    var jsd = Components.classes["@mozilla.org/js/jsd/debugger-service;
> 1"]
>            .getService(Components.interfaces.jsdIDebuggerService);
> 
>    if (jsd.isOn) {
>        jsd.off();
>        alert('Traps deactivated');
>        return;
>    }
> 
>    alert('Traps activated');
> 
>    jsd.on();
>    jsd.scriptHook = {
>      onScriptCreated: function(script) {
>  
> netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
>  
> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
> 
>          if (script.functionName == 'test_trap') {
>              alert('trapped {' + script.functionName + '}\n' +
> script);
>              script.setBreakpoint(0);
>          }
>      },
>      onScriptDestroyed: function(script) { }
>    };
> 
>    jsd.breakpointHook = {
>      onExecute: function (frame, type, val) {
>  
> netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
>  
> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
> 
>          alert('before jsdIStackFrame.eval');
> 
>          var result = jsd.wrapValue(null);
>          frame.eval('alert("inside jsdIStackFrame.eval")',
> frame.script.fileName, 1, result);
> 
>          // **not reached**
>          alert('after jsdIStackFrame.eval');
> 
>          // should abort script (but is not reached)
>          return jsd.breakpointHook.RETURN_HOOK_ERROR;
>       }
>    };
> }
> </script>
> <input type='submit' value='Activate' onclick='toggle_jsd()'><br>
> <input type='submit' value='Test' onclick="eval('function test_trap()
> { alert(\'Hello world!\'); } test_trap();')">
> </html>
> 
> ----
> 
> The 'Test' button normally displays a "Hello world" alert.
> When the JSD is activated (after pressing 'Activate') it is trapped by
> the hooks instead.
> 
> The code after the call to "frame.eval(...)" is never reached.
> 
> I have tested this on Firefox 3.6.10, 3.6.21 and 3.7a (Linux x86_64)
> with the same result in all cases. Higher releases seem not to support
> the JSD.
> 
> Sorry if this is not the right group to post this question, and thank
> you in advance for your help.
> 
> --
> Pablo Barenbaum