@@ -54,17 +54,20 @@ function validateContent(report, fields = []) {
54
54
55
55
function _validateContent ( report , fields = [ ] ) {
56
56
const isWindows = process . platform === 'win32' ;
57
+ const isJavaScriptThreadReport = report . javascriptStack != null ;
57
58
58
59
// Verify that all sections are present as own properties of the report.
59
- const sections = [ 'header' , 'javascriptStack' , 'nativeStack' ,
60
- 'javascriptHeap' , 'libuv' , 'environmentVariables' ,
60
+ const sections = [ 'header' , 'nativeStack' , 'libuv' , 'environmentVariables' ,
61
61
'sharedObjects' , 'resourceUsage' , 'workers' ] ;
62
62
if ( ! isWindows )
63
63
sections . push ( 'userLimits' ) ;
64
64
65
65
if ( report . uvthreadResourceUsage )
66
66
sections . push ( 'uvthreadResourceUsage' ) ;
67
67
68
+ if ( isJavaScriptThreadReport )
69
+ sections . push ( 'javascriptStack' , 'javascriptHeap' ) ;
70
+
68
71
checkForUnknownFields ( report , sections ) ;
69
72
sections . forEach ( ( section ) => {
70
73
assert ( report . hasOwnProperty ( section ) ) ;
@@ -163,19 +166,6 @@ function _validateContent(report, fields = []) {
163
166
} ) ;
164
167
assert . strictEqual ( header . host , os . hostname ( ) ) ;
165
168
166
- // Verify the format of the javascriptStack section.
167
- checkForUnknownFields ( report . javascriptStack ,
168
- [ 'message' , 'stack' , 'errorProperties' ] ) ;
169
- assert . strictEqual ( typeof report . javascriptStack . errorProperties ,
170
- 'object' ) ;
171
- assert . strictEqual ( typeof report . javascriptStack . message , 'string' ) ;
172
- if ( report . javascriptStack . stack !== undefined ) {
173
- assert ( Array . isArray ( report . javascriptStack . stack ) ) ;
174
- report . javascriptStack . stack . forEach ( ( frame ) => {
175
- assert . strictEqual ( typeof frame , 'string' ) ;
176
- } ) ;
177
- }
178
-
179
169
// Verify the format of the nativeStack section.
180
170
assert ( Array . isArray ( report . nativeStack ) ) ;
181
171
report . nativeStack . forEach ( ( frame ) => {
@@ -186,26 +176,41 @@ function _validateContent(report, fields = []) {
186
176
assert . strictEqual ( typeof frame . symbol , 'string' ) ;
187
177
} ) ;
188
178
189
- // Verify the format of the javascriptHeap section.
190
- const heap = report . javascriptHeap ;
191
- const jsHeapFields = [ 'totalMemory' , 'totalCommittedMemory' , 'usedMemory' ,
192
- 'availableMemory' , 'memoryLimit' , 'heapSpaces' ] ;
193
- checkForUnknownFields ( heap , jsHeapFields ) ;
194
- assert ( Number . isSafeInteger ( heap . totalMemory ) ) ;
195
- assert ( Number . isSafeInteger ( heap . totalCommittedMemory ) ) ;
196
- assert ( Number . isSafeInteger ( heap . usedMemory ) ) ;
197
- assert ( Number . isSafeInteger ( heap . availableMemory ) ) ;
198
- assert ( Number . isSafeInteger ( heap . memoryLimit ) ) ;
199
- assert ( typeof heap . heapSpaces === 'object' && heap . heapSpaces !== null ) ;
200
- const heapSpaceFields = [ 'memorySize' , 'committedMemory' , 'capacity' , 'used' ,
201
- 'available' ] ;
202
- Object . keys ( heap . heapSpaces ) . forEach ( ( spaceName ) => {
203
- const space = heap . heapSpaces [ spaceName ] ;
204
- checkForUnknownFields ( space , heapSpaceFields ) ;
205
- heapSpaceFields . forEach ( ( field ) => {
206
- assert ( Number . isSafeInteger ( space [ field ] ) ) ;
179
+ if ( isJavaScriptThreadReport ) {
180
+ // Verify the format of the javascriptStack section.
181
+ checkForUnknownFields ( report . javascriptStack ,
182
+ [ 'message' , 'stack' , 'errorProperties' ] ) ;
183
+ assert . strictEqual ( typeof report . javascriptStack . errorProperties ,
184
+ 'object' ) ;
185
+ assert . strictEqual ( typeof report . javascriptStack . message , 'string' ) ;
186
+ if ( report . javascriptStack . stack !== undefined ) {
187
+ assert ( Array . isArray ( report . javascriptStack . stack ) ) ;
188
+ report . javascriptStack . stack . forEach ( ( frame ) => {
189
+ assert . strictEqual ( typeof frame , 'string' ) ;
190
+ } ) ;
191
+ }
192
+
193
+ // Verify the format of the javascriptHeap section.
194
+ const heap = report . javascriptHeap ;
195
+ const jsHeapFields = [ 'totalMemory' , 'totalCommittedMemory' , 'usedMemory' ,
196
+ 'availableMemory' , 'memoryLimit' , 'heapSpaces' ] ;
197
+ checkForUnknownFields ( heap , jsHeapFields ) ;
198
+ assert ( Number . isSafeInteger ( heap . totalMemory ) ) ;
199
+ assert ( Number . isSafeInteger ( heap . totalCommittedMemory ) ) ;
200
+ assert ( Number . isSafeInteger ( heap . usedMemory ) ) ;
201
+ assert ( Number . isSafeInteger ( heap . availableMemory ) ) ;
202
+ assert ( Number . isSafeInteger ( heap . memoryLimit ) ) ;
203
+ assert ( typeof heap . heapSpaces === 'object' && heap . heapSpaces !== null ) ;
204
+ const heapSpaceFields = [ 'memorySize' , 'committedMemory' , 'capacity' ,
205
+ 'used' , 'available' ] ;
206
+ Object . keys ( heap . heapSpaces ) . forEach ( ( spaceName ) => {
207
+ const space = heap . heapSpaces [ spaceName ] ;
208
+ checkForUnknownFields ( space , heapSpaceFields ) ;
209
+ heapSpaceFields . forEach ( ( field ) => {
210
+ assert ( Number . isSafeInteger ( space [ field ] ) ) ;
211
+ } ) ;
207
212
} ) ;
208
- } ) ;
213
+ }
209
214
210
215
// Verify the format of the resourceUsage section.
211
216
const usage = report . resourceUsage ;
0 commit comments