mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-06 00:55:37 +00:00
c74418115e
* Made the DebuggerClient, which is actually the RootActor front, not consider one of the attached child fronts as "active". Since a single DebuggerClient (or RootFront) is kept around for the App Manager's lifetime, it makes sense to move the notion of "active" tab to the toolbox's target. As each toolbox gets destroyed, the fronts should be detaching from their actors (if they are stateful) so that the app is no longer in a debugging state. Debugging a new app (or reconnecting to a previous one) will create new fronts anyway. * Slightly refactored the TabClient, ThreadClient, SourceClient and TracerClient towards a protocol.js-based architecture, by adding parent-child references and lifecycle management. Now a tab-scoped thread actor for instance has the tab as its parent, while a global-scoped thread actor (chrome debugger) has the DebuggerCLient (RootFront) as its parent. This lets parents reference their children, so that caching in the target object can work. It also allowed me to move some methods from the DebuggerClient to the actual front that should be responsible, like reconfigureTab, reconfigureThread and attachThread. These methods now use DebuggerClient.requester, too. * Added some error handling in the debugger client requester around "before" and "after" callbacks, which exposed some errors in tests that are now fixed. * Fixed the state handling in the thread actor so that merely detaching from a thread doesn't put it in the exited state. This is the part that what was necessary for Firebug's use case. * Properly loading tracer and webgl actors now on b2g.
77 lines
2.1 KiB
JavaScript
77 lines
2.1 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
|
|
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
|
|
|
|
var gClient;
|
|
var gTabClient;
|
|
var gDebuggee;
|
|
|
|
function run_test()
|
|
{
|
|
initTestDebuggerServer();
|
|
gDebuggee = testGlobal("test-1");
|
|
DebuggerServer.addTestGlobal(gDebuggee);
|
|
|
|
let transport = DebuggerServer.connectPipe();
|
|
gClient = new DebuggerClient(transport);
|
|
gClient.connect(function(aType, aTraits) {
|
|
attachTestTab(gClient, "test-1", function(aReply, aTabClient) {
|
|
gTabClient = aTabClient;
|
|
test_threadAttach(aReply.threadActor);
|
|
});
|
|
});
|
|
do_test_pending();
|
|
}
|
|
|
|
function test_threadAttach(aThreadActorID)
|
|
{
|
|
do_print("Trying to attach to thread " + aThreadActorID);
|
|
gTabClient.attachThread({}, function(aResponse, aThreadClient) {
|
|
do_check_eq(aThreadClient.state, "paused");
|
|
do_check_eq(aThreadClient.actor, aThreadActorID);
|
|
aThreadClient.resume(function() {
|
|
do_check_eq(aThreadClient.state, "attached");
|
|
test_debugger_statement(aThreadClient);
|
|
});
|
|
});
|
|
}
|
|
|
|
function test_debugger_statement(aThreadClient)
|
|
{
|
|
aThreadClient.addListener("paused", function(aEvent, aPacket) {
|
|
do_check_eq(aThreadClient.state, "paused");
|
|
// Reach around the protocol to check that the debuggee is in the state
|
|
// we expect.
|
|
do_check_true(gDebuggee.a);
|
|
do_check_false(gDebuggee.b);
|
|
|
|
let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
|
|
do_check_eq(xpcInspector.eventLoopNestLevel, 1);
|
|
|
|
aThreadClient.resume(cleanup);
|
|
});
|
|
|
|
Cu.evalInSandbox("var a = true; var b = false; debugger; var b = true;", gDebuggee);
|
|
|
|
// Now make sure that we've run the code after the debugger statement...
|
|
do_check_true(gDebuggee.b);
|
|
}
|
|
|
|
function cleanup()
|
|
{
|
|
gClient.addListener("closed", function(aEvent) {
|
|
do_test_finished();
|
|
});
|
|
|
|
try {
|
|
let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
|
|
do_check_eq(xpcInspector.eventLoopNestLevel, 0);
|
|
} catch(e) {
|
|
dump(e);
|
|
}
|
|
|
|
gClient.close();
|
|
}
|