@@ -6,9 +6,9 @@ import * as Platform from '../../core/platform/platform.js';
66import * as Root from '../../core/root/root.js' ;
77import * as SDK from '../../core/sdk/sdk.js' ;
88import type * as Protocol from '../../generated/protocol.js' ;
9- import { createTarget } from '../../testing/EnvironmentHelpers .js' ;
10- import { describeWithMockConnection } from '../../testing/MockConnection .js' ;
11- import { MockProtocolBackend } from '../../testing/MockScopeChain .js' ;
9+ import { MockDebuggerBackend } from '../../testing/MockScopeChain .js' ;
10+ import { setupRuntimeHooks } from '../../testing/RuntimeHelpers .js' ;
11+ import { setupSettingsHooks } from '../../testing/SettingsHelpers .js' ;
1212import { encodeSourceMap , waitForAllSourceMapsProcessed } from '../../testing/SourceMapEncoder.js' ;
1313import { protocolCallFrame , stringifyFrame } from '../../testing/StackTraceHelpers.js' ;
1414import * as ScopesCodec from '../../third_party/source-map-scopes-codec/source-map-scopes-codec.js' ;
@@ -19,24 +19,17 @@ import * as Bindings from './bindings.js';
1919
2020const { urlString} = Platform . DevToolsPath ;
2121
22- describeWithMockConnection ( 'CompilerScriptMapping' , ( ) => {
23- let backend : MockProtocolBackend ;
22+ describe ( 'CompilerScriptMapping' , ( ) => {
23+ setupRuntimeHooks ( ) ;
24+ setupSettingsHooks ( ) ;
25+
26+ let backend : MockDebuggerBackend ;
2427 let debuggerWorkspaceBinding : Bindings . DebuggerWorkspaceBinding . DebuggerWorkspaceBinding ;
2528 let workspace : Workspace . Workspace . WorkspaceImpl ;
2629
2730 beforeEach ( ( ) => {
28- const targetManager = SDK . TargetManager . TargetManager . instance ( ) ;
29- workspace = Workspace . Workspace . WorkspaceImpl . instance ( { forceNew : true } ) ;
30- const resourceMapping = new Bindings . ResourceMapping . ResourceMapping ( targetManager , workspace ) ;
31- const ignoreListManager = Workspace . IgnoreListManager . IgnoreListManager . instance ( { forceNew : true } ) ;
32- debuggerWorkspaceBinding = Bindings . DebuggerWorkspaceBinding . DebuggerWorkspaceBinding . instance ( {
33- forceNew : true ,
34- resourceMapping,
35- targetManager,
36- ignoreListManager,
37- workspace,
38- } ) ;
39- backend = new MockProtocolBackend ( ) ;
31+ backend = new MockDebuggerBackend ( ) ;
32+ ( { debuggerWorkspaceBinding, workspace} = backend . universe ) ;
4033 } ) ;
4134
4235 afterEach ( async ( ) => {
@@ -58,7 +51,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
5851 } ) ;
5952
6053 it ( 'creates UISourceCodes with the correct content type' , async ( ) => {
61- const target = createTarget ( ) ;
54+ const target = backend . createTarget ( ) ;
6255
6356 const sourceRoot = 'http://example.com' ;
6457 const sources = [ 'foo.js' , 'bar.ts' , 'baz.jsx' ] ;
@@ -75,7 +68,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
7568 } ) ;
7669
7770 it ( 'removes webpack hashes from display names' , async ( ) => {
78- const target = createTarget ( ) ;
71+ const target = backend . createTarget ( ) ;
7972
8073 const sourceRoot = 'http://example.com' ;
8174 const sources = [ 'foo.js?a1b2' , 'two%20words.ts?c3d4' , '?e5f6' ] ;
@@ -93,7 +86,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
9386 } ) ;
9487
9588 it ( 'creates UISourceCodes with the correct media type' , async ( ) => {
96- const target = createTarget ( ) ;
89+ const target = backend . createTarget ( ) ;
9790
9891 const sourceRoot = 'http://example.com' ;
9992 const scriptInfo = {
@@ -118,7 +111,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
118111 } ) ;
119112
120113 it ( 'creates UISourceCodes with the correct content and metadata' , async ( ) => {
121- const target = createTarget ( ) ;
114+ const target = backend . createTarget ( ) ;
122115
123116 const sourceRoot = 'http://example.com' ;
124117 const sourceContent = 'const x = 1; console.log(x)' ;
@@ -145,11 +138,11 @@ describeWithMockConnection('CompilerScriptMapping', () => {
145138
146139 it ( 'creates separate UISourceCodes for separate targets' , async ( ) => {
147140 // Create a main target and a worker child target.
148- const mainTarget = createTarget ( {
141+ const mainTarget = backend . createTarget ( {
149142 id : 'main' as Protocol . Target . TargetID ,
150143 type : SDK . Target . Type . FRAME ,
151144 } ) ;
152- const workerTarget = createTarget ( {
145+ const workerTarget = backend . createTarget ( {
153146 id : 'worker' as Protocol . Target . TargetID ,
154147 type : SDK . Target . Type . ServiceWorker ,
155148 parentTarget : mainTarget ,
@@ -186,14 +179,19 @@ describeWithMockConnection('CompilerScriptMapping', () => {
186179 const uiLocation = await debuggerWorkspaceBinding . rawLocationToUILocation ( rawLocation ) ;
187180 assert . strictEqual ( uiLocation ! . uiSourceCode , uiSourceCode ) ;
188181 }
182+
183+ await Promise . all ( [
184+ mainTarget . model ( SDK . DebuggerModel . DebuggerModel ) ! . sourceMapManager ( ) . waitForSourceMapsProcessedForTest ( ) ,
185+ workerTarget . model ( SDK . DebuggerModel . DebuggerModel ) ! . sourceMapManager ( ) . waitForSourceMapsProcessedForTest ( ) ,
186+ ] ) ;
189187 } ) ;
190188
191189 it ( 'creates separate UISourceCodes for content scripts' , async ( ) => {
192190 // By default content scripts are ignore listed, which will prevent processing the
193191 // source map. We need to disable that option.
194- Workspace . IgnoreListManager . IgnoreListManager . instance ( ) . unIgnoreListContentScripts ( ) ;
192+ backend . universe . ignoreListManager . unIgnoreListContentScripts ( ) ;
195193
196- const target = createTarget ( ) ;
194+ const target = backend . createTarget ( ) ;
197195
198196 const sourceRoot = 'http://example.com' ;
199197 const scriptInfo = {
@@ -233,7 +231,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
233231 } ) ;
234232
235233 it ( 'correctly marks known 3rdparty UISourceCodes' , async ( ) => {
236- const target = createTarget ( ) ;
234+ const target = backend . createTarget ( ) ;
237235
238236 const sourceRoot = 'http://example.com' ;
239237 const scriptInfo = {
@@ -263,7 +261,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
263261 } ) ;
264262
265263 it ( 'correctly maps to inline <script>s with `//# sourceURL` annotations' , async ( ) => {
266- const target = createTarget ( ) ;
264+ const target = backend . createTarget ( ) ;
267265
268266 const sourceRoot = 'http://example.com' ;
269267 const scriptInfo = {
@@ -303,7 +301,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
303301 } ) ;
304302
305303 it ( 'correctly removes UISourceCodes when detaching a sourcemap' , async ( ) => {
306- const target = createTarget ( ) ;
304+ const target = backend . createTarget ( ) ;
307305
308306 const sourceRoot = 'http://example.com' ;
309307 const scriptInfo = {
@@ -335,7 +333,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
335333 } ) ;
336334
337335 it ( 'correctly reports source-mapped lines' , async ( ) => {
338- const target = createTarget ( ) ;
336+ const target = backend . createTarget ( ) ;
339337
340338 const sourceRoot = 'http://example.com' ;
341339 const scriptInfo = {
@@ -371,7 +369,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
371369 // out a dedicated bundle for each route (`route1.js` and `route2.js`). The demo can be
372370 // found at https://devtools-source-identities.glitch.me/webpack-code-split/ for further
373371 // reference.
374- const target = createTarget ( ) ;
372+ const target = backend . createTarget ( ) ;
375373 const sourceRoot = 'webpack:///src' ;
376374
377375 // Load the script and source map for the first route.
@@ -453,7 +451,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
453451 //
454452 // This is a generalization of https://crbug.com/1403362 and http://crbug.com/1403432,
455453 // which both present special cases of the general stale mapping problem.
456- const target = createTarget ( ) ;
454+ const target = backend . createTarget ( ) ;
457455 const sourceRoot = 'webpack:///src' ;
458456
459457 // Load the original bundle.
@@ -533,7 +531,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
533531 } ) ;
534532
535533 it ( 'assumes UTF-8 encoding for source files embedded in source maps' , async ( ) => {
536- const target = createTarget ( ) ;
534+ const target = backend . createTarget ( ) ;
537535
538536 const sourceRoot = 'http://example.com' ;
539537 const sourceContent = 'console.log("Ahoj světe!");' ;
@@ -558,7 +556,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
558556
559557 describe ( 'translateRawFramesStep' , ( ) => {
560558 it ( 'returns false for builtin frames' , async ( ) => {
561- const target = createTarget ( ) ;
559+ const target = backend . createTarget ( ) ;
562560 const compilerScriptMapping = new Bindings . CompilerScriptMapping . CompilerScriptMapping (
563561 target . model ( SDK . DebuggerModel . DebuggerModel ) ! , workspace , debuggerWorkspaceBinding ) ;
564562
@@ -569,7 +567,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
569567 it ( 'translates a single frame using "proposal scopes" information' , async ( ) => {
570568 Root . Runtime . experiments . enableForTest ( Root . ExperimentNames . ExperimentName . USE_SOURCE_MAP_SCOPES ) ;
571569
572- const target = createTarget ( ) ;
570+ const target = backend . createTarget ( ) ;
573571 const compilerScriptMapping = new Bindings . CompilerScriptMapping . CompilerScriptMapping (
574572 target . model ( SDK . DebuggerModel . DebuggerModel ) ! , workspace , debuggerWorkspaceBinding ) ;
575573 const sourceMap = encodeSourceMap ( [
@@ -615,7 +613,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
615613 } ) ;
616614
617615 it ( 'translates a single frame using "fallback" scope information (created from AST and mappigns)' , async ( ) => {
618- const target = createTarget ( ) ;
616+ const target = backend . createTarget ( ) ;
619617 const compilerScriptMapping = new Bindings . CompilerScriptMapping . CompilerScriptMapping (
620618 target . model ( SDK . DebuggerModel . DebuggerModel ) ! , workspace , debuggerWorkspaceBinding ) ;
621619 const sourceMap = encodeSourceMap ( [
@@ -654,7 +652,7 @@ describeWithMockConnection('CompilerScriptMapping', () => {
654652 it ( 'expands inlined frames and populates UISourceCode' , async ( ) => {
655653 Root . Runtime . experiments . enableForTest ( Root . ExperimentNames . ExperimentName . USE_SOURCE_MAP_SCOPES ) ;
656654
657- const target = createTarget ( ) ;
655+ const target = backend . createTarget ( ) ;
658656 const compilerScriptMapping = new Bindings . CompilerScriptMapping . CompilerScriptMapping (
659657 target . model ( SDK . DebuggerModel . DebuggerModel ) ! , workspace , debuggerWorkspaceBinding ) ;
660658 //
0 commit comments