зеркало из https://github.com/mozilla/gecko-dev.git
Bug 878472 - Let local debugger clients find the DebuggerServerConnection. r=past
This commit is contained in:
Родитель
f90033009f
Коммит
dce1c3abcb
|
@ -27,18 +27,15 @@ function test()
|
|||
is(aResponse.pong, "pong", "Actor should respond to requests.");
|
||||
|
||||
// Make sure that lazily-created actors are created only once.
|
||||
let connections = Object.keys(DebuggerServer._connections);
|
||||
info(connections.length + " connections are established.");
|
||||
let connPrefix = connections[connections.length - 1];
|
||||
ok(DebuggerServer._connections[connPrefix],
|
||||
connPrefix + " is a valid connection.");
|
||||
let conn = transport._serverConnection;
|
||||
// First we look for the pool of global actors.
|
||||
let extraPools = DebuggerServer._connections[connPrefix]._extraPools;
|
||||
let extraPools = conn._extraPools;
|
||||
|
||||
let globalPool;
|
||||
for (let pool of extraPools) {
|
||||
if (Object.keys(pool._actors).some(function(elem) {
|
||||
// Tab actors are in the global pool.
|
||||
let re = new RegExp(connPrefix + "tab", "g");
|
||||
let re = new RegExp(conn._prefix + "tab", "g");
|
||||
return elem.match(re) !== null;
|
||||
})) {
|
||||
globalPool = pool;
|
||||
|
@ -46,7 +43,7 @@ function test()
|
|||
}
|
||||
}
|
||||
// Then we look if the global pool contains only one test actor.
|
||||
let actorPrefix = connPrefix + "testone";
|
||||
let actorPrefix = conn._prefix + "testone";
|
||||
let actors = Object.keys(globalPool._actors).join();
|
||||
info("Global actors: " + actors);
|
||||
isnot(actors.indexOf(actorPrefix), -1, "The test actor exists in the pool.");
|
||||
|
|
|
@ -267,11 +267,29 @@ var DebuggerServer = {
|
|||
let serverTransport = new LocalDebuggerTransport;
|
||||
let clientTransport = new LocalDebuggerTransport(serverTransport);
|
||||
serverTransport.other = clientTransport;
|
||||
this._onConnection(serverTransport);
|
||||
let connection = this._onConnection(serverTransport);
|
||||
|
||||
// I'm putting this here because I trust you.
|
||||
//
|
||||
// There are times, when using a local connection, when you're going
|
||||
// to be tempted to just get direct access to the server. Resist that
|
||||
// temptation! If you succumb to that temptation, you will make the
|
||||
// fine developers that work on Fennec and Firefox OS sad. They're
|
||||
// professionals, they'll try to act like they understand, but deep
|
||||
// down you'll know that you hurt them.
|
||||
//
|
||||
// This reference allows you to give in to that temptation. There are
|
||||
// times this makes sense: tests, for example, and while porting a
|
||||
// previously local-only codebase to the remote protocol.
|
||||
//
|
||||
// But every time you use this, you will feel the shame of having
|
||||
// used a property that starts with a '_'.
|
||||
clientTransport._serverConnection = connection;
|
||||
|
||||
return clientTransport;
|
||||
},
|
||||
|
||||
|
||||
// nsIServerSocketListener implementation
|
||||
|
||||
onSocketAccepted:
|
||||
|
@ -318,6 +336,8 @@ var DebuggerServer = {
|
|||
conn.addActor(conn.rootActor);
|
||||
aTransport.send(conn.rootActor.sayHello());
|
||||
aTransport.ready();
|
||||
|
||||
return conn;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче