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:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /devtools/client/shared/test/shared-head.js
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 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"
);