Reed
Reed

Reputation: 1638

How to consistently crash IE 10&11? Reproducing "Internet Explorer to close and reopen the tab"

This is a stupid question. Is there a way to consistently produce this error in Internet Explorer 10&11 with Javascript, css or HTML?

A problem with this webpage caused Internet Explorer to close and reopen the tab.

This is not for malicious webpage, I need to test some plugin and simulate the situation where IE crashes.

Are there any known issue that in all versions of IE will cause it to show this error?

Upvotes: 3

Views: 1087

Answers (1)

Coty Embry
Coty Embry

Reputation: 978

tldr; @CodingIntrigue's comment worked for me in Internet Explorer 11

You could use at runtime in your html logic:

<script type="text/javascript">
    while(true) {}    //stop messing around and crash this window and let the default IE11 browser behavior open a new one
</script>

Note: my browser window was already full of memory crashing basically at this point so getting the error to happen was easy and happened 100% of the time quickly, but I'm seeing on other pages that are more skeleton this doesn't crash IE11 as easy/reliably or quickly/immediately

IE11 has a memory leak for my javascript react webapp and I was trying to do a window.open to get a fresh memory start for my app, then I wanted to window.close the current window due to IE11 related memory leaks as described here to free the memory of the window in the browser while the user is using it.

The issue is I could not get window.open to work within the memory full error callback because the memory was so full it just couldn't do it, but forcing IE11 to run this default/internal A problem with this webpage caused Internet Explorer to close and reopen the tab. error flow accomplishes the same effect. You might not care, but the next code is how my use case was using this while loop logic/strategy. I added a place for unhandled promises (it doesn't always fire if they are handled I think like inside my react logic)

window.addEventListener('error', function(e) {                     //respond to errors

    var errorMessage = e && e.message ? e.message.toString() : '',
        errorType = e && e.type ? e.type.toString() : '',
        targetNodeName = e && e.target && e.target.nodeName ? 
        e.target.nodeName.toString().toUpperCase() : '';

    //personally I added more if else logic here to only do this when necessary based on `errorMessage` and `errorType`
    while(true) {}    //stop messing around and crash this window and let the default IE11 browser behavior open a new one

})


window.addEventListener('unhandledrejection', function(e) {
    //Note - I have not got this callback invoked yet
    var errorMessage = e && e.message ? e.message : '';
    console.log('in unhandledrejection callback listener: ' + errorMessage, e);
}, true);       //`, true` to set `useCapture` Boolean

this next part is if you need to fill up the memory (I never could get it to work - but my memory is getting filled up anyways so I didnt need to mess with it too much) I got this from @Jaroslav Tulach's answer. Youll have to figure it out from there, its not exactly trimmed to your question

function gc(max) {
    var arr = [];
    for (var i = 0; i < max; i++) {
      arr.push(i);
    }
    return arr.length;
}
//now attempt to force IE11 garbage collector to run
for (var i = 0; i < 10; i++) {                  // repeat until you have enough:                    
    gc(Math.pow(2, i));
}

Upvotes: 2

Related Questions