Reputation: 77
Hi I'm creating a Chrome extension to purposely crash a Chrome tab. My methods are not working the way I would like. I am trying:
chrome.tabs.update({url: "about:crash"});
chrome.tabs.update({url: "chrome://crash"});
window.location = 'about:crash';
window.location = 'chrome://crash';
None of these work.
However if I replace the URL with something like 'about:blank' or 'http://google.com', it works!
Does Chrome have some sort of security measure in place, if so... any suggestions for a work around?
I would like to avoid overloading the memory with infinite loops if possible.
Upvotes: 7
Views: 6434
Reputation: 37113
Got this working and packaged up as an extension. Here's the relevant code:
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
queryInfo = new Object();
chrome.tabs.query(queryInfo, function(result) {
var i;
for (i=0; i < result.length; i += 1) {
chrome.experimental.processes.getProcessIdForTab(result[i].id, function(processId) {
chrome.experimental.processes.terminate(processId);
});
}
});
});
Upvotes: 4
Reputation: 37898
Load chrome://kill
on the tab.
For example, to kill this tab on chrome, enter chrome://kill
in the URL bar and hit enter.
Extra fun as of Chrome 20: chrome://favicon/size/1/http://gonna.crash.you/
Upvotes: 7
Reputation: 2736
Use following FUN FUN LOOP as described here!
txt = "a";
while(1)
{
txt = txt += "a"; //add as much as the browser can handle
}
//<i>[evil laugh]</i> BOOM! All memory used up, and it is now <b>CRASHED</b>!
Upvotes: -2
Reputation: 1959
With the experimental processes API, you can end processes, including those that belong to tabs.
I have thought of that exact same use case - if you ever complete your extension I'd like to try it!
Though maybe a better idea for now could be for your background page could redirect tabs to a data uri based on the page, such as
data:text/html,<a href="http://www.google.com/">click here to restore</a>
or maybe an extension page that generates pages based on its query parameters:
my_extension_page.html?url=http://www.google.com/
Upvotes: 4
Reputation: 4592
The close methods of the tabs object should do that in an orderly fashion, documentation is here : http://code.google.com/chrome/extensions/tabs.html#method-remove
Cheers, T.
Upvotes: 0