MCPcopy Index your code
hub / github.com/nodejs/node / get_stack

Function get_stack

test/fixtures/wpt/resources/testharness.js:4801–4837  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4799 AssertionError.prototype = Object.create(Error.prototype);
4800
4801 const get_stack = function() {
4802 var stack = new Error().stack;
4803
4804 // 'Error.stack' is not supported in all browsers/versions
4805 if (!stack) {
4806 return "(Stack trace unavailable)";
4807 }
4808
4809 var lines = stack.split("\n");
4810
4811 // Create a pattern to match stack frames originating within testharness.js. These include the
4812 // script URL, followed by the line/col (e.g., '/resources/testharness.js:120:21').
4813 // Escape the URL per http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
4814 // in case it contains RegExp characters.
4815 var script_url = get_script_url();
4816 var re_text = script_url ? script_url.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') : "\\btestharness.js";
4817 var re = new RegExp(re_text + ":\\d+:\\d+");
4818
4819 // Some browsers include a preamble that specifies the type of the error object. Skip this by
4820 // advancing until we find the first stack frame originating from testharness.js.
4821 var i = 0;
4822 while (!re.test(lines[i]) && i < lines.length) {
4823 i++;
4824 }
4825
4826 // Then skip the top frames originating from testharness.js to begin the stack at the test code.
4827 while (re.test(lines[i]) && i < lines.length) {
4828 i++;
4829 }
4830
4831 // Paranoid check that we didn't skip all frames. If so, return the original stack unmodified.
4832 if (i >= lines.length) {
4833 return stack;
4834 }
4835
4836 return lines.slice(i).join("\n");
4837 };
4838
4839 function OptionalFeatureUnsupportedError(message)
4840 {

Callers 2

assert_wrapperFunction · 0.85
AssertionErrorFunction · 0.85

Calls 5

get_script_urlFunction · 0.70
sliceMethod · 0.65
splitMethod · 0.45
testMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…