test_stack.js (1156B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test stack.js. 7 8 function run_test() { 9 const loader = new DevToolsLoader(); 10 const require = loader.require; 11 12 const { 13 StackFrameCache, 14 } = require("resource://devtools/server/actors/utils/stack.js"); 15 16 const cache = new StackFrameCache(); 17 cache.initFrames(); 18 const baseFrame = { 19 line: 23, 20 column: 77, 21 source: "nowhere", 22 functionDisplayName: "nobody", 23 parent: null, 24 asyncParent: null, 25 asyncCause: null, 26 }; 27 cache.addFrame(baseFrame); 28 29 let event = cache.makeEvent(); 30 Assert.equal(event[0], null); 31 Assert.equal(event[1].functionDisplayName, "nobody"); 32 Assert.equal(event.length, 2); 33 34 cache.addFrame({ 35 line: 24, 36 column: 78, 37 source: "nowhere", 38 functionDisplayName: "still nobody", 39 parent: null, 40 asyncParent: baseFrame, 41 asyncCause: "async", 42 }); 43 44 event = cache.makeEvent(); 45 Assert.equal(event[0].functionDisplayName, "still nobody"); 46 Assert.equal(event[0].parent, 0); 47 Assert.equal(event[0].asyncParent, 1); 48 Assert.equal(event.length, 1); 49 }