mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1521052 - Add DebuggerServer.hasConnection to track if it still has active connections. r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D16961 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
de44cc12fc
commit
34cccbbf19
@ -95,6 +95,10 @@ var DebuggerServer = {
|
||||
return this._initialized;
|
||||
},
|
||||
|
||||
hasConnection() {
|
||||
return Object.keys(this._connections).length > 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Performs cleanup tasks before shutting down the debugger server. Such tasks
|
||||
* include clearing any actor constructors added at runtime. This method
|
||||
|
@ -37,6 +37,7 @@ async function test_socket_conn() {
|
||||
gExtraListener = new SocketListener(DebuggerServer, socketOptions);
|
||||
gExtraListener.open();
|
||||
Assert.equal(DebuggerServer.listeningSockets, 2);
|
||||
Assert.ok(!DebuggerServer.hasConnection());
|
||||
|
||||
info("Starting long and unicode tests at " + new Date().toTimeString());
|
||||
const unicodeString = "(╯°□°)╯︵ ┻━┻";
|
||||
@ -44,13 +45,15 @@ async function test_socket_conn() {
|
||||
host: "127.0.0.1",
|
||||
port: gPort,
|
||||
});
|
||||
Assert.ok(DebuggerServer.hasConnection());
|
||||
|
||||
// Assert that connection settings are available on transport object
|
||||
const settings = transport.connectionSettings;
|
||||
Assert.equal(settings.host, "127.0.0.1");
|
||||
Assert.equal(settings.port, gPort);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const onDebuggerConnectionClosed = DebuggerServer.once("connectionchange");
|
||||
await new Promise((resolve) => {
|
||||
transport.hooks = {
|
||||
onPacket: function(packet) {
|
||||
this.onPacket = function({unicode}) {
|
||||
@ -71,6 +74,9 @@ async function test_socket_conn() {
|
||||
};
|
||||
transport.ready();
|
||||
});
|
||||
const type = await onDebuggerConnectionClosed;
|
||||
Assert.equal(type, "closed");
|
||||
Assert.ok(!DebuggerServer.hasConnection());
|
||||
}
|
||||
|
||||
async function test_socket_shutdown() {
|
||||
|
Loading…
Reference in New Issue
Block a user