FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-inspector/test/CallFramesProvider.js at master · programng/node-inspector · GitHub
programng
/
node-inspector
Public
forked from
node-inspector/node-inspector
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node-inspector
/
test
/
CallFramesProvider.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
103 lines (89 loc) · 3.54 KB
Breadcrumbs
node-inspector
/
test
/
CallFramesProvider.js
Copy path
File metadata and controls
103 lines (89 loc) · 3.54 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
var
expect
=
require
(
'chai'
)
.
expect
,
launcher
=
require
(
'./helpers/launcher.js'
)
,
CallFramesProvider
=
require
(
'../lib/CallFramesProvider'
)
.
CallFramesProvider
;
describe
(
'CallFramesProvider'
,
function
(
)
{
launcher
.
stopAllDebuggersAfterEachTest
(
)
;
it
(
'gets stack trace'
,
function
(
done
)
{
launcher
.
runOnBreakInFunction
(
function
(
debuggerClient
)
{
var
provider
=
new
CallFramesProvider
(
{
}
,
debuggerClient
)
;
provider
.
fetchCallFrames
(
function
(
error
,
callFrames
)
{
if
(
error
!==
undefined
&&
error
!==
null
)
{
done
(
error
)
;
return
;
}
// The order of script loading has changed in v0.11
var
scriptId
=
/
^
v
0
\.
1
0
\.
/
.
test
(
process
.
version
)
?
'28'
:
'36'
;
expect
(
callFrames
)
.
to
.
have
.
length
.
least
(
2
)
;
function
objectValueWithId
(
id
,
className
)
{
return
{
type
:
'object'
,
objectId
:
id
,
className
:
className
||
'Object'
,
description
:
className
||
'Object'
}
;
}
assertFrame
(
{
callFrameId
:
'0'
,
functionName
:
'MyObj.myFunc'
,
location
:
{
scriptId
:
scriptId
,
lineNumber
:
8
,
columnNumber
:
4
}
,
scopeChain
:
[
{
object
:
objectValueWithId
(
'scope:0:0'
)
,
type
:
'local'
}
,
{
object
:
objectValueWithId
(
'scope:0:1'
)
,
type
:
'closure'
}
,
{
object
:
objectValueWithId
(
'scope:0:2'
)
,
type
:
'global'
}
]
,
'this'
:
objectValueWithId
(
'1'
)
}
,
callFrames
[
0
]
,
'frame[0]'
)
;
assertFrame
(
{
callFrameId
:
'1'
,
functionName
:
'globalFunc'
,
location
:
{
scriptId
:
scriptId
,
lineNumber
:
13
,
columnNumber
:
6
}
,
scopeChain
:
[
{
object
:
objectValueWithId
(
'scope:1:0'
)
,
type
:
'local'
}
,
{
object
:
objectValueWithId
(
'scope:1:1'
)
,
type
:
'closure'
}
,
{
object
:
objectValueWithId
(
'scope:1:2'
)
,
type
:
'global'
}
]
,
'this'
:
objectValueWithId
(
'10'
,
'global'
)
}
,
callFrames
[
1
]
,
'frame[1]'
)
;
done
(
)
;
}
)
;
}
)
;
}
)
;
it
(
'retrieves specified number of stack traces when configured'
,
function
(
done
)
{
launcher
.
runOnBreakInFunction
(
function
(
debuggerClient
)
{
var
provider
=
new
CallFramesProvider
(
{
stackTraceLimit
:
1
}
,
debuggerClient
)
;
provider
.
fetchCallFrames
(
function
(
error
,
callFrames
)
{
if
(
error
!==
undefined
&&
error
!==
null
)
{
done
(
error
)
;
return
;
}
expect
(
callFrames
)
.
to
.
have
.
length
(
1
)
;
done
(
)
;
}
)
;
}
)
;
}
)
;
}
)
;
function
assertFrame
(
expected
,
actual
,
frameName
)
{
expect
(
actual
.
callFrameId
,
frameName
+
'.callFrameId'
)
.
to
.
equal
(
expected
.
callFrameId
)
;
expect
(
actual
.
functionName
,
frameName
+
'.functionName'
)
.
to
.
equal
(
expected
.
functionName
)
;
assertJSONEqual
(
expected
.
location
,
actual
.
location
,
frameName
+
'.location'
)
;
assertScopeChain
(
expected
.
scopeChain
,
actual
.
scopeChain
,
frameName
+
'.scopeChain'
)
;
assertJSONEqual
(
expected
.
this
,
actual
.
this
,
frameName
+
'.this'
)
;
}
function
assertScopeChain
(
expected
,
actual
,
objectName
)
{
var
i
;
expect
(
actual
.
length
,
objectName
+
'.length'
)
.
to
.
equal
(
expected
.
length
)
;
for
(
i
=
0
;
i
<
expected
.
length
;
i
++
)
{
assertJSONEqual
(
expected
[
i
]
,
actual
[
i
]
,
objectName
+
'['
+
i
+
']'
)
;
}
}
function
assertJSONEqual
(
expected
,
actual
,
message
)
{
var
expectedString
=
expected
?
JSON
.
stringify
(
expected
)
:
expected
;
var
actualString
=
actual
?
JSON
.
stringify
(
actual
)
:
actual
;
expect
(
actualString
,
message
)
.
to
.
equal
(
expectedString
)
;
}
Back
|
FazBrowse Home
|
New Git URL