Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Make sure 'print' is not used directly in envjs

#124

A webpage from a Large Site had this tidbit.

function print(pageName) {
    window.open(pageName, "Print", "scrollbars=yes,menubar=yes,resizable=yes,width=680,height=430,top=125,left=325");
}

print('foo');

If you run this, envjs exhausts all memory and explodes depending how you have it configured since it can go into an infinite loop. This was not fun tracing or debugging. Boo.

Redefining print aka window.print is legit, so one could do this type of switcheroo:


Envjs.print = print

Then make sure anyone who uses print calls Envjs.print instead. OR use console.log and make sure does the equiv (i.e. Console.print = print).

Really this might be more a documentation issue than a code issue, since print should be used in very few places, but the API/callbacks might use it, causing my infinite loop.

Reported by nickg · March 21st, 2010 @ 12:36 PM

State: resolved
Milestone: none
Assigned to: nickg nickg

Activity

  1. nickg
    nickg
    • State changed from new to open

    This is easier than I expected since the groundwork has already been laid. All that needs to change is in src/platform/rhino/console.js

    Envjs.log = function(msg) {
      print(msg);
    }
    

    to

    Envjs.log = print;
    

    console calls Envjs.log instead of using print directly (nice work whoever did this. Thank you!).

    I'll let this bake for a bit to see if anyone has objections/comments.

    --nickg

    March 21st, 2010 @ 02:41 PM

  2. nickg

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.