2.6.8.29 tab opening bookmarklet regression

Bug reports and enhancement requests
Post Reply
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

2.6.8.29 tab opening bookmarklet regression

Post 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
Last edited by al_9x on Sat Jun 28, 2014 2:13 am, edited 1 time in total.
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: 2.6.8.29 tab opening bookmarklet regression

Post by al_9x »

Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
barbaz
Senior Member
Posts: 10841
Joined: Sat Aug 03, 2013 5:45 pm

Re: 2.6.8.29 tab opening bookmarklet regression

Post 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.
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0 (PaleMoon)
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: 2.6.8.29 tab opening bookmarklet regression

Post by al_9x »

this is actually easily reproducible, it happens when the active tab at the time of bookmarklet invocation is not script allowed
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: 2.6.8.29 tab opening bookmarklet regression

Post 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?
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
barbaz
Senior Member
Posts: 10841
Joined: Sat Aug 03, 2013 5:45 pm

Re: 2.6.8.29 tab opening bookmarklet regression

Post by barbaz »

al_9x wrote:What prompted the introduction of _bypass in .29?
probably http://forums.informaction.com/viewtopi ... 10&t=19728
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0 (PaleMoon)
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: 2.6.8.29 tab opening bookmarklet regression

Post 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;
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: 2.6.8.29 tab opening bookmarklet regression

Post by Giorgio Maone »

Fixed in latest development build 2.6.8.30rc5, thank you.
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: 2.6.8.29 tab opening bookmarklet regression

Post 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?
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: 2.6.8.29 tab opening bookmarklet regression

Post 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.
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Post Reply