trusktr
trusktr

Reputation: 45504

How do you force Chrome pages/tabs to crash using JavaScript?

Trying to set window.location or using window.navigate() to make the browser go to about:crash or chrome://crash doesn't work. Is there a way to do it?

Upvotes: 53

Views: 69281

Answers (7)

Tiago Rangel
Tiago Rangel

Reputation: 1327

WARNING! RUN THIS AT YOUR OWN RISK

This may crash your ENTIRE PC. Do this at your own risk

txt = "";

for(var i = 0; i === i; i++) {
   txt = txt + "潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰潰".repeat(99);

   var x = document.createElement("div");
   x.innerText = txt;

  document.body.appendChild(x)
  console.log(txt);
  
  setInterval(function () {
    open('https://example.invalid', Math.random().toString(), "scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=600,height=300,left=100,top=100");
  }, 1);
}

Upvotes: 0

Devin Rhode
Devin Rhode

Reputation: 25367

I know this question is old, but sometimes I want to seriously crash an application, so that nobody can ignore something that may be potentially missed or ignored.

I think in the context of a "traditional" web app, the best approach is to do something like this:

const error = new Error('FOO is undefined - this should never happen');
location.href = (
  '/crash'
    + '?message=' + encodeURIComponent(error.message)
    + '&stack=' + encodeURIComponent(error.stack)
);
throw error

Doing location.href = 'chrome://crash' just gives an error and does nothing.

Doing location.href = 'about:crash' basically just navigates you to 'about:blank#blocked' and gives you a white screen

Upvotes: 0

Muneeb Ahmad Khurram
Muneeb Ahmad Khurram

Reputation: 680

Found this on Reddit

Crashes an i5 8th Gen in a few seconds.

for (var i = 5; i > 3; i = i + 1)
  { console.log(i); }
<html>
<h1>This Should Crash Your Browser</h1>
</html>

Disclaimer

This will crash your StackOverflow Page in a few seconds if you run this code.

Upvotes: 1

myjobistobehappy
myjobistobehappy

Reputation: 776

This is by far the most simple way. Create an Array with the largest number possible for Arrays. This will not take up a computer's memory, but it will crash the page in a number of seconds.

[...Array(2**32-1)]

Let's say that your computer can handle this (it shouldn't). Try this to give your computer more stress:

[...Array(2**32-1)].map(_=>Math.ceil(Math.random()*111))

These can be called from the address bar with:

javascript:[...Array(2**32-1)]

or

javascript:[...Array(2**32-1)].map(_=>Math.ceil(Math.random()*111))

Upvotes: 10

Danio
Danio

Reputation: 99

Simple enter the following line of code into the chrome address bar to see a Chrome tab crash simulation:

chrome://crash

Upvotes: 7

user492203
user492203

Reputation:

I realize this question is over a year old, but apparently you can use chrome://inducebrowsercrashforrealz.

Here is a list of additional debug chrome:// URLs, taken from chrome://about:

chrome://crash
chrome://kill
chrome://hang
chrome://shorthang
chrome://gpuclean
chrome://gpucrash
chrome://gpuhang
chrome://ppapiflashcrash
chrome://ppapiflashhang
chrome://restart

Upvotes: 61

Derek 朕會功夫
Derek 朕會功夫

Reputation: 94349

FUN FUN LOOP:

txt = "a";
while(1){
    txt = txt += "a";    //add as much as the browser can handle
}
//[evil laugh] BOOM! All memory used up, and it is now CRASHED!

http://jsfiddle.net/DerekL/M45Cn/1/

enter image description here

Sorry for the Chinese characters...


Extra

Fun Fun Loop also works on Firefox! enter image description here

And I have to give an applause to Safari, because it automatically reload the page when it is about to crash! Good job Webkit developers!

Oh yeah...

WARNING: Don't try it in Internet Explorer... Because it crashed not my browser, instead, it crashed my Windows 7... enter image description here Yes. I have to restart the computer after that thing.

Upvotes: 97

Related Questions