File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -681,6 +681,9 @@ function createRepl(inspector) {
681681
682682 // List source code
683683 function list ( delta = 5 ) {
684+ if ( ! selectedFrame ) {
685+ throw new ERR_DEBUGGER_ERROR ( 'Requires execution to be paused' ) ;
686+ }
684687 return selectedFrame . list ( delta ) . then ( null , ( error ) => {
685688 print ( "You can't list source code right now" ) ;
686689 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