With the changes performed in 
https://github.com/greasemonkey/greasemonkey/issues/issue/1258
, a bug arises.
The change performed can crash scripts worked before 0.91. In version
0.90 and before, the window variable was shared between scripts. The
following example works:
    // ==UserScript==
    // @name           Script1
    // @namespace      http://test.free.fr
    // @description    Script1
    // @include        *
    // ==/UserScript==
    window.a=1;
-
    // ==UserScript==
    // @name           Script2
    // @namespace      http://test.free.fr
    // @description    Script2
    // @include        *
    // ==/UserScript==
    alert(a);

And with this change, the second script crashes.


A workaround trying to solve the bug and maintaining the backward
compatibility is:

    var unsafeContentWin = wrappedContentWin.wrappedJSObject;
    +    var safeContentWin = new XPCNativeWrapper(unsafeContentWin);

    // detect and grab reference to firebug console and context, if it
exists
    var firebugConsole = this.getFirebugConsole(unsafeContentWin,
chromeWin);

    for (var i = 0; script = scripts[i]; i++) {
     ...
      // Re-wrap the window before assigning it to the
sandbox.__proto__
      // This is a workaround for a bug in which the Security Manager
      // vetoes the use of eval.
    -     sandbox.__proto__ = new XPCNativeWrapper(unsafeContentWin);
     +    sandbox.__proto__ = safeContentWin;

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" 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/greasemonkey-users?hl=en.

Reply via email to