[Greasemonkey] say horray for evalInSandbox()

Nikolas Coukouma lists at atrus.org
Tue Jul 19 02:24:11 EDT 2005


Aaron Boodman wrote:

>I'm not sure. Here is the bug where it was moved. Perhaps you can
>track it's previous home down:
>
>https://bugzilla.mozilla.org/show_bug.cgi?id=296374
>
at the end of the patch, there's an example of how evailInSandbox used
to be work and how it works now:

RCS file: /cvsroot/mozilla/netwerk/base/src/nsProxyAutoConfig.js,v
retrieving revision 1.35
diff -u -p -r1.35 nsProxyAutoConfig.js
--- netwerk/base/src/nsProxyAutoConfig.js	25 Mar 2005 03:41:29 -0000	1.35
+++ netwerk/base/src/nsProxyAutoConfig.js	15 Jun 2005 14:19:54 -0000
@@ -74,19 +74,19 @@ nsProxyAutoConfig.prototype = {
         if (pacURI == "" || pacText == "") {
             this._findProxyForURL = null;
             this._sandBox = null;
+            return;
         }
 
         // allocate a fresh Sandbox to clear global scope for new PAC script
-        this._sandBox = new Sandbox();
+        this._sandBox = Components.util.evalInSandbox(pacUtils, pacURI);
 
         // add predefined functions to pac
-        var mypac = pacUtils + pacText;
         this._sandBox.myIpAddress = myIpAddress;
         this._sandBox.dnsResolve = dnsResolve;
         this._sandBox.alert = proxyAlert;
 
         // evaluate loaded js file
-        evalInSandbox(mypac, this._sandBox, pacURI);
+        Components.util.evalInSandbox(pacText, pacURI, this._sandBox);
         this._findProxyForURL = this._sandBox.FindProxyForURL;
     },
 

However, I've tried this and evalInSandbox is not defined. I assume
something needs to be included, but I have no idea what.
nsProxyAutoConfig.js doesn't seem to be in use (at least a search in LXR
doesn't turn up anything).

Your patch also seems to use the new XPCNativeWrapper:
new:
   http://developer-test.mozilla.org/en/docs/XPCNativeWrapper
old:
   http://kb.mozillazine.org/XPCNativeWrapper

The word "deep"

-Nikolas Coukouma


More information about the Greasemonkey mailing list