Page 1 of 1

2.6.8.29 tab opening bookmarklet regression

Posted: Fri Jun 27, 2014 3:14 pm
by al_9x
Fx 24.6.0 & 30.0.0, NS 2.6.8.29 & 2.6.8.30rc4 (.28 is ok), new profile

when opening (click or keyword) bookmarklets that open multiple tabs:

Code: Select all

javascript:open('https://www.google.com/','_self');open('https://www.mozilla.org/');
from a tab that's not script allowed, no tabs open, only the _self navigation takes place

the following is logged in the browser console:

Code: Select all

"InternalError: too much recursion" JSURL.js:81
with .28, tabs open and no error is logged

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Fri Jun 27, 2014 3:22 pm
by al_9x

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Sat Jun 28, 2014 1:26 am
by barbaz
Confirmed.

With NS 2.6.8.30rc4 & my normal profile:
- Not working at all in PaleMoon 24.6.2.
- Works in SeaMonkey 2.27a2 if the page on which that bookmarklet is run is allowed to run JavaScript.

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Sat Jun 28, 2014 2:07 am
by al_9x
this is actually easily reproducible, it happens when the active tab at the time of bookmarklet invocation is not script allowed

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Sat Jun 28, 2014 4:36 am
by al_9x

Code: Select all

        function patch(o, m, f) {
            var saved = o[m];
            f._restore = function() { o[m] = saved };
            f._bypass = saved;
            o[m] = f;
        }
        
        patch(w, "open", function() {
          return patchAll(w.open._bypass.apply(w, arguments));  
        });
open(,'_self') does not return a new window so it gets double patched and w.open._bypass ends up with the patched open.

Code: Select all

  _patch: (function() {
      (function patchAll(w) {
        if (!w || w.open._restore) return w;
        
        var d = w.document;
        
        function op(data) {
          var code = "Object.getPrototypeOf(document)." + 
             (typeof(data) === "string"
               ? 'write.call(document, ' + JSON.stringify(data) + ')'
               : 'open.call(document)'
             );
          var s = d.createElement("script");
          s.appendChild(d.createTextNode(code));
          var p = d.documentElement;
          p.appendChild(s);
          p.removeChild(s);
          if (d.write === Object.getPrototypeOf(d).write) {
            patchAll(w);
          }
        }
        function patch(o, m, f) {
            var saved = o[m];
            f._restore = function() { o[m] = saved };
            o[m] = f;
        }
        
        patch(d, "open", function() { op(null) });
        patch(d, "write", function(s) {
            op(typeof(s) === "string" ? s : "" + s); 
        });
        patch(d, "writeln", function(s) { this.write(s + "\n") });
        
        patch(w, "open", function() {
          return patchAll(Object.getPrototypeOf(w).open.apply(w, arguments));
        });
        
        return w;
      })(window);
  }).toSource() + "()",
What prompted the introduction of _bypass in .29?

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Sat Jun 28, 2014 5:02 pm
by barbaz
al_9x wrote:What prompted the introduction of _bypass in .29?
probably http://forums.informaction.com/viewtopi ... 10&t=19728

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Sat Jun 28, 2014 6:51 pm
by al_9x
so window methods are no longer in the prototype but in the instance, why did they do that?

fix

Code: Select all

      (function patchAll(w) {
        if (!w || w.open._bypass) return w;

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Mon Jun 30, 2014 11:45 am
by Giorgio Maone
Fixed in latest development build 2.6.8.30rc5, thank you.

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Mon Jun 30, 2014 1:37 pm
by al_9x
Giorgio Maone wrote:Fixed in latest development build 2.6.8.30rc5, thank you.
Do you know why the window methods are no longer on the prototype?

Code: Select all

        if (!w || w.open && w.open._bypass)
          return null;
Shouldn't this return w?

Re: 2.6.8.29 tab opening bookmarklet regression

Posted: Mon Jun 30, 2014 2:17 pm
by Giorgio Maone
al_9x wrote:
Giorgio Maone wrote:Fixed in latest development build 2.6.8.30rc5, thank you.
Do you know why the window methods are no longer on the prototype?
Nope.
al_9x wrote:

Code: Select all

        if (!w || w.open && w.open._bypass)
          return null;
Shouldn't this return w?
Yep, typo, fixed in latest development build 31rc1, thanks.