summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/test/shared-head.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /devtools/client/shared/test/shared-head.js
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/shared/test/shared-head.js')
-rw-r--r--devtools/client/shared/test/shared-head.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/devtools/client/shared/test/shared-head.js b/devtools/client/shared/test/shared-head.js
index 2c8df188a6..aa47b35edd 100644
--- a/devtools/client/shared/test/shared-head.js
+++ b/devtools/client/shared/test/shared-head.js
@@ -54,6 +54,45 @@ if (DEBUG_ALLOCATIONS) {
});
}
+// When DEBUG_STEP environment variable is set,
+// automatically start a tracer which will log all line being executed
+// in the running test (and nothing else) and also pause its execution
+// for the given amount of milliseconds.
+//
+// Be careful that these pause have significant side effect.
+// This will pause the test script event loop and allow running the other
+// tasks queued in the parent process's main thread event loop queue.
+//
+// Passing any non-number value, like `DEBUG_STEP=true` will still
+// log the executed lines without any pause, and without this side effect.
+//
+// For now, the tracer can only work once per thread.
+// So when using this feature you will not be able to use the JS tracer
+// in any other way on parent process's main thread.
+const DEBUG_STEP = Services.env.get("DEBUG_STEP");
+if (DEBUG_STEP) {
+ // Use a custom loader with `invisibleToDebugger` flag for the allocation tracker
+ // as it instantiates custom Debugger API instances and has to be running in a distinct
+ // compartments from DevTools and system scopes (JSMs, XPCOM,...)
+ const {
+ useDistinctSystemPrincipalLoader,
+ releaseDistinctSystemPrincipalLoader,
+ } = ChromeUtils.importESModule(
+ "resource://devtools/shared/loader/DistinctSystemPrincipalLoader.sys.mjs"
+ );
+ const requester = {};
+ const loader = useDistinctSystemPrincipalLoader(requester);
+
+ const stepper = loader.require(
+ "resource://devtools/shared/test-helpers/test-stepper.js"
+ );
+ stepper.start(globalThis, gTestPath, DEBUG_STEP);
+ registerCleanupFunction(() => {
+ stepper.stop();
+ releaseDistinctSystemPrincipalLoader(requester);
+ });
+}
+
const { loader, require } = ChromeUtils.importESModule(
"resource://devtools/shared/loader/Loader.sys.mjs"
);