Bug 790952 - Debugger server always creates new actor instances. f=glandium r=rcampbell

This commit is contained in:
Panos Astithas 2012-09-21 09:04:21 +03:00
Родитель f1424f9023
Коммит f4d41c8144
2 изменённых файлов: 37 добавлений и 2 удалений

Просмотреть файл

@ -22,7 +22,39 @@ function test()
"testTabActor's actorPrefix should be used.");
gClient.request({ to: globalActor, type: "ping" }, function(aResponse) {
is(aResponse.pong, "pong", "Actor should respond to requests.");
finish_test();
// Send another ping to see if the same actor is used.
gClient.request({ to: globalActor, type: "ping" }, function(aResponse) {
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);
is(connections.length, 1, "Only one connection is established.");
let connPrefix = connections[0];
ok(DebuggerServer._connections[connPrefix],
connPrefix + " is the only connection.");
// First we look for the pool of global actors.
let extraPools = DebuggerServer._connections[connPrefix]._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");
return elem.match(re) !== null;
})) {
globalPool = pool;
break;
}
}
// Then we look if the global pool contains only one test actor.
let actorPrefix = connPrefix + "testone";
let actors = Object.keys(globalPool._actors).join();
info("Global actors: " + actors);
isnot(actors.indexOf(actorPrefix), -1, "The test actor exists in the pool.");
is(actors.indexOf(actorPrefix), actors.lastIndexOf(actorPrefix),
"Only one actor exists in the pool.");
finish_test();
});
});
});
});

Просмотреть файл

@ -529,8 +529,11 @@ DebuggerServerConnection.prototype = {
"': " + safeErrorString(e))
});
}
// We want the newly-constructed actor to completely replace the factory
// actor. Reusing the existing actor ID will make sure ActorPool.addActor
// does the right thing.
instance.actorID = actor.actorID;
actor.registeredPool.addActor(instance);
actor.registeredPool.removeActor(actor);
actor = instance;
}