summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/xpcshell
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /devtools/server/tests/xpcshell
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--devtools/server/tests/xpcshell/head_dbg.js29
-rw-r--r--devtools/server/tests/xpcshell/test_addon_debugging_connect.js4
-rw-r--r--devtools/server/tests/xpcshell/test_getRuleText.js41
-rw-r--r--devtools/server/tests/xpcshell/test_sessionDataHelpers.js5
-rw-r--r--devtools/server/tests/xpcshell/test_xpcshell_debugging.js16
-rw-r--r--devtools/server/tests/xpcshell/testactors.js36
6 files changed, 82 insertions, 49 deletions
diff --git a/devtools/server/tests/xpcshell/head_dbg.js b/devtools/server/tests/xpcshell/head_dbg.js
index 7161d5eaea..e8547f15b8 100644
--- a/devtools/server/tests/xpcshell/head_dbg.js
+++ b/devtools/server/tests/xpcshell/head_dbg.js
@@ -22,8 +22,8 @@ appInfo.updateAppInfo({
const { require, loader } = ChromeUtils.importESModule(
"resource://devtools/shared/loader/Loader.sys.mjs"
);
-const { worker } = ChromeUtils.import(
- "resource://devtools/shared/loader/worker-loader.js"
+const { worker } = ChromeUtils.importESModule(
+ "resource://devtools/shared/loader/worker-loader.sys.mjs"
);
const { NetUtil } = ChromeUtils.importESModule(
@@ -250,11 +250,6 @@ function waitForNewSource(threadFront, url) {
});
}
-function attachThread(targetFront, options = {}) {
- dump("Attaching to thread.\n");
- return targetFront.attachThread(options);
-}
-
function resume(threadFront) {
dump("Resuming thread.\n");
return threadFront.resume();
@@ -445,10 +440,14 @@ async function attachTestTab(client, title) {
async function attachTestThread(client, title) {
const commands = await attachTestTab(client, title);
const targetFront = commands.targetCommand.targetFront;
- const threadFront = await targetFront.getFront("thread");
- await targetFront.attachThread({
- autoBlackBox: true,
+
+ // Pass any configuration, in order to ensure starting all the thread actors
+ // and have them to handle debugger statements.
+ await commands.threadConfigurationCommand.updateConfiguration({
+ skipBreakpoints: false,
});
+
+ const threadFront = await targetFront.getFront("thread");
Assert.equal(threadFront.state, "attached", "Thread front is attached");
return { targetFront, threadFront, commands };
}
@@ -856,7 +855,15 @@ async function setupTestFromUrl(url) {
const targetFront = await descriptorFront.getTarget();
- const threadFront = await attachThread(targetFront);
+ const commands = await createCommandsDictionary(descriptorFront);
+
+ // Pass any configuration, in order to ensure starting all the thread actor
+ // and have it to notify about all sources
+ await commands.threadConfigurationCommand.updateConfiguration({
+ skipBreakpoints: false,
+ });
+
+ const threadFront = await targetFront.getFront("thread");
const sourceUrl = getFileUrl(url);
const promise = waitForNewSource(threadFront, sourceUrl);
diff --git a/devtools/server/tests/xpcshell/test_addon_debugging_connect.js b/devtools/server/tests/xpcshell/test_addon_debugging_connect.js
index 221e73d256..f0318378c9 100644
--- a/devtools/server/tests/xpcshell/test_addon_debugging_connect.js
+++ b/devtools/server/tests/xpcshell/test_addon_debugging_connect.js
@@ -53,7 +53,7 @@ function promiseFrameUpdate(front, matcher = () => true) {
add_task(
{
// This test needs to run only when the extension are running in a separate
- // child process, otherwise attachThread would pause the main process and this
+ // child process, otherwise the thread actor would pause the main process and this
// test would get stuck.
skip_if: () => !WebExtensionPolicy.useRemoteWebExtensions,
},
@@ -90,7 +90,7 @@ add_task(
.pop();
ok(backgroundPageFrame, "Found the frame for the background page");
- const threadFront = await addonTarget.attachThread();
+ const threadFront = await addonTarget.getFront("thread");
ok(threadFront, "Got a threadFront for the target addon");
equal(threadFront.paused, false, "The addon threadActor isn't paused");
diff --git a/devtools/server/tests/xpcshell/test_getRuleText.js b/devtools/server/tests/xpcshell/test_getRuleText.js
index bc89da974c..6e67a5f85b 100644
--- a/devtools/server/tests/xpcshell/test_getRuleText.js
+++ b/devtools/server/tests/xpcshell/test_getRuleText.js
@@ -39,7 +39,7 @@ const TEST_DATA = [
input: "#id{color:red;background:yellow;}",
line: 1,
column: 1,
- expected: { offset: 4, text: "color:red;background:yellow;" },
+ expected: "color:red;background:yellow;",
},
{
desc: "Multiple rules test case",
@@ -48,14 +48,14 @@ const TEST_DATA = [
"{ position:absolute; line-height: 45px}",
line: 1,
column: 34,
- expected: { offset: 56, text: " position:absolute; line-height: 45px" },
+ expected: " position:absolute; line-height: 45px",
},
{
desc: "Unclosed rule",
input: "#id{color:red;background:yellow;",
line: 1,
column: 1,
- expected: { offset: 4, text: "color:red;background:yellow;" },
+ expected: "color:red;background:yellow;",
},
{
desc: "Multi-lines CSS",
@@ -72,7 +72,7 @@ const TEST_DATA = [
].join("\n"),
line: 7,
column: 1,
- expected: { offset: 116, text: "\n color: purple;\n" },
+ expected: "\n color: purple;\n",
},
{
desc: "Multi-lines CSS and multi-line rule",
@@ -98,75 +98,64 @@ const TEST_DATA = [
].join("\n"),
line: 5,
column: 1,
- expected: {
- offset: 30,
- text: "\n margin: 0;\n padding: 15px 15px 2px 15px;\n color: red;\n",
- },
+ expected:
+ "\n margin: 0;\n padding: 15px 15px 2px 15px;\n color: red;\n",
},
{
desc: "Content string containing a } character",
input: " #id{border:1px solid red;content: '}';color:red;}",
line: 1,
column: 4,
- expected: {
- offset: 7,
- text: "border:1px solid red;content: '}';color:red;",
- },
+ expected: "border:1px solid red;content: '}';color:red;",
},
{
desc: "Attribute selector containing a { character",
input: `div[data-x="{"]{color: gold}`,
line: 1,
column: 1,
- expected: {
- offset: 16,
- text: "color: gold",
- },
+ expected: "color: gold",
},
{
desc: "Rule contains no tokens",
input: "div{}",
line: 1,
column: 1,
- expected: { offset: 4, text: "" },
+ expected: "",
},
{
desc: "Rule contains invalid declaration",
input: `#id{color;}`,
line: 1,
column: 1,
- expected: { offset: 4, text: "color;" },
+ expected: "color;",
},
{
desc: "Rule contains invalid declaration",
input: `#id{-}`,
line: 1,
column: 1,
- expected: { offset: 4, text: "-" },
+ expected: "-",
},
{
desc: "Rule contains nested rule",
input: `#id{background: gold; .nested{color:blue;} color: tomato; }`,
line: 1,
column: 1,
- expected: {
- offset: 4,
- text: "background: gold; .nested{color:blue;} color: tomato; ",
- },
+ expected: "background: gold; .nested{color:blue;} color: tomato; ",
},
{
desc: "Rule contains nested rule with invalid declaration",
input: `#id{.nested{color;}}`,
line: 1,
column: 1,
- expected: { offset: 4, text: ".nested{color;}" },
+ expected: ".nested{color;}",
},
{
desc: "Rule contains unicode chars",
input: `#id /*🙃*/ {content: "☃️";}`,
line: 1,
column: 1,
- expected: { offset: 12, text: `content: "☃️";` },
+ expected: `content: "☃️";`,
},
];
@@ -192,7 +181,7 @@ function run_test() {
}
}
if (output) {
- deepEqual(output, test.expected);
+ Assert.equal(output, test.expected);
}
}
}
diff --git a/devtools/server/tests/xpcshell/test_sessionDataHelpers.js b/devtools/server/tests/xpcshell/test_sessionDataHelpers.js
index e0dcc3b21b..0c17937a69 100644
--- a/devtools/server/tests/xpcshell/test_sessionDataHelpers.js
+++ b/devtools/server/tests/xpcshell/test_sessionDataHelpers.js
@@ -7,8 +7,9 @@
"use strict";
-const { SessionDataHelpers } = ChromeUtils.import(
- "resource://devtools/server/actors/watcher/SessionDataHelpers.jsm"
+const { SessionDataHelpers } = ChromeUtils.importESModule(
+ "resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
+ { global: "contextual" }
);
const { SUPPORTED_DATA } = SessionDataHelpers;
const { TARGETS } = SUPPORTED_DATA;
diff --git a/devtools/server/tests/xpcshell/test_xpcshell_debugging.js b/devtools/server/tests/xpcshell/test_xpcshell_debugging.js
index ff54d7390d..12d38b923d 100644
--- a/devtools/server/tests/xpcshell/test_xpcshell_debugging.js
+++ b/devtools/server/tests/xpcshell/test_xpcshell_debugging.js
@@ -35,11 +35,17 @@ add_task(async function () {
);
// Even though we have no tabs, getMainProcess gives us the chrome debugger.
- const targetDescriptor = await client.mainRoot.getMainProcess();
- const front = await targetDescriptor.getTarget();
- const watcher = await targetDescriptor.getWatcher();
+ const commands = await CommandsFactory.forMainProcess({ client });
+ await commands.targetCommand.startListening();
- const threadFront = await front.attachThread();
+ // We have to pass at least one valid thread configuration in order to initialize
+ // the thread actor and make it pause on breakpoint/debugger statements.
+ await commands.threadConfigurationCommand.updateConfiguration({
+ skipBreakpoints: false,
+ });
+ const threadFront = await commands.targetCommand.targetFront.getFront(
+ "thread"
+ );
// Checks that the thread actor initializes immediately and that _setupDevToolsServer
// callback gets called.
@@ -72,7 +78,7 @@ add_task(async function () {
);
info("Dynamically add a breakpoint after the debugger statement");
- const breakpointsFront = await watcher.getBreakpointListActor();
+ const breakpointsFront = await commands.watcherFront.getBreakpointListActor();
await breakpointsFront.setBreakpoint(
{ sourceUrl: testFile.path, line: 11, column: 0 },
{}
diff --git a/devtools/server/tests/xpcshell/testactors.js b/devtools/server/tests/xpcshell/testactors.js
index bbcd8abe6e..6df7f0ce88 100644
--- a/devtools/server/tests/xpcshell/testactors.js
+++ b/devtools/server/tests/xpcshell/testactors.js
@@ -8,6 +8,9 @@ const {
createExtraActors,
} = require("resource://devtools/shared/protocol/lazy-pool.js");
const { RootActor } = require("resource://devtools/server/actors/root.js");
+const {
+ WatcherActor,
+} = require("resource://devtools/server/actors/watcher.js");
const { ThreadActor } = require("resource://devtools/server/actors/thread.js");
const {
DevToolsServer,
@@ -30,6 +33,14 @@ const Targets = require("resource://devtools/server/actors/targets/index.js");
const {
createContentProcessSessionContext,
} = require("resource://devtools/server/actors/watcher/session-context.js");
+const { TargetActorRegistry } = ChromeUtils.importESModule(
+ "resource://devtools/server/actors/targets/target-actor-registry.sys.mjs",
+ { global: "shared" }
+);
+const {
+ BaseTargetActor,
+} = require("resource://devtools/server/actors/targets/base-target-actor.js");
+const Resources = require("resource://devtools/server/actors/resources/index.js");
var gTestGlobals = new Set();
DevToolsServer.addTestGlobal = function (global) {
@@ -78,6 +89,9 @@ function TestTabList(connection) {
const actor = new TestTargetActor(connection, global);
this._descriptorActorPool.manage(actor);
+ // Register the target actor, so that the Watcher actor can have access to it.
+ TargetActorRegistry.registerXpcShellTargetActor(actor);
+
const descriptorActor = new TestDescriptorActor(connection, actor);
this._descriptorActorPool.manage(descriptorActor);
@@ -134,7 +148,9 @@ class TestDescriptorActor extends protocol.Actor {
form() {
const form = {
actor: this.actorID,
- traits: {},
+ traits: {
+ watcher: true,
+ },
selected: this.selected,
title: this._targetActor.title,
url: this._targetActor.url,
@@ -143,6 +159,20 @@ class TestDescriptorActor extends protocol.Actor {
return form;
}
+ getWatcher() {
+ const sessionContext = {
+ type: "all",
+ supportedTargets: {},
+ supportedResources: [
+ Resources.TYPES.SOURCE,
+ Resources.TYPES.CONSOLE_MESSAGE,
+ Resources.TYPES.THREAD_STATE,
+ ],
+ };
+ const watcherActor = new WatcherActor(this.conn, sessionContext);
+ return watcherActor;
+ }
+
getFavicon() {
return "";
}
@@ -152,9 +182,9 @@ class TestDescriptorActor extends protocol.Actor {
}
}
-class TestTargetActor extends protocol.Actor {
+class TestTargetActor extends BaseTargetActor {
constructor(conn, global) {
- super(conn, windowGlobalTargetSpec);
+ super(conn, Targets.TYPES.FRAME, windowGlobalTargetSpec);
this.sessionContext = createContentProcessSessionContext();
this._global = global;