From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/xpcshell/test_Log_nsIStackFrame.js | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js (limited to 'toolkit/modules/tests/xpcshell/test_Log_nsIStackFrame.js') 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); +} -- cgit v1.2.3