I'm testing an AJAX application where we need to handle a temporary loss of connection to the server or other errors (i.e. like in Gmail or Google Calendar.) What's a good way to simulate this in testing?
For example, is there a browser plugin that will allow one to temporarily "turn off" the internet connection for a tab? I do all my debugging in Chrome so it would be particularly helpful if someone could offer a suggestion for that browser.
Other options I've tried are toggling the network connection to a VM to the server, or shutting down the server and restarting it, neither of which is very lightweight or easy for testing (the latter also doesn't preserve any state.)
Clarification: I'm not interested in how to test disconnection handling in test code. I want to create a disconnection to test when running my app. Ideally, it could be something easily toggled in one tab of my browser that doesn't involve borking my entire internet connection.