On Wed, Jul 29, 2009 at 17:11, johnjbarton<[email protected]> wrote: > On Jul 29, 5:55 am, Olivier Cornu <[email protected]> wrote: >> quick-&-dirty-hack(TM) in getFrameScopeWindowAncestor(): >> >> --- firebug-service.js~ 2009-07-29 13:25:51.913450368 +0200 >> +++ firebug-service.js 2009-07-29 13:26:42.293449931 +0200 >> @@ -2573,7 +2573,7 @@ >> while(scope.jsParent) >> scope = scope.jsParent; >> >> - if (scope.jsClassName == "Window" || scope.jsClassName == >> "ChromeWindow") >> + if (scope.jsClassName == "Window" || scope.jsClassName == >> "ChromeWindow" || scope.jsClassName == "Sandbox") >> return scope.getWrappedValue(); > > While Chromebug can with with non-window scopes, Firebug cannot.
Do you think i should browse Chromebug code for inspiration, then? >> Apart of the fact that this throws "too much recursion" errors at >> firebug-service:2559 (hook()), webmonkey.js (the add-on XPCOM, not the >> script unfortunately) appears in FB scripts tab. Nevertheless, it's a >> tiny progress. :-p > > I don't understand "the addon XPCOM". I meant it's a GM XPCOM service source file (like Firebug's firebug-service.js). >> I guess one of my problems at this stage will be that >> getFrameScopeWindowAncestor() is expected to return an object that is >> _both_ a Window and a JS scope: in the context of a GM script, these >> are two different things (the scope is the Sandbox). > > Well getFrameScopeWindowAncestor() must return a nsIDOMWindow for > Firebug. In particular it needs to return the window that the GM > script was applied to. But I think you want to know that the compile > was in a Sandbox. > > I think that at this stage in the processing the only thing we are > trying to do is create a "SourceFile", that is Firebug's metadata for > a compilation unit, and put that SourceFile in the correct context. > The scope analysis is only a means to that end. Firefox mixes up all > of the scripts from web pages and xul: we are just trying to sort out > where this particular script belongs. For that we need the window > then we can use getContextByWindow() to get the context we want to > attach to. Alright. In the specific case of a GM script Sandbox, it's quite straightforward to extract a reference back to the target nsiDOMWindow (it holds several of them). In other words, it should be easy to find the right context (/me is checking that box). > But we also need to know that the compile was in a Sandbox so we can > create a SandboxSourceFile (which by the way is not defined yet ;-). > This would be returned from onTopLevelScriptCreated. You don't need > the sandbox itself, just a way to know that you need to get the source > from GM (well I assume you have a way to get the source...). As noted in my previous mail, the source code run in the Sandbox appears at some point in the Firebug trace (step #86): script.functionSource logged by onScriptCreated() on line 1514. It is not the script source in its exact original form though (it lacks some metadata/comments, etc), so it might still be a good idea to make this original source available from GM somehow. > With a SandboxSourceFile and the correct context, I guess the rest > will come together. I guess that, if we rely on GM to provide the Sandbox source, that would be a GMSandboxSourceFile (as opposed to a general Sandbox mechanism)? > You won't see any of the GM script's top level objects this way, I > suppose they are in the sandbox object. But you can't reach them from > the web page anyway. You will see stuff when you hit a breakpoint in a > GM script. That'd be excellent already. :-) Then i'd just like to add a way for users to poke around in a script Sandbox/scope from the Firebug console tab, which implies a mean for users to select said scope -- cd(scope)? > Does this give you enough hints? That's a lot -- more than i was expecting! It's great, thanks again for that. :-) I guess i've got the big picture now, i just to work a bit more on the specifics... Anyway, i've got enough to move forward significantly. Back to work! -- Olivier --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Firebug" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/firebug?hl=en -~----------~----~----~----~------~----~------~--~---
