2012-04-12 08:47:56 -07:00
|
|
|
/*
|
|
|
|
* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
2012-05-03 10:36:40 -07:00
|
|
|
|
|
|
|
// Tests that a remote debugger can be created in a new window.
|
|
|
|
|
|
|
|
var gWindow = null;
|
2012-04-12 08:47:56 -07:00
|
|
|
var gTab = null;
|
2012-10-01 05:16:00 -07:00
|
|
|
var gRemoteHost = null;
|
2012-06-04 03:02:32 -07:00
|
|
|
var gRemotePort = null;
|
2012-10-01 05:16:00 -07:00
|
|
|
var gRemoteTimeout = null;
|
2012-04-27 14:18:02 -07:00
|
|
|
var gAutoConnect = null;
|
2012-05-03 10:36:40 -07:00
|
|
|
|
|
|
|
const TEST_URL = EXAMPLE_URL + "browser_dbg_iframes.html";
|
2012-04-12 08:47:56 -07:00
|
|
|
|
|
|
|
function test() {
|
2012-05-03 10:36:40 -07:00
|
|
|
debug_remote(TEST_URL, function(aTab, aDebuggee, aWindow) {
|
2012-04-12 08:47:56 -07:00
|
|
|
gTab = aTab;
|
2012-05-03 10:36:40 -07:00
|
|
|
gWindow = aWindow;
|
|
|
|
let gDebugger = gWindow.contentWindow;
|
2012-04-12 08:47:56 -07:00
|
|
|
|
2012-10-01 05:16:00 -07:00
|
|
|
info("Current remote host: " +
|
|
|
|
Services.prefs.getCharPref("devtools.debugger.remote-host"));
|
2012-06-04 03:02:32 -07:00
|
|
|
info("Current remote port: " +
|
|
|
|
Services.prefs.getIntPref("devtools.debugger.remote-port"));
|
2012-10-26 13:28:54 -07:00
|
|
|
info("Current remote retries: " +
|
|
|
|
Services.prefs.getIntPref("devtools.debugger.remote-connection-retries"));
|
2012-10-01 05:16:00 -07:00
|
|
|
info("Current remote timeout: " +
|
|
|
|
Services.prefs.getIntPref("devtools.debugger.remote-timeout"));
|
2012-06-04 03:02:32 -07:00
|
|
|
info("Current autoconnect flag: " +
|
|
|
|
Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect"));
|
|
|
|
|
2012-10-26 13:28:54 -07:00
|
|
|
is(gDebugger.Prefs.remoteHost,
|
|
|
|
Services.prefs.getCharPref("devtools.debugger.remote-host"),
|
|
|
|
"Current remote host corresponds to the debugger pref.");
|
|
|
|
|
|
|
|
is(gDebugger.Prefs.remotePort,
|
|
|
|
Services.prefs.getIntPref("devtools.debugger.remote-port"),
|
|
|
|
"Current remote port corresponds to the debugger pref.");
|
|
|
|
|
|
|
|
is(gDebugger.Prefs.remoteConnectionRetries,
|
|
|
|
Services.prefs.getIntPref("devtools.debugger.remote-connection-retries"),
|
|
|
|
"Current remote retries corresponds to the debugger pref.");
|
|
|
|
|
|
|
|
is(gDebugger.Prefs.remoteTimeout,
|
|
|
|
Services.prefs.getIntPref("devtools.debugger.remote-timeout"),
|
|
|
|
"Current remote timeout corresponds to the debugger pref.");
|
|
|
|
|
|
|
|
is(gDebugger.Prefs.remoteAutoConnect,
|
|
|
|
Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect"),
|
|
|
|
"Current autoconnect flag corresponds to the debugger pref.");
|
|
|
|
|
|
|
|
|
2012-05-03 10:36:40 -07:00
|
|
|
is(gDebugger.document.getElementById("close").getAttribute("hidden"), "true",
|
|
|
|
"The close button should be hidden in a remote debugger.");
|
2012-04-12 08:47:56 -07:00
|
|
|
|
2012-05-03 10:36:40 -07:00
|
|
|
is(gDebugger.DebuggerController.activeThread.paused, false,
|
|
|
|
"Should be running after debug_remote.");
|
|
|
|
|
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
|
|
|
Services.tm.currentThread.dispatch({ run: function() {
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
let frames = gDebugger.DebuggerView.StackFrames._container._list;
|
2012-05-03 10:36:40 -07:00
|
|
|
let childNodes = frames.childNodes;
|
|
|
|
|
|
|
|
is(gDebugger.DebuggerController.activeThread.paused, true,
|
|
|
|
"Should be paused after an interrupt request.");
|
|
|
|
|
|
|
|
is(frames.querySelectorAll(".dbg-stackframe").length, 1,
|
|
|
|
"Should have one frame in the stack.");
|
|
|
|
|
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("resumed", function() {
|
|
|
|
Services.tm.currentThread.dispatch({ run: function() {
|
2012-05-31 03:01:13 -07:00
|
|
|
closeDebuggerAndFinish(true);
|
2012-05-03 10:36:40 -07:00
|
|
|
}}, 0);
|
|
|
|
});
|
2012-04-12 08:47:56 -07:00
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
EventUtils.sendMouseEvent({ type: "mousedown" },
|
2012-05-03 10:36:40 -07:00
|
|
|
gDebugger.document.getElementById("resume"),
|
|
|
|
gDebugger);
|
|
|
|
}}, 0);
|
|
|
|
});
|
2012-04-12 08:47:56 -07:00
|
|
|
|
2012-05-03 10:36:40 -07:00
|
|
|
let iframe = gTab.linkedBrowser.contentWindow.wrappedJSObject.frames[0];
|
2012-04-12 08:47:56 -07:00
|
|
|
|
2012-05-03 10:36:40 -07:00
|
|
|
is(iframe.document.title, "Browser Debugger Test Tab", "Found the iframe");
|
2012-04-12 08:47:56 -07:00
|
|
|
|
2012-05-03 10:36:40 -07:00
|
|
|
iframe.runDebuggerStatement();
|
2012-04-27 14:18:02 -07:00
|
|
|
},
|
|
|
|
function beforeTabAdded() {
|
|
|
|
if (!DebuggerServer.initialized) {
|
2012-06-01 08:25:08 -07:00
|
|
|
DebuggerServer.init(function() { return true; });
|
2012-04-27 14:18:02 -07:00
|
|
|
DebuggerServer.addBrowserActors();
|
|
|
|
}
|
|
|
|
DebuggerServer.closeListener();
|
|
|
|
|
2012-10-01 05:16:00 -07:00
|
|
|
gRemoteHost = Services.prefs.getCharPref("devtools.debugger.remote-host");
|
2012-06-04 03:02:32 -07:00
|
|
|
gRemotePort = Services.prefs.getIntPref("devtools.debugger.remote-port");
|
2012-10-01 05:16:00 -07:00
|
|
|
gRemoteTimeout = Services.prefs.getIntPref("devtools.debugger.remote-timeout");
|
2012-04-27 14:18:02 -07:00
|
|
|
gAutoConnect = Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect");
|
|
|
|
|
|
|
|
// Open the listener at some point in the future to test automatic reconnect.
|
2012-10-01 05:16:00 -07:00
|
|
|
openListener(gRemoteHost, gRemotePort + 1, gRemoteTimeout / 10);
|
2012-04-12 08:47:56 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-06-04 03:02:32 -07:00
|
|
|
let attempts = 0;
|
|
|
|
|
2012-10-01 05:16:00 -07:00
|
|
|
function openListener(host, port, timeout) {
|
|
|
|
Services.prefs.setCharPref("devtools.debugger.remote-host", host);
|
2012-06-04 03:02:32 -07:00
|
|
|
Services.prefs.setIntPref("devtools.debugger.remote-port", port);
|
2012-10-01 05:16:00 -07:00
|
|
|
Services.prefs.setIntPref("devtools.debugger.remote-timeout", timeout);
|
2012-06-04 03:02:32 -07:00
|
|
|
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.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-12 08:47:56 -07:00
|
|
|
registerCleanupFunction(function() {
|
2012-10-01 05:16:00 -07:00
|
|
|
Services.prefs.setCharPref("devtools.debugger.remote-host", gRemoteHost);
|
2012-06-04 03:02:32 -07:00
|
|
|
Services.prefs.setIntPref("devtools.debugger.remote-port", gRemotePort);
|
2012-10-01 05:16:00 -07:00
|
|
|
Services.prefs.setIntPref("devtools.debugger.remote-timeout", gRemoteTimeout);
|
2012-04-27 14:18:02 -07:00
|
|
|
Services.prefs.setBoolPref("devtools.debugger.remote-autoconnect", gAutoConnect);
|
2012-04-12 08:47:56 -07:00
|
|
|
removeTab(gTab);
|
2012-05-03 10:36:40 -07:00
|
|
|
gWindow = null;
|
2012-04-12 08:47:56 -07:00
|
|
|
gTab = null;
|
2012-10-01 05:16:00 -07:00
|
|
|
gRemoteHost = null;
|
2012-06-04 03:02:32 -07:00
|
|
|
gRemotePort = null;
|
2012-10-01 05:16:00 -07:00
|
|
|
gRemoteTimeout = null;
|
2012-04-27 14:18:02 -07:00
|
|
|
gAutoConnect = null;
|
2012-04-12 08:47:56 -07:00
|
|
|
});
|