File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -635,6 +635,9 @@ function createRepl(inspector) {
635635
636636 // List source code
637637 function list ( delta = 5 ) {
638+ if ( ! selectedFrame ) {
639+ throw new ERR_DEBUGGER_ERROR ( 'Requires execution to be paused' ) ;
640+ }
638641 return selectedFrame . list ( delta ) . then ( null , ( error ) => {
639642 print ( "You can't list source code right now" ) ;
640643 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+ cli . waitForInitialBreak ( )
14+ . then ( ( ) => cli . waitForPrompt ( ) )
15+ . then ( ( ) => cli . command ( 'list(0)' ) )
16+ . then ( ( ) => {
17+ assert . match ( cli . output , / > 1 l e t x = 1 ; / ) ;
18+ } )
19+ . then ( ( ) => cli . command ( 'list(1)' ) )
20+ . then ( ( ) => {
21+ assert . match ( cli . output , / > 1 l e t x = 1 ; \n { 2 } 2 x = x \+ 1 ; / ) ;
22+ } )
23+ . then ( ( ) => cli . command ( 'list(10)' ) )
24+ . then ( ( ) => {
25+ assert . match ( cli . output , / > 1 l e t x = 1 ; \n { 2 } 2 x = x \+ 1 ; \n { 2 } 3 m o d u l e \. e x p o r t s = x ; \n { 2 } 4 / ) ;
26+ } )
27+ . then ( ( ) => cli . command ( 'c' ) )
28+ . then ( ( ) => cli . waitFor ( / d i s c o n n e c t / ) )
29+ . then ( ( ) => cli . waitForPrompt ( ) )
30+ . then ( ( ) => cli . command ( 'list()' ) )
31+ . then ( ( ) => {
32+ 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 / ) ;
33+ } )
34+ . finally ( ( ) => cli . quit ( ) )
35+ . then ( common . mustCall ( ) ) ;
You can’t perform that action at this time.
0 commit comments