@@ -15,130 +15,128 @@ import * as Bindings from './bindings.js';
1515
1616const { urlString} = Platform . DevToolsPath ;
1717
18- describe ( 'DebuggerLanguagePlugins' , ( ) => {
19- describe ( 'ExtensionRemoteObject' , ( ) => {
20- describe ( 'isLinearMemoryInspectable' , ( ) => {
21- it ( 'yields false when the extension object has no linear memory address' , ( ) => {
22- const callFrame = sinon . createStubInstance ( SDK . DebuggerModel . CallFrame ) ;
23- const extensionObject : Chrome . DevTools . RemoteObject = {
24- type : 'object' ,
25- hasChildren : false ,
26- } ;
27- const plugin = new TestPlugin ( 'TestPlugin' ) ;
28- const remoteObject =
29- new Bindings . DebuggerLanguagePlugins . ExtensionRemoteObject ( callFrame , extensionObject , plugin ) ;
30- assert . isFalse ( remoteObject . isLinearMemoryInspectable ( ) ) ;
31- } ) ;
18+ describe ( 'ExtensionRemoteObject' , ( ) => {
19+ describe ( 'isLinearMemoryInspectable' , ( ) => {
20+ it ( 'yields false when the extension object has no linear memory address' , ( ) => {
21+ const callFrame = sinon . createStubInstance ( SDK . DebuggerModel . CallFrame ) ;
22+ const extensionObject : Chrome . DevTools . RemoteObject = {
23+ type : 'object' ,
24+ hasChildren : false ,
25+ } ;
26+ const plugin = new TestPlugin ( 'TestPlugin' ) ;
27+ const remoteObject =
28+ new Bindings . DebuggerLanguagePlugins . ExtensionRemoteObject ( callFrame , extensionObject , plugin ) ;
29+ assert . isFalse ( remoteObject . isLinearMemoryInspectable ( ) ) ;
30+ } ) ;
3231
33- it ( 'yields true when the extension object has a linear memory address' , ( ) => {
34- const callFrame = sinon . createStubInstance ( SDK . DebuggerModel . CallFrame ) ;
35- const extensionObject : Chrome . DevTools . RemoteObject = {
36- type : 'object' ,
37- linearMemoryAddress : 42 ,
38- hasChildren : false ,
39- } ;
40- const plugin = new TestPlugin ( 'TestPlugin' ) ;
41- const remoteObject =
42- new Bindings . DebuggerLanguagePlugins . ExtensionRemoteObject ( callFrame , extensionObject , plugin ) ;
43- assert . isTrue ( remoteObject . isLinearMemoryInspectable ( ) ) ;
44- } ) ;
32+ it ( 'yields true when the extension object has a linear memory address' , ( ) => {
33+ const callFrame = sinon . createStubInstance ( SDK . DebuggerModel . CallFrame ) ;
34+ const extensionObject : Chrome . DevTools . RemoteObject = {
35+ type : 'object' ,
36+ linearMemoryAddress : 42 ,
37+ hasChildren : false ,
38+ } ;
39+ const plugin = new TestPlugin ( 'TestPlugin' ) ;
40+ const remoteObject =
41+ new Bindings . DebuggerLanguagePlugins . ExtensionRemoteObject ( callFrame , extensionObject , plugin ) ;
42+ assert . isTrue ( remoteObject . isLinearMemoryInspectable ( ) ) ;
4543 } ) ;
4644 } ) ;
45+ } ) ;
4746
48- describe ( 'DebuggerLanguagePluginManager' , ( ) => {
49- describeWithMockConnection ( 'getFunctionInfo' , ( ) => {
50- let target : SDK . Target . Target ;
51- let pluginManager : Bindings . DebuggerLanguagePlugins . DebuggerLanguagePluginManager ;
52-
53- const MISSING_DWO_FILE = 'test.dwo' ;
54- const MISSING_DEBUG_FILES : SDK . DebuggerModel . MissingDebugFiles = {
55- resourceUrl : urlString `${ MISSING_DWO_FILE } ` ,
56- initiator : {
57- target : null ,
58- frameId : null ,
59- extensionId : 'chrome-extension-id' ,
60- initiatorUrl : urlString `chrome-extension-id` ,
61- } ,
62- } ;
63- const FUNCTION_NAME = 'test' ;
64-
65- class Plugin extends TestPlugin {
66- override getFunctionInfo ( _rawLocation : Chrome . DevTools . RawLocation ) :
67- Promise < { frames : Chrome . DevTools . FunctionInfo [ ] , missingSymbolFiles : string [ ] } |
68- { frames : Chrome . DevTools . FunctionInfo [ ] } | { missingSymbolFiles : string [ ] } > {
69- return Promise . resolve ( { missingSymbolFiles : [ ] } ) ;
70- }
71- override handleScript ( _ : SDK . Script . Script ) {
72- return true ;
73- }
74- override addRawModule ( _rawModuleId : string , _symbolsURL : string , _rawModule : Chrome . DevTools . RawModule ) :
75- Promise < string [ ] > {
76- return Promise . resolve ( [ 'https://script-host/script.js' ] ) ;
77- }
47+ describe ( 'DebuggerLanguagePluginManager' , ( ) => {
48+ describeWithMockConnection ( 'getFunctionInfo' , ( ) => {
49+ let target : SDK . Target . Target ;
50+ let pluginManager : Bindings . DebuggerLanguagePlugins . DebuggerLanguagePluginManager ;
51+
52+ const MISSING_DWO_FILE = 'test.dwo' ;
53+ const MISSING_DEBUG_FILES : SDK . DebuggerModel . MissingDebugFiles = {
54+ resourceUrl : urlString `${ MISSING_DWO_FILE } ` ,
55+ initiator : {
56+ target : null ,
57+ frameId : null ,
58+ extensionId : 'chrome-extension-id' ,
59+ initiatorUrl : urlString `chrome-extension-id` ,
60+ } ,
61+ } ;
62+ const FUNCTION_NAME = 'test' ;
63+
64+ class Plugin extends TestPlugin {
65+ override getFunctionInfo ( _rawLocation : Chrome . DevTools . RawLocation ) :
66+ Promise < { frames : Chrome . DevTools . FunctionInfo [ ] , missingSymbolFiles : string [ ] } |
67+ { frames : Chrome . DevTools . FunctionInfo [ ] } | { missingSymbolFiles : string [ ] } > {
68+ return Promise . resolve ( { missingSymbolFiles : [ ] } ) ;
7869 }
79-
80- beforeEach ( ( ) => {
81- target = createTarget ( ) ;
82- const workspace = Workspace . Workspace . WorkspaceImpl . instance ( ) ;
83- const targetManager = target . targetManager ( ) ;
84- const resourceMapping = new Bindings . ResourceMapping . ResourceMapping ( targetManager , workspace ) ;
85- const ignoreListManager = Workspace . IgnoreListManager . IgnoreListManager . instance ( { forceNew : true } ) ;
86- const debuggerWorkspaceBinding = Bindings . DebuggerWorkspaceBinding . DebuggerWorkspaceBinding . instance ( {
87- forceNew : true ,
88- resourceMapping,
89- targetManager,
90- ignoreListManager,
91- } ) ;
92- pluginManager = debuggerWorkspaceBinding . pluginManager ;
93- } ) ;
94-
95- function createAndRegisterScript ( ) : SDK . Script . Script {
96- const debuggerModel = target . model ( SDK . DebuggerModel . DebuggerModel ) as SDK . DebuggerModel . DebuggerModel ;
97- const scriptUrl = urlString `https://script-host/script.js` ;
98- return debuggerModel . parsedScriptSource (
99- '0' as Protocol . Runtime . ScriptId , scriptUrl , 0 , 0 , 0 , 0 , 0 , '' , null , false , undefined , false , false , 0 ,
100- null , null , null , null , null , null , null ) ;
70+ override handleScript ( _ : SDK . Script . Script ) {
71+ return true ;
10172 }
102-
103- it ( 'correctly processes missing debug info if available' , async ( ) => {
104- const plugin = new Plugin ( 'TestPlugin' ) ;
105- sinon . stub ( plugin , 'getFunctionInfo' ) . returns ( Promise . resolve ( { missingSymbolFiles : [ MISSING_DWO_FILE ] } ) ) ;
106- pluginManager . addPlugin ( plugin ) ;
107-
108- const script = createAndRegisterScript ( ) ;
109-
110- const location = sinon . createStubInstance ( SDK . DebuggerModel . Location ) ;
111- const result = await pluginManager . getFunctionInfo ( script , location ) ;
112- Platform . assertNotNullOrUndefined ( result ) ;
113- assert . deepEqual ( result , { missingSymbolFiles : [ MISSING_DEBUG_FILES ] } ) ;
73+ override addRawModule ( _rawModuleId : string , _symbolsURL : string , _rawModule : Chrome . DevTools . RawModule ) :
74+ Promise < string [ ] > {
75+ return Promise . resolve ( [ 'https://script-host/script.js' ] ) ;
76+ }
77+ }
78+
79+ beforeEach ( ( ) => {
80+ target = createTarget ( ) ;
81+ const workspace = Workspace . Workspace . WorkspaceImpl . instance ( ) ;
82+ const targetManager = target . targetManager ( ) ;
83+ const resourceMapping = new Bindings . ResourceMapping . ResourceMapping ( targetManager , workspace ) ;
84+ const ignoreListManager = Workspace . IgnoreListManager . IgnoreListManager . instance ( { forceNew : true } ) ;
85+ const debuggerWorkspaceBinding = Bindings . DebuggerWorkspaceBinding . DebuggerWorkspaceBinding . instance ( {
86+ forceNew : true ,
87+ resourceMapping,
88+ targetManager,
89+ ignoreListManager,
11490 } ) ;
91+ pluginManager = debuggerWorkspaceBinding . pluginManager ;
92+ } ) ;
11593
116- it ( 'correctly returns frames if available' , async ( ) => {
117- const plugin = new Plugin ( 'TestPlugin' ) ;
118- sinon . stub ( plugin , 'getFunctionInfo' ) . returns ( Promise . resolve ( { frames : [ { name : FUNCTION_NAME } ] } ) ) ;
119- pluginManager . addPlugin ( plugin ) ;
94+ function createAndRegisterScript ( ) : SDK . Script . Script {
95+ const debuggerModel = target . model ( SDK . DebuggerModel . DebuggerModel ) as SDK . DebuggerModel . DebuggerModel ;
96+ const scriptUrl = urlString `https://script-host/script.js` ;
97+ return debuggerModel . parsedScriptSource (
98+ '0' as Protocol . Runtime . ScriptId , scriptUrl , 0 , 0 , 0 , 0 , 0 , '' , null , false , undefined , false , false , 0 , null ,
99+ null , null , null , null , null , null ) ;
100+ }
101+
102+ it ( 'correctly processes missing debug info if available' , async ( ) => {
103+ const plugin = new Plugin ( 'TestPlugin' ) ;
104+ sinon . stub ( plugin , 'getFunctionInfo' ) . returns ( Promise . resolve ( { missingSymbolFiles : [ MISSING_DWO_FILE ] } ) ) ;
105+ pluginManager . addPlugin ( plugin ) ;
106+
107+ const script = createAndRegisterScript ( ) ;
108+
109+ const location = sinon . createStubInstance ( SDK . DebuggerModel . Location ) ;
110+ const result = await pluginManager . getFunctionInfo ( script , location ) ;
111+ Platform . assertNotNullOrUndefined ( result ) ;
112+ assert . deepEqual ( result , { missingSymbolFiles : [ MISSING_DEBUG_FILES ] } ) ;
113+ } ) ;
120114
121- const script = createAndRegisterScript ( ) ;
122- const location = sinon . createStubInstance ( SDK . DebuggerModel . Location ) ;
115+ it ( 'correctly returns frames if available' , async ( ) => {
116+ const plugin = new Plugin ( 'TestPlugin' ) ;
117+ sinon . stub ( plugin , 'getFunctionInfo' ) . returns ( Promise . resolve ( { frames : [ { name : FUNCTION_NAME } ] } ) ) ;
118+ pluginManager . addPlugin ( plugin ) ;
123119
124- const result = await pluginManager . getFunctionInfo ( script , location ) ;
125- Platform . assertNotNullOrUndefined ( result ) ;
126- assert . deepEqual ( result , { frames : [ { name : FUNCTION_NAME } ] } ) ;
127- } ) ;
120+ const script = createAndRegisterScript ( ) ;
121+ const location = sinon . createStubInstance ( SDK . DebuggerModel . Location ) ;
128122
129- it ( 'correctly returns frames and missing debug info if both are available' , async ( ) => {
130- const plugin = new Plugin ( 'TestPlugin' ) ;
131- sinon . stub ( plugin , 'getFunctionInfo' )
132- . returns ( Promise . resolve ( { frames : [ { name : FUNCTION_NAME } ] , missingSymbolFiles : [ MISSING_DWO_FILE ] } ) ) ;
133- pluginManager . addPlugin ( plugin ) ;
123+ const result = await pluginManager . getFunctionInfo ( script , location ) ;
124+ Platform . assertNotNullOrUndefined ( result ) ;
125+ assert . deepEqual ( result , { frames : [ { name : FUNCTION_NAME } ] } ) ;
126+ } ) ;
134127
135- const script = createAndRegisterScript ( ) ;
136- const location = sinon . createStubInstance ( SDK . DebuggerModel . Location ) ;
128+ it ( 'correctly returns frames and missing debug info if both are available' , async ( ) => {
129+ const plugin = new Plugin ( 'TestPlugin' ) ;
130+ sinon . stub ( plugin , 'getFunctionInfo' )
131+ . returns ( Promise . resolve ( { frames : [ { name : FUNCTION_NAME } ] , missingSymbolFiles : [ MISSING_DWO_FILE ] } ) ) ;
132+ pluginManager . addPlugin ( plugin ) ;
137133
138- const result = await pluginManager . getFunctionInfo ( script , location ) ;
139- Platform . assertNotNullOrUndefined ( result ) ;
140- assert . deepEqual ( result , { frames : [ { name : FUNCTION_NAME } ] , missingSymbolFiles : [ MISSING_DEBUG_FILES ] } ) ;
141- } ) ;
134+ const script = createAndRegisterScript ( ) ;
135+ const location = sinon . createStubInstance ( SDK . DebuggerModel . Location ) ;
136+
137+ const result = await pluginManager . getFunctionInfo ( script , location ) ;
138+ Platform . assertNotNullOrUndefined ( result ) ;
139+ assert . deepEqual ( result , { frames : [ { name : FUNCTION_NAME } ] , missingSymbolFiles : [ MISSING_DEBUG_FILES ] } ) ;
142140 } ) ;
143141 } ) ;
144142} ) ;
0 commit comments