22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- import type { Chrome } from '../../../../ extension-api/ExtensionAPI.js' ;
6- import * as Platform from '../../../ core/platform/platform.js' ;
7- import * as SDK from '../../../ core/sdk/sdk.js' ;
8- import type * as Protocol from '../../../ generated/protocol.js' ;
9- import * as Bindings from '../../../ models/bindings/bindings.js' ;
10- import * as Trace from '../../../ models/trace/trace.js' ;
11- import * as Workspace from '../../../ models/workspace/workspace.js' ;
12- import { createTarget } from '../../../ testing/EnvironmentHelpers.js' ;
13- import { TestPlugin } from '../../../ testing/LanguagePluginHelpers.js' ;
5+ import type { Chrome } from '../../../extension-api/ExtensionAPI.js' ;
6+ import * as Platform from '../../core/platform/platform.js' ;
7+ import * as SDK from '../../core/sdk/sdk.js' ;
8+ import type * as Protocol from '../../generated/protocol.js' ;
9+ import * as Bindings from '../../models/bindings/bindings.js' ;
10+ import * as Trace from '../../models/trace/trace.js' ;
11+ import * as Workspace from '../../models/workspace/workspace.js' ;
12+ import { createTarget } from '../../testing/EnvironmentHelpers.js' ;
13+ import { TestPlugin } from '../../testing/LanguagePluginHelpers.js' ;
1414import {
1515 describeWithMockConnection ,
16- } from '../../../ testing/MockConnection.js' ;
17- import { MockProtocolBackend } from '../../../ testing/MockScopeChain.js' ;
18- import { encodeSourceMap } from '../../../ testing/SourceMapEncoder.js' ;
19- import { loadBasicSourceMapExample } from '../../../ testing/SourceMapHelpers.js' ;
16+ } from '../../testing/MockConnection.js' ;
17+ import { MockProtocolBackend } from '../../testing/MockScopeChain.js' ;
18+ import { encodeSourceMap } from '../../testing/SourceMapEncoder.js' ;
19+ import { loadBasicSourceMapExample } from '../../testing/SourceMapHelpers.js' ;
2020import {
2121 makeMockRendererHandlerData ,
2222 makeMockSamplesHandlerData ,
2323 makeProfileCall ,
24- } from '../../../ testing/TraceHelpers.js' ;
25- import { TraceLoader } from '../../../ testing/TraceLoader.js' ;
24+ } from '../../testing/TraceHelpers.js' ;
25+ import { TraceLoader } from '../../testing/TraceLoader.js' ;
2626
27- import * as Utils from './utils.js' ;
27+ import * as TraceSourceMapsResolver from './trace_source_maps_resolver.js' ;
28+
29+ const { SourceMapsResolver, SourceMappingsUpdated} = TraceSourceMapsResolver ;
2830
2931const { urlString} = Platform . DevToolsPath ;
3032const MINIFIED_FUNCTION_NAME = 'minified' ;
@@ -153,7 +155,7 @@ describeWithMockConnection('SourceMapsResolver', () => {
153155
154156 it ( 'renames nodes from the profile models when the corresponding scripts and source maps have loaded' ,
155157 async function ( ) {
156- const resolver = new Utils . SourceMapsResolver . SourceMapsResolver ( parsedTrace ) ;
158+ const resolver = new SourceMapsResolver ( parsedTrace ) ;
157159
158160 // Test the node's name is minified before the script and source maps load.
159161 assert . strictEqual (
@@ -172,8 +174,7 @@ describeWithMockConnection('SourceMapsResolver', () => {
172174
173175 // Ensure we populate the cache
174176 assert . strictEqual (
175- Utils . SourceMapsResolver . SourceMapsResolver . resolvedCodeLocationForEntry ( profileCallForNameResolving )
176- ?. name ,
177+ SourceMapsResolver . resolvedCodeLocationForEntry ( profileCallForNameResolving ) ?. name ,
177178 AUTHORED_FUNCTION_NAME ) ;
178179 } ) ;
179180
@@ -195,7 +196,7 @@ describeWithMockConnection('SourceMapsResolver', () => {
195196
196197 const { pluginManager} = Bindings . DebuggerWorkspaceBinding . DebuggerWorkspaceBinding . instance ( ) ;
197198 pluginManager . addPlugin ( new Plugin ( ) ) ;
198- const resolver = new Utils . SourceMapsResolver . SourceMapsResolver ( parsedTrace ) ;
199+ const resolver = new SourceMapsResolver ( parsedTrace ) ;
199200 await resolver . install ( ) ;
200201 assert . strictEqual (
201202 Trace . Handlers . ModelHandlers . Samples . getProfileCallFunctionName (
@@ -233,19 +234,17 @@ describeWithMockConnection('SourceMapsResolver', () => {
233234 // For a profile call with mappings, it must return the mapped script.
234235 const parsedTraceWithMappings = parsedTraceFromProfileCalls ( [ profileCallWithMappings ] ) ;
235236 const mapperWithMappings = new Trace . EntityMapper . EntityMapper ( parsedTraceWithMappings ) ;
236- let resolver = new Utils . SourceMapsResolver . SourceMapsResolver ( parsedTraceWithMappings , mapperWithMappings ) ;
237+ let resolver = new SourceMapsResolver ( parsedTraceWithMappings , mapperWithMappings ) ;
237238 await resolver . install ( ) ;
238- let sourceMappedURL = Utils . SourceMapsResolver . SourceMapsResolver . resolvedURLForEntry (
239- parsedTraceWithMappings , profileCallWithMappings ) ;
239+ let sourceMappedURL = SourceMapsResolver . resolvedURLForEntry ( parsedTraceWithMappings , profileCallWithMappings ) ;
240240 assert . strictEqual ( sourceMappedURL , authoredScriptURL ) ;
241241
242242 // For a profile call without mappings, it must return the original URL
243243 const parsedTraceWithoutMappings = parsedTraceFromProfileCalls ( [ profileCallWithNoMappings ] ) ;
244244 const mapperWithoutMappings = new Trace . EntityMapper . EntityMapper ( parsedTraceWithoutMappings ) ;
245- resolver = new Utils . SourceMapsResolver . SourceMapsResolver ( parsedTraceWithoutMappings , mapperWithoutMappings ) ;
245+ resolver = new SourceMapsResolver ( parsedTraceWithoutMappings , mapperWithoutMappings ) ;
246246 await resolver . install ( ) ;
247- sourceMappedURL = Utils . SourceMapsResolver . SourceMapsResolver . resolvedURLForEntry (
248- parsedTraceWithoutMappings , profileCallWithNoMappings ) ;
247+ sourceMappedURL = SourceMapsResolver . resolvedURLForEntry ( parsedTraceWithoutMappings , profileCallWithNoMappings ) ;
249248 assert . strictEqual ( sourceMappedURL , genScriptURL ) ;
250249 } ) ;
251250 } ) ;
@@ -254,8 +253,8 @@ describeWithMockConnection('SourceMapsResolver', () => {
254253 const parsedTrace = await TraceLoader . traceEngine ( this , 'user-timings.json.gz' ) ;
255254 const listener = sinon . spy ( ) ;
256255
257- const sourceMapsResolver = new Utils . SourceMapsResolver . SourceMapsResolver ( parsedTrace ) ;
258- sourceMapsResolver . addEventListener ( Utils . SourceMapsResolver . SourceMappingsUpdated . eventName , listener ) ;
256+ const sourceMapsResolver = new SourceMapsResolver ( parsedTrace ) ;
257+ sourceMapsResolver . addEventListener ( SourceMappingsUpdated . eventName , listener ) ;
259258 await sourceMapsResolver . install ( ) ;
260259 sinon . assert . notCalled ( listener ) ;
261260 } ) ;
@@ -306,7 +305,7 @@ describeWithMockConnection('SourceMapsResolver', () => {
306305 mapper . mappings ( ) . eventsByEntity . set ( testEntity , [ profileCall , profileCallUnmapped ] ) ;
307306 mapper . mappings ( ) . createdEntityCache . set ( 'example-domain.com' , testEntity ) ;
308307
309- const resolver = new Utils . SourceMapsResolver . SourceMapsResolver ( parsedTrace , mapper ) ;
308+ const resolver = new SourceMapsResolver ( parsedTrace , mapper ) ;
310309 // This should update the entities
311310 await resolver . install ( ) ;
312311 const afterEntityOfEvent = mapper . entityForEvent ( profileCall ) ;
0 commit comments