| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // Flags: --expose-gc | 4 // Flags: --expose-gc |
| 5 | 5 |
| 6 InspectorTest.log('Checks async stack for late .then handlers with gc'); | 6 let {session, contextGroup, Protocol} = InspectorTest.start('Checks async stack
for late .then handlers with gc'); |
| 7 | 7 |
| 8 InspectorTest.addScript(` | 8 contextGroup.addScript(` |
| 9 function foo1() { | 9 function foo1() { |
| 10 gc(); | 10 gc(); |
| 11 debugger; | 11 debugger; |
| 12 } | 12 } |
| 13 | 13 |
| 14 function test() { | 14 function test() { |
| 15 var resolve1; | 15 var resolve1; |
| 16 var p1 = new Promise(resolve => resolve1 = resolve); | 16 var p1 = new Promise(resolve => resolve1 = resolve); |
| 17 gc(); | 17 gc(); |
| 18 var p2 = p1.then(foo1); | 18 var p2 = p1.then(foo1); |
| 19 gc(); | 19 gc(); |
| 20 resolve1(); | 20 resolve1(); |
| 21 gc(); | 21 gc(); |
| 22 var p3 = p1.then(foo1); | 22 var p3 = p1.then(foo1); |
| 23 gc(); | 23 gc(); |
| 24 var p4 = p1.then(foo1); | 24 var p4 = p1.then(foo1); |
| 25 gc(); | 25 gc(); |
| 26 return Promise.all([p2,p3,p4]); | 26 return Promise.all([p2,p3,p4]); |
| 27 } | 27 } |
| 28 //# sourceURL=test.js`, 8, 26); | 28 //# sourceURL=test.js`, 8, 26); |
| 29 | 29 |
| 30 InspectorTest.setupScriptMap(); | 30 session.setupScriptMap(); |
| 31 Protocol.Debugger.onPaused(message => { | 31 Protocol.Debugger.onPaused(message => { |
| 32 InspectorTest.logCallFrames(message.params.callFrames); | 32 session.logCallFrames(message.params.callFrames); |
| 33 var asyncStackTrace = message.params.asyncStackTrace; | 33 var asyncStackTrace = message.params.asyncStackTrace; |
| 34 while (asyncStackTrace) { | 34 while (asyncStackTrace) { |
| 35 InspectorTest.log(`-- ${asyncStackTrace.description} --`); | 35 InspectorTest.log(`-- ${asyncStackTrace.description} --`); |
| 36 InspectorTest.logCallFrames(asyncStackTrace.callFrames); | 36 session.logCallFrames(asyncStackTrace.callFrames); |
| 37 asyncStackTrace = asyncStackTrace.parent; | 37 asyncStackTrace = asyncStackTrace.parent; |
| 38 } | 38 } |
| 39 InspectorTest.log(''); | 39 InspectorTest.log(''); |
| 40 Protocol.Debugger.resume(); | 40 Protocol.Debugger.resume(); |
| 41 }); | 41 }); |
| 42 | 42 |
| 43 Protocol.Debugger.enable(); | 43 Protocol.Debugger.enable(); |
| 44 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); | 44 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| 45 Protocol.Runtime.evaluate({ expression: 'test()//# sourceURL=expr.js', | 45 Protocol.Runtime.evaluate({ expression: 'test()//# sourceURL=expr.js', |
| 46 awaitPromise: true }) | 46 awaitPromise: true }) |
| 47 .then(() => Protocol.Runtime.evaluate({ expression: 'gc()'})) | 47 .then(() => Protocol.Runtime.evaluate({ expression: 'gc()'})) |
| 48 .then(InspectorTest.completeTest); | 48 .then(InspectorTest.completeTest); |
| OLD | NEW |