views:

192

answers:

3

I'm part of a testing team and have been tasked with "behaving badly" using javascript in a firefox browser. I've tried these methods to take the browser down http://www.yuki-onna.co.uk/browserdeath.html but none of them do anything worse than cause a popup asking to shut down the script.

Any other ideas?

+5  A: 

The script-execution-time watchdog is nice and all, but it doesn't solve the modal-loop problem. Going to an alert, confirm or prompt box stops the timer, making this:

<script>while(true) alert('alert bomb');</script>

difficult to escape from, and this:

<body onbeforeunload="while(true) alert('alert bomb');">

effectively impossible. (Have your Task Manager handy.)

Using difficult-to-escape modal loops was a favourite tactic of aggressive spyware installer pages. (“Click Yes to install VomitBar now or face endless alert boxes...”)

bobince
Chrome > Firefox on this one :); http://tinypic.com/r/54smer/5
Matt
One of the most annoying things ... ever!
pst
Chrome offers the option to terminate the script after the first box.
George Edison
A: 

I managed to crash my Firefox repeatedly, by doing a massive DOM insertion of approximately 10,000+ elements.

Basically, the user clicks a button to trigger an jQuery AJAX call. The call would return a full HTML file, which would be appended to a specific div with jQuery.

<script>
  $("div.content").empty();
  $("div.content").html(data);
</script>

Then once the data was added it would attempt to parse that entire muck of data and add onClick and onHover events to basically every element in the tree.

Rest assured, every time I ran this function, my browser crashed. It would bring up the usual "a script is running slowly do you want to cancel it", but I could never cancel it, and always had to CTRL+ALT+DEL it.

Just FYI, I never planned on doing a 10,000 element insertion it was an error on my part. I was querying a database with a JOIN and meant to do SELECT DISTINCT, and instead did SELECT so instead of returning 100 elements, I returned 10,000 due to the joins. Whoops.

Owen Allen
+2  A: 

Somewhat akin to a "fork bomb"

<html>
<body>
<a href="#" onclick="die()">click me!</a>
<script>
function die () {
  setTimeout(function () {die(); die()}, 0)
}
</script>
</body>
</html>

It is not stoppable by FF 3.6 and below (unless the user happens to close the violating tab soon enough). The longer you let it run the more vicious it will get. Eventually it will eat up all the memory available to the process. The load on the CPU should increase as well. Some operating systems will cope with a mis-behaving FF better than others. You can make this more degenerate if you also apply an appropriate load to the DOM each cycle.

Edit: "Use this knowledge only for the good of the world." :-)

pst