summaryrefslogtreecommitdiffstats
path: root/devtools/shared/tests/xpcshell/test_stack.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/shared/tests/xpcshell/test_stack.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--devtools/shared/tests/xpcshell/test_stack.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/devtools/shared/tests/xpcshell/test_stack.js b/devtools/shared/tests/xpcshell/test_stack.js
new file mode 100644
index 0000000000..a95d28c57d
--- /dev/null
+++ b/devtools/shared/tests/xpcshell/test_stack.js
@@ -0,0 +1,49 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test stack.js.
+
+function run_test() {
+ const loader = new DevToolsLoader();
+ const require = loader.require;
+
+ const {
+ StackFrameCache,
+ } = require("resource://devtools/server/actors/utils/stack.js");
+
+ const cache = new StackFrameCache();
+ cache.initFrames();
+ const baseFrame = {
+ line: 23,
+ column: 77,
+ source: "nowhere",
+ functionDisplayName: "nobody",
+ parent: null,
+ asyncParent: null,
+ asyncCause: null,
+ };
+ cache.addFrame(baseFrame);
+
+ let event = cache.makeEvent();
+ Assert.equal(event[0], null);
+ Assert.equal(event[1].functionDisplayName, "nobody");
+ Assert.equal(event.length, 2);
+
+ cache.addFrame({
+ line: 24,
+ column: 78,
+ source: "nowhere",
+ functionDisplayName: "still nobody",
+ parent: null,
+ asyncParent: baseFrame,
+ asyncCause: "async",
+ });
+
+ event = cache.makeEvent();
+ Assert.equal(event[0].functionDisplayName, "still nobody");
+ Assert.equal(event[0].parent, 0);
+ Assert.equal(event[0].asyncParent, 1);
+ Assert.equal(event.length, 1);
+}