Bug 1696375 - [devtools] Move Targets tests to commands folder. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D105615
This commit is contained in:
Alexandre Poirot 2021-03-15 08:08:38 +00:00
Родитель 061804b995
Коммит ec618b289e
24 изменённых файлов: 175 добавлений и 22 удалений

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

@ -5,3 +5,6 @@
DevToolsModules(
"target-command.js",
)
if CONFIG["MOZ_BUILD_APP"] != "mobile/android":
BROWSER_CHROME_MANIFESTS += ["tests/browser.ini"]

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

@ -0,0 +1,6 @@
"use strict";
module.exports = {
// Extend from the shared list of defined globals for mochitests.
extends: "../../../../.eslintrc.mochitests.js",
};

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

@ -0,0 +1,35 @@
[DEFAULT]
tags = devtools
subsuite = devtools
support-files =
!/devtools/client/shared/test/shared-head.js
!/devtools/client/shared/test/telemetry-test-helpers.js
!/devtools/client/shared/test/test-actor.js
head.js
fission_document.html
fission_iframe.html
test_service_worker.js
test_sw_page.html
test_sw_page_worker.js
test_worker.js
[browser_target_list_browser_workers.js]
[browser_target_list_frames.js]
skip-if = (os == "win" && bits == 64) && fission #Bug 1697354
[browser_target_list_getAllTargets.js]
[browser_target_list_preffedoff.js]
[browser_target_list_processes.js]
[browser_target_list_service_workers.js]
[browser_target_list_service_workers_navigation.js]
skip-if = fission
# There are several issues to test Targets navigation scenarios with fission.
# Without a toolbox linked to the target-list, the target list cannot switch
# targets. The legacy worker watchers are also not designed to support target
# switching, since they set this.target = targetList.targetFront just once in
# their constructor.
[browser_target_list_switchToTarget.js]
[browser_target_list_tab_workers.js]
[browser_target_list_various_descriptors.js]
[browser_target_list_watchTargets.js]
[browser_watcher_actor_getter_caching.js]
[browser_watcher_target_configuration.js]

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

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf8">
<title>Test fission document</title>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<script>
"use strict";
const params = new URLSearchParams(document.location.search);
// eslint-disable-next-line no-unused-vars
const worker = new Worker("https://example.com/browser/devtools/shared/commands/target/tests/test_worker.js#simple-worker");
// eslint-disable-next-line no-unused-vars
const sharedWorker = new SharedWorker("https://example.com/browser/devtools/shared/commands/target/tests/test_worker.js#shared-worker");
if (!params.has("noServiceWorker")) {
// Expose a reference to the registration so that tests can unregister it.
window.registrationPromise = navigator.serviceWorker.register("https://example.com/browser/devtools/shared/commands/target/tests/test_service_worker.js#service-worker");
}
/* exported logMessageInWorker */
function logMessageInWorker(message) {
worker.postMessage({
type: "log-in-worker",
message,
});
}
</script>
</head>
<body>
<p>Test fission iframe</p>
<script>
"use strict";
const iframe = document.createElement("iframe");
let iframeUrl = `https://example.org/browser/devtools/shared/commands/target/tests/fission_iframe.html`;
if (document.location.search) {
iframeUrl += `?${new URLSearchParams(document.location.search)}`;
}
iframe.src = iframeUrl;
document.body.append(iframe);
</script>
</body>
</html>

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

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf8">
<title>Test fission iframe document</title>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<script>
"use strict";
const params = new URLSearchParams(document.location.search);
const hashSuffix = params.get("hashSuffix") || "in-iframe";
// eslint-disable-next-line no-unused-vars
const worker = new Worker("test_worker.js#simple-worker-" + hashSuffix);
// eslint-disable-next-line no-unused-vars
const sharedWorker = new SharedWorker("test_worker.js#shared-worker-" + hashSuffix);
/* exported logMessageInWorker */
function logMessageInWorker(message) {
worker.postMessage({
type: "log-in-worker",
message,
});
}
</script>
</head>
<body>
<p>remote iframe</p>
</body>
</html>

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

@ -0,0 +1,29 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from ../../../../client/shared/test/shared-head.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js",
this
);
const { DevToolsClient } = require("devtools/client/devtools-client");
const { DevToolsServer } = require("devtools/server/devtools-server");
async function createLocalClient() {
// Instantiate a minimal server
DevToolsServer.init();
DevToolsServer.allowChromeProcess = true;
if (!DevToolsServer.createRootActor) {
DevToolsServer.registerAllActors();
}
const transport = DevToolsServer.connectPipe();
const client = new DevToolsClient(transport);
await client.connect();
return client;
}

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

@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// We don't need any computation in the worker,
// but at least register a fetch listener so that
// we force instantiating the SW when loading the page.
self.onfetch = function(event) {
// do nothing.
};

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

@ -0,0 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
console.log("[WORKER] started", globalThis.location.toString(), globalThis);
globalThis.onmessage = function(e) {
const { type, message } = e.data;
if (type === "log-in-worker") {
// Printing `e` so we can check that we have an object and not a stringified version
console.log("[WORKER]", message, e);
}
};

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

@ -22,8 +22,6 @@ support-files =
style_iframe.css
style_iframe.html
test_service_worker.js
test_sw_page.html
test_sw_page_worker.js
test_worker.js
websocket_backend_wsh.py
websocket_frontend_iframe.html
@ -53,23 +51,3 @@ support-files =
[browser_resources_thread_states.js]
[browser_resources_unwatch_early.js]
[browser_resources_websocket.js]
[browser_target_list_browser_workers.js]
[browser_target_list_frames.js]
skip-if = (os == "win" && bits == 64) && fission #Bug 1697354
[browser_target_list_getAllTargets.js]
[browser_target_list_preffedoff.js]
[browser_target_list_processes.js]
[browser_target_list_service_workers.js]
[browser_target_list_service_workers_navigation.js]
skip-if = fission
# There are several issues to test TargetList navigation scenarios with fission.
# Without a toolbox linked to the target-list, the target list cannot switch
# targets. The legacy worker watchers are also not designed to support target
# switching, since they set this.target = targetList.targetFront just once in
# their constructor.
[browser_target_list_switchToTarget.js]
[browser_target_list_tab_workers.js]
[browser_target_list_various_descriptors.js]
[browser_target_list_watchTargets.js]
[browser_watcher_actor_getter_caching.js]
[browser_watcher_target_configuration.js]