On Thu, Aug 20, 2009 at 06:32, johnjbarton<[email protected]> wrote:
> On Aug 19, 1:16 pm, Olivier Cornu <[email protected]> wrote:
>>
>> For the sake of completion: the empty "this" issue was because the
>> Sandbox object has no hasOwnProperty(), __lookupGetter___() and
>> __lookupSetter__() methods -- dom.js needs them to correctly print the
>> object hierarchy. If i put dummy implementations of these methods
>> everything works fine.  :-)
>
> Ok, more evidence that the Sandbox is half-baked ;-)

I kind of remember i read somewhere there was a point it, though...
Whatever: it works.  :-)


>> Also, very interestingly: "As of Firefox 3.5/Gecko 1.9.1, it's
>> possible to optionally specify the JS version, filename, and line
>> number of the code being evaluated" [1].
>> This means it seems possible for the Firebug-1.5 to support sandboxed
>> scripts debugging (when they provide such information) without too
>> many changes: they pretty much look like other top-level scripts. The
>> only thing needed is a way for getFrameScopeWindowAncestor() to
>> discover which window the script should be attached to (if any).

I can confirm patching getFrameScopeWindowAncestor() is enough to
correctly debug GM scripts: no need to mess further with Firebug core
code (no need for a onSandboxScriptCreated() handler nor a new
SandboxSourceFile object). Sandboxed scripts are successfully treated
like other top-level scripts.

>> The most generic test i've found (also working with GM) is the
>> following: if the sandbox prototype is a Window (or a XPCNW of a
>> Window) return it, otherwise the sandboxed script is ignored. It
>> probably makes sense to debug sandboxed scripts which are as tied to a
>> Window as that, although it's not a perfect test to filter relevant
>> sandboxed scripts...
>
> But that assumes a specific model for how the sandbox is used. On the
> other hand, as far as I know GM is the only user of the sandbox, so
> why not.

Yes, it's not generic enough to cover every Window-mangling sandboxed
script possible. In fact, it's probably impossible to detect all
Window-mangling sandboxed scripts without "prior knowledge": somehow,
FB and tiers chrome code will have to share common assumptions about
where in the sandbox is the Window reference. In which case i suppose
we have to rely on "obvious" locations if we want to keep it simple:
the sandbox prototype, a sandbox property called "window"...
An alternative would be for FB to offer an API tiers code can use to
register their own getWindowFromSandbox() handler.

Back to debugging GM in particular, the new evalInSandbox() signature
is a blessing, even more so in case of concatenated scripts (the
so-called complex case -- GM @require tag). GM used to evalInSandbox()
a single string which was the concatenation of all needed source
files. If, instead, GM does evalInSandbox() each one of them in turn,
passing the proper filename/line number of the code being evaled,
everything works perfectly: all files appear in the debugger tab and
you can set breakpoints, etc, in anyone of them.
In other words, our original goal is reached with a very simple FB
core patch (attached)!  :-)


-- 
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
-~----------~----~----~----~------~----~------~--~---

Index: components/firebug-service.js
===================================================================
--- components/firebug-service.js	(révision 4044)
+++ components/firebug-service.js	(copie de travail)
@@ -2609,6 +2609,16 @@
             //        FBTrace.sysout("fbs.getFrameScopeWindowAncestor found WorkerGlobalScope.location: "+workerScope.location, workerScope.location);
             return lastWindowScope;
         }
+
+        if (scope.jsClassName == "Sandbox")
+        {
+            var proto = scope.jsPrototype;
+            if (proto.jsClassName == "XPCNativeWrapper")
+                proto = proto.jsParent;
+            if (proto.jsClassName == "Window")
+                return proto.getWrappedValue();
+        }
+
         if (FBTrace.DBG_FBS_FINDDEBUGGER)
             FBTrace.sysout("fbs.getFrameScopeWindowAncestor found scope chain bottom, not Window: "+scope.jsClassName, scope);
     }
Index: content/firebug/debugger.js
===================================================================
--- content/firebug/debugger.js	(révision 4044)
+++ content/firebug/debugger.js	(copie de travail)
@@ -3693,6 +3693,15 @@
         if (scope.jsClassName == "Window" || scope.jsClassName == "ChromeWindow")
             return  scope.getWrappedValue();
 
+        if (scope.jsClassName == "Sandbox")
+        {
+            var proto = scope.jsPrototype;
+            if (proto.jsClassName == "XPCNativeWrapper")
+                proto = proto.jsParent;
+            if (proto.jsClassName == "Window")
+                return proto.getWrappedValue();
+        }
+
         if (FBTrace.DBG_FBS_FINDDEBUGGER)
             FBTrace.sysout("debugger.getFrameScopeWindowAncestor found scope chain bottom, not Window: "+scope.jsClassName, scope);
     }

Reply via email to