mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 08:48:07 +00:00
Bug 1537768 - Simplify RemoteAgent initialization. r=remote-protocol-reviewers,ato
Start the `TabObserver` from `RemoteAgent.listen` in order to prevent having the tests to manually start it. Start it from `listen` instead of `init` as we do stop the `TabObserver` from `stop` and `stop` is the reverse of `listen`, not the reverse of `init`. Differential Revision: https://phabricator.services.mozilla.com/D29412 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
360fec5787
commit
b45bb32493
@ -39,6 +39,10 @@ class RemoteAgentClass {
|
||||
throw new Error("Remote agent can only be instantiated from the parent process");
|
||||
}
|
||||
|
||||
if (this.server) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.server = new HttpServer();
|
||||
this.targets = new Targets();
|
||||
|
||||
@ -67,7 +71,7 @@ class RemoteAgentClass {
|
||||
return !!this.server && !this.server._socketClosed;
|
||||
}
|
||||
|
||||
listen(address) {
|
||||
async listen(address) {
|
||||
if (!(address instanceof Ci.nsIURI)) {
|
||||
throw new TypeError(`Expected nsIURI: ${address}`);
|
||||
}
|
||||
@ -86,6 +90,10 @@ class RemoteAgentClass {
|
||||
return;
|
||||
}
|
||||
|
||||
this.init();
|
||||
|
||||
await this.tabs.start();
|
||||
|
||||
try {
|
||||
this.server._start(port, host);
|
||||
|
||||
@ -185,7 +193,6 @@ class RemoteAgentClass {
|
||||
this.init();
|
||||
|
||||
await Observer.once("sessionstore-windows-restored");
|
||||
await this.tabs.start();
|
||||
|
||||
try {
|
||||
this.listen(addr);
|
||||
|
@ -32,9 +32,7 @@ async function testCDP() {
|
||||
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
|
||||
|
||||
// Start the CDP server
|
||||
RemoteAgent.init();
|
||||
RemoteAgent.tabs.start();
|
||||
RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
|
||||
// Retrieve the chrome-remote-interface library object
|
||||
const CDP = await getCDP();
|
||||
|
@ -11,9 +11,7 @@ const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
|
||||
|
||||
add_task(async function() {
|
||||
// Start the CDP server
|
||||
RemoteAgent.init();
|
||||
RemoteAgent.tabs.start();
|
||||
RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
|
||||
const { mainProcessTarget } = RemoteAgent.targets;
|
||||
ok(mainProcessTarget,
|
||||
|
@ -31,9 +31,7 @@ async function testCDP() {
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
|
||||
|
||||
// Start the CDP server
|
||||
RemoteAgent.init();
|
||||
RemoteAgent.tabs.start();
|
||||
RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
|
||||
// Retrieve the chrome-remote-interface library object
|
||||
const CDP = await getCDP();
|
||||
|
@ -31,9 +31,7 @@ async function testCDP() {
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
|
||||
|
||||
// Start the CDP server
|
||||
RemoteAgent.init();
|
||||
RemoteAgent.tabs.start();
|
||||
RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
|
||||
// Retrieve the chrome-remote-interface library object
|
||||
const CDP = await getCDP();
|
||||
|
@ -31,9 +31,7 @@ async function testCDP() {
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
|
||||
|
||||
// Start the CDP server
|
||||
RemoteAgent.init();
|
||||
RemoteAgent.tabs.start();
|
||||
RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
|
||||
// Retrieve the chrome-remote-interface library object
|
||||
const CDP = await getCDP();
|
||||
|
@ -11,9 +11,7 @@ const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
|
||||
|
||||
add_task(async function() {
|
||||
// Start the CDP server
|
||||
RemoteAgent.init();
|
||||
RemoteAgent.tabs.start();
|
||||
RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
|
||||
const CDP = await getCDP();
|
||||
|
||||
|
@ -26,9 +26,7 @@ add_task(async function() {
|
||||
|
||||
async function testCDP() {
|
||||
// Start the CDP server
|
||||
RemoteAgent.init();
|
||||
RemoteAgent.tabs.start();
|
||||
RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
|
||||
// Retrieve the chrome-remote-interface library object
|
||||
const CDP = await getCDP();
|
||||
|
Loading…
x
Reference in New Issue
Block a user