| 23 | } |
| 24 | |
| 25 | func Test_parseCallFrame(t *testing.T) { |
| 26 | tests := []struct { |
| 27 | name string |
| 28 | input string |
| 29 | want callFrame |
| 30 | }{ |
| 31 | { |
| 32 | name: "Chrome 96.0.4664.110 on Linux #1", |
| 33 | input: "at foo (eval at $b (https://gopherjs.github.io/playground/playground.js:102:11836), <anonymous>:25887:60)", |
| 34 | want: callFrame{FuncName: "foo", File: "https://gopherjs.github.io/playground/playground.js", Line: 102, Col: 11836}, |
| 35 | }, |
| 36 | { |
| 37 | name: "Chrome 96, anonymous eval", |
| 38 | input: " at eval (<anonymous>)", |
| 39 | want: callFrame{FuncName: "eval", File: "<anonymous>"}, |
| 40 | }, |
| 41 | { |
| 42 | name: "Chrome 96, anonymous Array.forEach", |
| 43 | input: " at Array.forEach (<anonymous>)", |
| 44 | want: callFrame{FuncName: "Array.forEach", File: "<anonymous>"}, |
| 45 | }, |
| 46 | { |
| 47 | name: "Chrome 96, file location only", |
| 48 | input: "at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.min.js:31:225", |
| 49 | want: callFrame{FuncName: "<none>", File: "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.min.js", Line: 31, Col: 225}, |
| 50 | }, |
| 51 | { |
| 52 | name: "Chrome 96, aliased function", |
| 53 | input: "at k.e.$externalizeWrapper.e.$externalizeWrapper [as run] (https://gopherjs.github.io/playground/playground.js:5:30547)", |
| 54 | want: callFrame{FuncName: "run", File: "https://gopherjs.github.io/playground/playground.js", Line: 5, Col: 30547}, |
| 55 | }, |
| 56 | { |
| 57 | name: "Node.js v12.22.5", |
| 58 | input: " at Script.runInThisContext (vm.js:120:18)", |
| 59 | want: callFrame{FuncName: "Script.runInThisContext", File: "vm.js", Line: 120, Col: 18}, |
| 60 | }, |
| 61 | { |
| 62 | name: "Node.js v12.22.5, aliased function", |
| 63 | input: "at REPLServer.runBound [as eval] (domain.js:440:12)", |
| 64 | want: callFrame{FuncName: "eval", File: "domain.js", Line: 440, Col: 12}, |
| 65 | }, |
| 66 | { |
| 67 | name: "Firefox 78.15.0esr Linux", |
| 68 | input: "getEvalResult@resource://devtools/server/actors/webconsole/eval-with-debugger.js:231:24", |
| 69 | want: callFrame{FuncName: "getEvalResult", File: "resource://devtools/server/actors/webconsole/eval-with-debugger.js", Line: 231, Col: 24}, |
| 70 | }, |
| 71 | { |
| 72 | name: "Firefox anonymous function", |
| 73 | input: "@filename.js:10:15", |
| 74 | want: callFrame{FuncName: "<none>", File: "filename.js", Line: 10, Col: 15}, |
| 75 | }, |
| 76 | { |
| 77 | name: "Firefox no column number", |
| 78 | input: "foo@bar.js:42", |
| 79 | want: callFrame{FuncName: "foo", File: "bar.js", Line: 42}, |
| 80 | }, |
| 81 | { |
| 82 | name: "Firefox no line or column", |