Files
sousa-gecko/devtools/client/shared/webpack/shims/test/test_stack.js
T
Mike Ratcliffe 87cde2de5f Bug 1448287 - Fix devtools.dump.emit when using new event emitter r=jdescottes
components.stack is not always available, throw new Error() to obtain a stack instead.

MozReview-Commit-ID: BZq7zLKgA9H
2018-03-23 15:34:22 +00:00

45 lines
982 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// There isn't really very much about the content stack.js that we can
// test, but we'll do what we can.
"use strict";
const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
const {
callFunctionWithAsyncStack,
getStack,
getNthPathExcluding
} = require("devtools/client/shared/webpack/shims/platform-stack-stub");
function f3() {
return getNthPathExcluding(2);
}
function f2() {
return f3();
}
function f1() {
return f2();
}
function run_test() {
let value = 7;
const changeValue = () => {
value = 9;
};
callFunctionWithAsyncStack(changeValue, getStack(), "test_stack");
equal(value, 9, "callFunctionWithAsyncStack worked");
let stack = getStack();
equal(JSON.parse(JSON.stringify(stack)), stack, "stack is serializable");
let desc = f1();
ok(desc.includes("f1"), "stack description includes f1");
}