1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * An object that contains details of a stack frame.
8 * @typedef {object} StackFrame
11 * @property {string=} asyncCause
12 * Type of asynchronous call by which this frame was invoked.
13 * @property {number} columnNumber
14 * The column number for this stack frame.
15 * @property {string} filename
16 * The source URL for this stack frame.
17 * @property {string} function
18 * SpiderMonkey’s inferred name for this stack frame’s function, or null.
19 * @property {number} lineNumber
20 * The line number for this stack frame (starts with 1).
21 * @property {number} sourceId
22 * The process-unique internal integer ID of this source.
26 * Return a list of stack frames from the given stack.
28 * Convert stack objects to the JSON attributes expected by consumers.
30 * @param {object} stack
31 * The native stack object to process.
33 * @returns {Array<StackFrame>=}
35 export function getFramesFromStack(stack) {
36 if (!stack || (Cu && Cu.isDeadWrapper(stack))) {
37 // If the global from which this error came from has been nuked,
38 // stack is going to be a dead wrapper.
45 asyncCause: stack.asyncCause,
46 columnNumber: stack.column,
47 filename: stack.source,
48 functionName: stack.functionDisplayName || "",
49 lineNumber: stack.line,
50 sourceId: stack.sourceId,
53 stack = stack.parent || stack.asyncParent;
60 * Check if a frame is from chrome scope.
62 * @param {object} frame
66 * True, if frame is from chrome scope
68 export function isChromeFrame(frame) {
70 frame.filename.startsWith("chrome://") ||
71 frame.filename.startsWith("resource://")