@@ -21,7 +21,6 @@ import {createDeviceMock} from './InspectorDeviceUtils';
2121import { sendFromDebuggerToTarget } from './InspectorProtocolUtils' ;
2222import { withAbortSignalForEachTest } from './ResourceUtils' ;
2323import { withServerForEachTest } from './ServerUtils' ;
24- import nullthrows from 'nullthrows' ;
2524import until from 'wait-for-expect' ;
2625
2726// WebSocket is unreliable when using fake timers.
@@ -155,136 +154,6 @@ describe.each(['HTTP', 'HTTPS'])(
155154 }
156155 } ) ;
157156
158- test ( 'multiple debuggers to the same page on the same device' , async ( ) => {
159- let device , debugger1 , debugger2 ;
160- try {
161- // Connect a device to the proxy.
162- device = await createDeviceMock (
163- `${ serverRef . serverBaseWsUrl } /inspector/device?device=device1&name=foo&app=bar` ,
164- autoCleanup . signal ,
165- ) ;
166- // Capture a log of events so we can assert on their order later.
167- const events : Array <
168- | ConnectRequest
169- | DisconnectRequest
170- | { event : 'create-debugger-mock' , name : string } ,
171- > = [ ] ;
172- device . disconnect . mockImplementation ( message => {
173- events . push ( message ) ;
174- } ) ;
175- device . connect . mockImplementation ( message => {
176- events . push ( message ) ;
177- } ) ;
178- // Set up the page.
179- device . getPages . mockImplementation ( ( ) => [
180- {
181- app : 'bar-app' ,
182- id : 'page1' ,
183- title : 'bar-title' ,
184- vm : 'bar-vm' ,
185- } ,
186- ] ) ;
187- let pageList : Array < PageDescription > = [ ] ;
188- await until ( async ( ) => {
189- pageList = ( await fetchJson (
190- `${ serverRef . serverBaseUrl } /json` ,
191- // $FlowFixMe[unclear-type]
192- ) ) as any ;
193- expect ( pageList ) . toHaveLength ( 1 ) ;
194- } ) ;
195- const [ { webSocketDebuggerUrl} ] = pageList ;
196-
197- // Connect the first debugger and send a message.
198- events . push ( { event : 'create-debugger-mock' , name : 'debugger1' } ) ;
199- debugger1 = await createDebuggerMock (
200- webSocketDebuggerUrl ,
201- autoCleanup . signal ,
202- ) ;
203- await sendFromDebuggerToTarget ( debugger1 , device , 'page1' , {
204- method : 'Runtime.enable' ,
205- id : 0 ,
206- } ) ;
207-
208- // Connect the second debugger.
209- events . push ( { event : 'create-debugger-mock' , name : 'debugger2' } ) ;
210- debugger2 = await createDebuggerMock (
211- webSocketDebuggerUrl ,
212- autoCleanup . signal ,
213- ) ;
214-
215- // The first debugger gets disconnected. TODO: In the future, we should
216- // amend the protocol to allow for multiple debuggers to connect at the
217- // same time.
218- await until ( async ( ) => {
219- expect ( [
220- // CLOSING
221- 3 ,
222- // CLOSED
223- 4 ,
224- ] ) . toContain ( debugger1 . socket . readyState ) ;
225- } ) ;
226-
227- // Send a message from the second debugger.
228- await sendFromDebuggerToTarget ( debugger2 , device , 'page1' , {
229- method : 'Debugger.enable' ,
230- id : 1 ,
231- } ) ;
232-
233- // Check the order of `connect` and `disconnect` events received by the
234- // device. `create-debugger-mock` events are included for convenience.
235- expect ( events ) . toEqual ( [
236- {
237- event : 'create-debugger-mock' ,
238- name : 'debugger1' ,
239- } ,
240- {
241- event : 'connect' ,
242- payload : {
243- pageId : 'page1' ,
244- sessionId : expect . any ( String ) ,
245- } ,
246- } ,
247- {
248- event : 'create-debugger-mock' ,
249- name : 'debugger2' ,
250- } ,
251- {
252- // NOTE: For debugger1
253- event : 'disconnect' ,
254- payload : {
255- pageId : 'page1' ,
256- sessionId : expect . any ( String ) ,
257- } ,
258- } ,
259- {
260- // NOTE: For debugger2
261- event : 'connect' ,
262- payload : {
263- pageId : 'page1' ,
264- sessionId : expect . any ( String ) ,
265- } ,
266- } ,
267- ] ) ;
268- // Verify that disconnect and second connect use different session IDs
269- // (disconnect is for first debugger, connect is for second debugger)
270- const disconnectEvent = nullthrows (
271- events . find ( e => e . event === 'disconnect' ) ,
272- ) ;
273- const connectEvents = events . filter ( e => e . event === 'connect' ) ;
274- expect ( connectEvents ) . toHaveLength ( 2 ) ;
275- expect ( disconnectEvent . payload . sessionId ) . toBe (
276- connectEvents [ 0 ] . payload . sessionId ,
277- ) ;
278- expect ( disconnectEvent ?. payload . sessionId ) . not . toBe (
279- connectEvents [ 1 ] . payload . sessionId ,
280- ) ;
281- } finally {
282- device ?. close ( ) ;
283- debugger1 ?. close ( ) ;
284- debugger2 ?. close ( ) ;
285- }
286- } ) ;
287-
288157 test ( 'debugger connection to a nonexistent page is rejected' , async ( ) => {
289158 let device , debugger_ ;
290159 try {
@@ -665,23 +534,19 @@ describe.each(['HTTP', 'HTTPS'])(
665534 }
666535 } ) ;
667536
668- test ( 'page with supportsMultipleDebuggers allows concurrent debugger connections' , async ( ) => {
537+ test ( 'allows concurrent debugger connections to a page ' , async ( ) => {
669538 let device , debugger1 , debugger2 ;
670539 try {
671540 device = await createDeviceMock (
672541 `${ serverRef . serverBaseWsUrl } /inspector/device?device=device1&name=foo&app=bar` ,
673542 autoCleanup . signal ,
674543 ) ;
675- // Page with supportsMultipleDebuggers capability
676544 device . getPages . mockImplementation ( ( ) => [
677545 {
678546 app : 'bar-app' ,
679547 id : 'page1' ,
680548 title : 'bar-title' ,
681549 vm : 'bar-vm' ,
682- capabilities : {
683- supportsMultipleDebuggers : true ,
684- } ,
685550 } ,
686551 ] ) ;
687552 let pageList : Array < PageDescription > = [ ] ;
0 commit comments