summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js')
-rw-r--r--toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js b/toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js
new file mode 100644
index 0000000000..b7fdd511e1
--- /dev/null
+++ b/toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js
@@ -0,0 +1,59 @@
+const { Log } = ChromeUtils.importESModule(
+ "resource://gre/modules/Log.sys.mjs"
+);
+
+function foo() {
+ return bar(); // line 6
+}
+
+function bar() {
+ return baz(); // line 10
+}
+
+function baz() {
+ return Log.stackTrace(Components.stack.caller); // line 14
+}
+
+function start() {
+ return next(); // line 18
+}
+
+function next() {
+ return finish(); // line 22
+}
+
+function finish() {
+ return Log.stackTrace(); // line 26
+}
+
+function run_test() {
+ const stackFrameTrace = foo(); // line 30
+
+ print(`Got trace for nsIStackFrame case: ${stackFrameTrace}`);
+
+ const fooPos = stackFrameTrace.search(/foo@.*test_Log_nsIStackFrame.js:6/);
+ const barPos = stackFrameTrace.search(/bar@.*test_Log_nsIStackFrame.js:10/);
+ const runTestPos = stackFrameTrace.search(
+ /run_test@.*test_Log_nsIStackFrame.js:30/
+ );
+
+ print(`String positions: ${runTestPos} ${barPos} ${fooPos}`);
+ Assert.ok(barPos >= 0);
+ Assert.ok(fooPos > barPos);
+ Assert.ok(runTestPos > fooPos);
+
+ const emptyArgTrace = start();
+
+ print(`Got trace for empty argument case: ${emptyArgTrace}`);
+
+ const startPos = emptyArgTrace.search(/start@.*test_Log_nsIStackFrame.js:18/);
+ const nextPos = emptyArgTrace.search(/next@.*test_Log_nsIStackFrame.js:22/);
+ const finishPos = emptyArgTrace.search(
+ /finish@.*test_Log_nsIStackFrame.js:26/
+ );
+
+ print(`String positions: ${finishPos} ${nextPos} ${startPos}`);
+ Assert.ok(finishPos >= 0);
+ Assert.ok(nextPos > finishPos);
+ Assert.ok(startPos > nextPos);
+}