Bug 753225 - Intermittent browser_dbg_createRemote.js; r=past

This commit is contained in:
Victor Porof 2012-06-04 13:02:32 +03:00
parent ffc9ccb766
commit 28f8993d4d
2 changed files with 45 additions and 5 deletions

View File

@ -123,6 +123,7 @@ let DebuggerController = {
this._remoteConnectionTimeout = window.setTimeout(function() {
// If we couldn't connect to any server yet, try again...
if (!DebuggerController.activeThread) {
DebuggerController._onRemoteConnectionTimeout();
DebuggerController._connect();
}
}, Prefs.remoteTimeout);
@ -130,6 +131,14 @@ let DebuggerController = {
return true;
},
/**
* Called when a remote connection timeout occurs.
*/
_onRemoteConnectionTimeout: function DC__onRemoteConnectionTimeout() {
Cu.reportError("Couldn't connect to " +
Prefs.remoteHost + ":" + Prefs.remotePort);
},
/**
* Initializes a debugger client and connects it to the debugger server,
* wiring event handlers as necessary.

View File

@ -7,6 +7,7 @@
var gWindow = null;
var gTab = null;
var gRemotePort = null;
var gAutoConnect = null;
const TEST_URL = EXAMPLE_URL + "browser_dbg_iframes.html";
@ -17,6 +18,11 @@ function test() {
gWindow = aWindow;
let gDebugger = gWindow.contentWindow;
info("Current remote port: " +
Services.prefs.getIntPref("devtools.debugger.remote-port"));
info("Current autoconnect flag: " +
Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect"));
is(gDebugger.document.getElementById("close").getAttribute("hidden"), "true",
"The close button should be hidden in a remote debugger.");
@ -60,21 +66,46 @@ function test() {
}
DebuggerServer.closeListener();
gRemotePort = Services.prefs.getIntPref("devtools.debugger.remote-port");
gAutoConnect = Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect");
Services.prefs.setBoolPref("devtools.debugger.remote-autoconnect", true);
// Open the listener at some point in the future to test automatic reconnect.
window.setTimeout(function() {
DebuggerServer.openListener(
Services.prefs.getIntPref("devtools.debugger.remote-port"));
}, Math.random() * 1000);
openListener(gRemotePort + 1);
});
}
let attempts = 0;
function openListener(port) {
Services.prefs.setIntPref("devtools.debugger.remote-port", port);
Services.prefs.setBoolPref("devtools.debugger.remote-autoconnect", true);
info("Attempting to open a new listener on port " + port);
try {
info("Closing listener...");
DebuggerServer.closeListener();
info("Opening listener...");
DebuggerServer.openListener(port);
} catch (e) {
info(e);
info("Exception caught when opening listener on port " + port);
info("Retrying with port " + (++port));
if (++attempts < 100) {
DebuggerServer.closeListener();
openListener(port);
} else {
ok(false, "Timed out while opening a listener.");
}
}
}
registerCleanupFunction(function() {
Services.prefs.setIntPref("devtools.debugger.remote-port", gRemotePort);
Services.prefs.setBoolPref("devtools.debugger.remote-autoconnect", gAutoConnect);
removeTab(gTab);
gWindow = null;
gTab = null;
gRemotePort = null;
gAutoConnect = null;
});