@@ -7,87 +7,16 @@ requestLongerTimeout(4);
7
7
// Tests loading sourcemapped sources for Babel's compile output.
8
8
9
9
async function breakpointScopes ( dbg , fixture , { line, column } , scopes ) {
10
- const { selectors : { getBreakpoint, getBreakpoints } , getState } = dbg ;
11
-
12
10
const filename = `fixtures/${ fixture } /input.js` ;
13
- await waitForSources ( dbg , filename ) ;
14
-
15
- ok ( true , "Original sources exist" ) ;
16
- const source = findSource ( dbg , filename ) ;
17
-
18
- await selectSource ( dbg , source ) ;
19
-
20
- // Test that breakpoint is not off by a line.
21
- await addBreakpoint ( dbg , source , line ) ;
22
-
23
- is ( getBreakpoints ( getState ( ) ) . size , 1 , "One breakpoint exists" ) ;
24
- ok (
25
- getBreakpoint ( getState ( ) , { sourceId : source . id , line, column } ) ,
26
- "Breakpoint has correct line"
27
- ) ;
28
-
29
11
const fnName = fixture . replace ( / - ( [ a - z ] ) / g, ( s , c ) => c . toUpperCase ( ) ) ;
30
12
31
- const invokeResult = invokeInTab ( fnName ) ;
32
-
33
- let invokeFailed = await Promise . race ( [
34
- waitForPaused ( dbg ) ,
35
- invokeResult . then ( ( ) => new Promise ( ( ) => { } ) , ( ) => true )
36
- ] ) ;
37
-
38
- if ( invokeFailed ) {
39
- return invokeResult ;
40
- }
41
-
42
- assertPausedLocation ( dbg ) ;
43
-
44
- await assertScopes ( dbg , scopes ) ;
45
-
46
- await removeBreakpoint ( dbg , source . id , line , column ) ;
47
-
48
- is ( getBreakpoints ( getState ( ) ) . size , 0 , "Breakpoint reverted" ) ;
49
-
50
- await resume ( dbg ) ;
51
-
52
- // If the invoke errored later somehow, capture here so the error is reported nicely.
53
- await invokeResult ;
13
+ await invokeWithBreakpoint ( dbg , fnName , filename , { line, column } , async ( ) => {
14
+ await assertScopes ( dbg , scopes ) ;
15
+ } ) ;
54
16
55
17
ok ( true , `Ran tests for ${ fixture } at line ${ line } column ${ column } ` ) ;
56
18
}
57
19
58
- async function expandAllScopes ( dbg ) {
59
- const scopes = await waitForElement ( dbg , "scopes" ) ;
60
- const scopeElements = scopes . querySelectorAll (
61
- `.tree-node[aria-level="1"][data-expandable="true"]:not([aria-expanded="true"])`
62
- ) ;
63
- const indices = Array . from ( scopeElements , el => {
64
- return Array . prototype . indexOf . call ( el . parentNode . childNodes , el ) ;
65
- } ) . reverse ( ) ;
66
-
67
- for ( const index of indices ) {
68
- await toggleScopeNode ( dbg , index + 1 ) ;
69
- }
70
- }
71
-
72
- async function assertScopes ( dbg , items ) {
73
- await expandAllScopes ( dbg ) ;
74
-
75
- for ( const [ i , val ] of items . entries ( ) ) {
76
- if ( Array . isArray ( val ) ) {
77
- is ( getScopeLabel ( dbg , i + 1 ) , val [ 0 ] ) ;
78
- is (
79
- getScopeValue ( dbg , i + 1 ) ,
80
- val [ 1 ] ,
81
- `"${ val [ 0 ] } " has the expected "${ val [ 1 ] } " value`
82
- ) ;
83
- } else {
84
- is ( getScopeLabel ( dbg , i + 1 ) , val ) ;
85
- }
86
- }
87
-
88
- is ( getScopeLabel ( dbg , items . length + 1 ) , "Window" ) ;
89
- }
90
-
91
20
add_task ( async function ( ) {
92
21
await pushPref ( "devtools.debugger.features.map-scopes" , true ) ;
93
22
0 commit comments