[Greasemonkey] Re: sandboxCtor

Travis Choma travischoma at gmail.com
Fri Oct 7 17:33:39 EDT 2005


I solved my problem by changing the line in GM_DocHandler.prototype.snarf()

from:
this.sandboxCtor = this.unsafeContentWin.Object
to:
this.sandboxCtor = this.unsafeContentWin.Object.constructor.

Now there is no more unexpected errors, and the injected javascript runs
fine and can access the GM api.

I got the idea from browsing some of the older versions of dochandler.js. I
would be thankful if anyone has any intuitive explanation for this.

Best regards,
-Travis

On 10/7/05, Travis Choma <travischoma at gmail.com> wrote:
>
> Hello,
>
> I wanted to turn one of my greasemonkey scripts into an extension but
> still be able to use the GM api to make xmlhttpRequests outside the current
> domain.
> So i took the downloaded the latest CVS snapshot and striped it down to
> the essentials (modified versions of Browser.js,DocHandlers.js,
> xmlhttpRequester.js,Utils.js).
> However I get an unexpected error from this line:
>
> var sandbox = new this.sandboxCtor();
>
> I checked and the reference has already been snarfed, if I printout
> this.sandboxCtor it is of the following type:
>
> function XPCNativeWrapper function wrapper() {
> [native code]
> }
>
> Now if I change the line to: var sandbox = this.sandboxCtor everything
> proceeds fine but I then I get unexpected
> errors in the injected script (when creating new Objects and calling GM
> api functions).
>
> Any ideas why constructing the new sandbox object fail? I am running
> firefox 1.5b1. Is this a known problem?
>
> Best regards,
> -Travis
>
>
>


More information about the Greasemonkey mailing list