# Namespace goog.testing.stacktrace

code »

## Classes

goog.testing.stacktrace.Frame Class representing one stack frame.

Show:Public Protected Private

## Global Functions

code »goog.testing.stacktrace.callSitesToFrames_ ( stack ) ⇒ `!Array`

Converts an array of CallSite (elements of a stack trace in V8) to an array of Frames.

Parameters
stack: `!Array` The stack as an array of CallSites.
Returns
The stack as an array of Frames.

code »goog.testing.stacktrace.canonicalize ( stack ) ⇒ `string`

Brings the stack trace into a common format across browsers.

Parameters
stack: `string` Browser-specific stack trace.
Returns
Same stack trace in common format.

code »goog.testing.stacktrace.deobfuscateFunctionName_ ( ) ⇒ `string`

Function to deobfuscate function names.

code »goog.testing.stacktrace.followCallChain_ ( ) ⇒ `!Array`

Creates a stack trace by following the call chain. Based on `goog.debug.getStacktrace`.

Returns
Stack frames.

code »goog.testing.stacktrace.framesToString_ ( frames ) ⇒ `string`

Converts the stack frames into canonical format. Chops the beginning and the end of it which come from the testing environment, not from the test itself.

Parameters
frames: `!Array.<goog.testing.stacktrace.Frame>` The frames.
Returns
Canonical, pretty printed stack trace.

code »goog.testing.stacktrace.get ( ) ⇒ `string`

Gets the native stack trace if available otherwise follows the call chain.

Returns
The stack trace in canonical format.

code »goog.testing.stacktrace.getNativeStack_ ( ) ⇒ `(string|!Array)`

Returns the native stack trace.

code »goog.testing.stacktrace.htmlEscape_ ( text ) ⇒ `string`

Escapes the special character in HTML.

Parameters
text: `string` Plain text.
Returns
Escaped text.

code »goog.testing.stacktrace.maybeDeobfuscateFunctionName_ ( name ) ⇒ `string`

Deobfuscates a compiled function name with the function passed to `#setDeobfuscateFunctionName`. Returns the original function name if the deobfuscator hasn't been set.

Parameters
name: `string` The function name to deobfuscate.
Returns
The deobfuscated function name.

code »goog.testing.stacktrace.parseLongFirefoxFrame_ ( frameStr ) ⇒ `!goog.testing.stacktrace.Frame`

Parses a long firefox stack frame.

Parameters
frameStr: `string` The stack frame as string.
Returns
Stack frame object.

code »goog.testing.stacktrace.parseStackFrame_ ( frameStr ) ⇒ `goog.testing.stacktrace.Frame`

Parses one stack frame.

Parameters
frameStr: `string` The stack frame as string.
Returns
Stack frame object or null if the parsing failed.

code »goog.testing.stacktrace.parse_ ( stack ) ⇒ `!Array.<goog.testing.stacktrace.Frame>`

Parses the browser's native stack trace.

Parameters
stack: `string` Stack trace.
Returns
Stack frames. The unrecognized frames will be nulled out.

code »goog.testing.stacktrace.setDeobfuscateFunctionName ( fn )

Sets function to deobfuscate function names.

Parameters
fn: `function(string): string` function to deobfuscate function names.

## Global Properties

code »goog.testing.stacktrace.CHROME_URL_PATTERN_ : `string`

RegExp pattern for an URL + line number + column number in V8. The URL is either in submatch 1 or submatch 2.

code »goog.testing.stacktrace.FIREFOX_FUNCTION_CALL_PATTERN_ : `string`

RegExp pattern for function call in the Firefox stack trace. Creates 2 submatches with function name (optional) and arguments.

code »goog.testing.stacktrace.FIREFOX_STACK_FRAME_REGEXP_ : `!RegExp`

Regular expression for parsing one stack frame in Firefox.

code »goog.testing.stacktrace.FUNCTION_SOURCE_REGEXP_ : `!RegExp`

Regular expression for finding the function name in its source.

code »goog.testing.stacktrace.IDENTIFIER_PATTERN_ : `string`

RegExp pattern for JavaScript identifiers. We don't support Unicode identifiers defined in ECMAScript v3.

code »goog.testing.stacktrace.IE_FUNCTION_CALL_PATTERN_ : `string`

RegExp pattern for function call in a IE stack trace. This expression allows for identifiers like 'Anonymous function', 'eval code', and 'Global code'.

code »goog.testing.stacktrace.IE_STACK_FRAME_REGEXP_ : `!RegExp`

Regular expression for parsing a stack frame in IE.

code »goog.testing.stacktrace.MAX_DEPTH_ : `number`

Maximum number of steps while the call chain is followed.

code »goog.testing.stacktrace.MAX_FIREFOX_FRAMESTRING_LENGTH_ : `number`

Maximum length of a string that can be matched with a RegExp on Firefox 3x. Exceeding this approximate length will cause string.match to exceed Firefox's stack quota. This situation can be encountered when goog.globalEval is invoked with a long argument; such as when loading a module.

code »goog.testing.stacktrace.OPERA_ANONYMOUS_FUNCTION_NAME_PATTERN_ : `string`

RegExp pattern for an anonymous function call in an Opera stack frame. Creates 2 (optional) submatches: the context object and function name.

code »goog.testing.stacktrace.OPERA_FUNCTION_CALL_PATTERN_ : `string`

RegExp pattern for a function call in an Opera stack frame. Creates 4 (optional) submatches: the function name (if not anonymous), the aliased context object and function name (if anonymous), and the function call arguments.

code »goog.testing.stacktrace.OPERA_STACK_FRAME_REGEXP_ : `!RegExp`

Regular expression for parsing on stack frame in Opera 11.68 - 12.17. Newer versions of Opera use V8 and stack frames should match against goog.testing.stacktrace.V8_STACK_FRAME_REGEXP_.

code »goog.testing.stacktrace.URL_PATTERN_ : `string`

RegExp pattern for an URL + position inside the file.

code »goog.testing.stacktrace.V8_ALIAS_PATTERN_ : `string`

RegExp pattern for function name alias in the V8 stack trace.

code »goog.testing.stacktrace.V8_CONTEXT_PATTERN_ : `string`

RegExp pattern for the context of a function call in a V8 stack trace. Creates an optional submatch for the namespace identifier including the "new" keyword for constructor calls (e.g. "new foo.Bar").

code »goog.testing.stacktrace.V8_FUNCTION_CALL_PATTERN_ : `string`

RegExp pattern for function call in the V8 stack trace. Creates 3 submatches with context object (optional), function name and function alias (optional).

code »goog.testing.stacktrace.V8_FUNCTION_NAME_PATTERN_ : `string`

RegExp pattern for function names and constructor calls in the V8 stack trace.

code »goog.testing.stacktrace.V8_STACK_FRAME_REGEXP_ : `!RegExp`

Regular expression for parsing one stack frame in V8. For more information on V8 stack frame formats, see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi.