开发者

Crash firefox using JavaScript [closed]

开发者 https://www.devze.com 2022-12-28 04:22 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学Python
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学Python

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 5 years ago.

Improve this question

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, but none of them do anything worse than cause a popup asking to shut down the script.

Any other ideas?


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." :-)


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...”)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消