зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1609162 - [remote] Start remote agent only once in remote mochitests r=remote-protocol-reviewers,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D110214
This commit is contained in:
Родитель
d1a386a566
Коммит
43975df10a
|
@ -29,6 +29,7 @@ with Files("domains/**/Target.jsm"):
|
|||
|
||||
BROWSER_CHROME_MANIFESTS += [
|
||||
"test/browser/browser.ini",
|
||||
"test/browser/component/browser.ini",
|
||||
"test/browser/dom/browser.ini",
|
||||
"test/browser/emulation/browser.ini",
|
||||
"test/browser/input/browser.ini",
|
||||
|
|
|
@ -7,7 +7,6 @@ support-files =
|
|||
chrome-remote-interface.js
|
||||
head.js
|
||||
|
||||
[browser_agent.js]
|
||||
[browser_cdp.js]
|
||||
skip-if = socketprocess_networking
|
||||
[browser_httpd.js]
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
[DEFAULT]
|
||||
tags = remote
|
||||
subsuite = remote
|
||||
prefs =
|
||||
remote.enabled=true
|
||||
support-files =
|
||||
!/remote/cdp/test/browser/chrome-remote-interface.js
|
||||
!/remote/cdp/test/browser/head.js
|
||||
head.js
|
||||
|
||||
# This test needs to start and close RemoteAgent several times.
|
||||
# It should be the only test in this suite to avoid side-effects with
|
||||
# regular tests which reuse a shared RemoteAgent instance.
|
||||
[browser_agent.js]
|
|
@ -0,0 +1,11 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../head.js */
|
||||
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/remote/cdp/test/browser/head.js",
|
||||
this
|
||||
);
|
|
@ -39,6 +39,18 @@ setup and teardown described above.
|
|||
|
||||
const add_plain_task = add_task.bind(this);
|
||||
|
||||
// Start RemoteAgent lazily and reuse it for all the tests in the suite.
|
||||
// Starting and stopping RemoteAgent for every test would trigger race conditions
|
||||
// in httpd.js. See Bug 1609162.
|
||||
let remoteAgentStarted = false;
|
||||
async function startRemoteAgent() {
|
||||
if (!remoteAgentStarted) {
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
remoteAgentStarted = true;
|
||||
info("Remote agent started");
|
||||
}
|
||||
}
|
||||
|
||||
this.add_task = function(taskFn, opts = {}) {
|
||||
const {
|
||||
createTab = true, // By default run each test in its own tab
|
||||
|
@ -47,8 +59,7 @@ this.add_task = function(taskFn, opts = {}) {
|
|||
const fn = async function() {
|
||||
let client, tab, target;
|
||||
|
||||
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
|
||||
info("CDP server started");
|
||||
await startRemoteAgent();
|
||||
|
||||
try {
|
||||
const CDP = await getCDP();
|
||||
|
@ -92,9 +103,6 @@ this.add_task = function(taskFn, opts = {}) {
|
|||
info("CDP client closed");
|
||||
}
|
||||
|
||||
await RemoteAgent.close();
|
||||
info("CDP server stopped");
|
||||
|
||||
// Close any additional tabs, so that only a single tab remains open
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
gBrowser.removeCurrentTab();
|
||||
|
|
Загрузка…
Ссылка в новой задаче