Commit 04b2f33 1 parent bd952ea commit 04b2f33 Copy full SHA for 04b2f33
File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -635,6 +635,9 @@ function createRepl(inspector) {
635
635
636
636
// List source code
637
637
function list ( delta = 5 ) {
638
+ if ( ! selectedFrame ) {
639
+ throw new ERR_DEBUGGER_ERROR ( 'Requires execution to be paused' ) ;
640
+ }
638
641
return selectedFrame . list ( delta ) . then ( null , ( error ) => {
639
642
print ( "You can't list source code right now" ) ;
640
643
throw error ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+
4
+ common . skipIfInspectorDisabled ( ) ;
5
+
6
+ const fixtures = require ( '../common/fixtures' ) ;
7
+ const startCLI = require ( '../common/debugger' ) ;
8
+
9
+ const assert = require ( 'assert' ) ;
10
+
11
+ const cli = startCLI ( [ fixtures . path ( 'debugger/three-lines.js' ) ] ) ;
12
+
13
+ ( async ( ) => {
14
+ await cli . waitForInitialBreak ( ) ;
15
+ await cli . waitForPrompt ( ) ;
16
+ await cli . command ( 'list(0)' ) ;
17
+ assert . match ( cli . output , / > 1 l e t x = 1 ; / ) ;
18
+ await cli . command ( 'list(1)' ) ;
19
+ assert . match ( cli . output , / > 1 l e t x = 1 ; \r ? \n { 2 } 2 x = x \+ 1 ; / ) ;
20
+ await cli . command ( 'list(10)' ) ;
21
+ assert . match ( cli . output , / > 1 l e t x = 1 ; \r ? \n { 2 } 2 x = x \+ 1 ; \r ? \n { 2 } 3 m o d u l e \. e x p o r t s = x ; \r ? \n { 2 } 4 / ) ;
22
+ await cli . command ( 'c' ) ;
23
+ await cli . waitFor ( / d i s c o n n e c t / ) ;
24
+ await cli . waitFor ( / d e b u g > $ / ) ;
25
+ await cli . command ( 'list()' ) ;
26
+ await cli . waitFor ( / E R R _ D E B U G G E R _ E R R O R / ) ;
27
+ assert . match ( cli . output , / U n c a u g h t E r r o r \[ E R R _ D E B U G G E R _ E R R O R \] : R e q u i r e s e x e c u t i o n t o b e p a u s e d / ) ;
28
+ } ) ( )
29
+ . finally ( ( ) => cli . quit ( ) )
30
+ . then ( common . mustCall ( ) ) ;
You can’t perform that action at this time.
0 commit comments