Forcing an HTTP request to fail in browser Forcing an HTTP request to fail in browser google-chrome google-chrome

Forcing an HTTP request to fail in browser


In Chrome (just checked v63), you can actually block a specific URL (or even a whole domain) from the Network tab. You only need to right-click on the entry and select Block request URL (or Block request domain.)


One possible solution is to modify the XMLHttpRequest objects that will be used by the browser. Running this code in a javascript console will cause all future AJAX calls on the page to be redirected to a different URL (which will probably give a 404 error):

XMLHttpRequest.prototype._old_open =  XMLHttpRequest.prototype._old_open || XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {  return XMLHttpRequest.prototype._old_open.call(    this, method, 'TEST-'+url, async, user, pass);};


Don't overlook the simplest solution: disconnect your computer from the Internet, and then trigger the AJAX call.