XPCSafeJSObjectWrapper

XPCSafeJSObjectWrapperはいまのところ netwerk/base/src/nsProxyAutoConfig.js でだけ明示的に使われている。

        // allocate a fresh Sandbox to clear global scope for new PAC script
        this._sandBox = new Components.utils.Sandbox(pacURI);
        Components.utils.evalInSandbox(pacUtils, this._sandBox);

        // add predefined functions to pac
        this._sandBox.importFunction(myIpAddress);
        this._sandBox.importFunction(dnsResolve);
        this._sandBox.importFunction(proxyAlert, "alert");

        // evaluate loaded js file
        Components.utils.evalInSandbox(pacText, this._sandBox);

        // We can no longer trust this._sandBox. Touching it directly can
        // cause all sorts of pain, so wrap it in an XPCSafeJSObjectWrapper
        // and do all of our work through there.
        this._sandBox = new XPCSafeJSObjectWrapper(this._sandBox);
    },

    getProxyForURI: function(testURI, testHost) {
        if (!("FindProxyForURL" in this._sandBox))
            return null;

        // Call the original function
        try {
            var rval = this._sandBox.FindProxyForURL(testURI, testHost);
        } catch (e) {
            throw XPCSafeJSObjectWrapper(e);
        }
        return rval;
    }

pacに書いてあるjsを評価するのにSandboxを使う。あれ書式jsに似てるなと思ったことがあったけどjsそのままだったんだ。
これはFirefox3のコード。

だったらXPCSafeJSObjectWrapperのないFirefox2.0.0.12はどうなってるのかなと思ってみたら

        // allocate a fresh Sandbox to clear global scope for new PAC script
        this._sandBox = new Components.utils.Sandbox(pacURI);
        Components.utils.evalInSandbox(pacUtils, this._sandBox);

        // add predefined functions to pac
        this._sandBox.importFunction(myIpAddress);
        this._sandBox.importFunction(dnsResolve);
        this._sandBox.importFunction(proxyAlert, "alert");

        // evaluate loaded js file
        Components.utils.evalInSandbox(pacText, this._sandBox);
        this._findProxyForURL = this._sandBox.FindProxyForURL;
    },

    getProxyForURI: function(testURI, testHost) {
        if (!this._findProxyForURL)
            return null;

        // Call the original function
        return this._findProxyForURL.call(this._sandBox, testURI, testHost);
    }

ふつうにsandboxで再定義された可能性のあるオブジェクトにアクセスしていた。