@@ -207,7 +207,7 @@ describe.each(['HTTP', 'HTTPS'])(
207
207
vm : 'bar-vm' ,
208
208
} ,
209
209
{
210
- host : '192.168.0.123:' + serverRef . port ,
210
+ deviceHostHeader : '192.168.0.123:' + serverRef . port ,
211
211
} ,
212
212
) ;
213
213
try {
@@ -240,52 +240,7 @@ describe.each(['HTTP', 'HTTPS'])(
240
240
}
241
241
} ) ;
242
242
243
- test ( 'does not rewrite urls in Debugger.scriptParsed that match the device connection host but are not allowlisted for rewriting' , async ( ) => {
244
- serverRef . app . use ( '/source-map' , serveStaticJson ( { version : 3 } ) ) ;
245
- const { device, debugger_} = await createAndConnectTarget (
246
- serverRef ,
247
- autoCleanup . signal ,
248
- {
249
- app : 'bar-app' ,
250
- id : 'page1' ,
251
- title : 'bar-title' ,
252
- vm : 'bar-vm' ,
253
- } ,
254
- {
255
- host : '192.168.0.123:' + serverRef . port ,
256
- } ,
257
- ) ;
258
- try {
259
- let fetchCalledWithURL ;
260
- fetchSpy . mockImplementationOnce ( url => {
261
- fetchCalledWithURL = url instanceof URL ? url : null ;
262
- throw new Error ( 'Unreachable' ) ;
263
- } ) ;
264
- const sourceMapURL = `${ protocol . toLowerCase ( ) } ://192.168.0.123:${
265
- serverRef . port
266
- } /source-map`;
267
- const scriptParsedMessage = await sendFromTargetToDebugger (
268
- device ,
269
- debugger_ ,
270
- 'page1' ,
271
- {
272
- method : 'Debugger.scriptParsed' ,
273
- params : {
274
- sourceMapURL,
275
- } ,
276
- } ,
277
- ) ;
278
- expect ( fetchCalledWithURL ?. href ) . toEqual ( sourceMapURL ) ;
279
- expect ( scriptParsedMessage . params . sourceMapURL ) . toEqual (
280
- `${ protocol . toLowerCase ( ) } ://192.168.0.123:${ serverRef . port } /source-map` ,
281
- ) ;
282
- } finally {
283
- device . close ( ) ;
284
- debugger_ . close ( ) ;
285
- }
286
- } ) ;
287
-
288
- describe . each ( [ '10.0.2.2' , '10.0.3.2' , '127.0.0.1' ] ) (
243
+ describe . each ( [ '10.0.2.2:8080' , '[::1]' , 'example.com:2000' ] ) (
289
244
'%s aliasing to and from localhost' ,
290
245
sourceHost => {
291
246
test ( 'in source map fetching during Debugger.scriptParsed' , async ( ) => {
@@ -300,7 +255,7 @@ describe.each(['HTTP', 'HTTPS'])(
300
255
vm : 'bar-vm' ,
301
256
} ,
302
257
{
303
- host : sourceHost + ':' + serverRef . port ,
258
+ deviceHostHeader : sourceHost ,
304
259
} ,
305
260
) ;
306
261
try {
@@ -311,9 +266,7 @@ describe.each(['HTTP', 'HTTPS'])(
311
266
{
312
267
method : 'Debugger.scriptParsed' ,
313
268
params : {
314
- sourceMapURL : `${ protocol . toLowerCase ( ) } ://${ sourceHost } :${
315
- serverRef . port
316
- } /source-map`,
269
+ sourceMapURL : `${ protocol . toLowerCase ( ) } ://${ sourceHost } /source-map` ,
317
270
} ,
318
271
} ,
319
272
) ;
@@ -337,7 +290,8 @@ describe.each(['HTTP', 'HTTPS'])(
337
290
vm : 'bar-vm' ,
338
291
} ,
339
292
{
340
- host : sourceHost + ':' + serverRef . port ,
293
+ debuggerHostHeader : 'localhost:' + serverRef . port ,
294
+ deviceHostHeader : sourceHost ,
341
295
} ,
342
296
) ;
343
297
try {
@@ -348,9 +302,7 @@ describe.each(['HTTP', 'HTTPS'])(
348
302
{
349
303
method : 'Debugger.scriptParsed' ,
350
304
params : {
351
- url : `${ protocol . toLowerCase ( ) } ://${ sourceHost } :${
352
- serverRef . port
353
- } /some/file.js`,
305
+ url : `${ protocol . toLowerCase ( ) } ://${ sourceHost } /some/file.js` ,
354
306
} ,
355
307
} ,
356
308
) ;
@@ -376,9 +328,7 @@ describe.each(['HTTP', 'HTTPS'])(
376
328
} ,
377
329
) ;
378
330
expect ( setBreakpointByUrlMessage . params . url ) . toEqual (
379
- `${ protocol . toLowerCase ( ) } ://${ sourceHost } :${
380
- serverRef . port
381
- } /some/file.js`,
331
+ `${ protocol . toLowerCase ( ) } ://${ sourceHost } /some/file.js` ,
382
332
) ;
383
333
384
334
const setBreakpointByUrlRegexMessage =
@@ -390,9 +340,20 @@ describe.each(['HTTP', 'HTTPS'])(
390
340
urlRegex : `localhost:${ serverRef . port } |example.com:2000` ,
391
341
} ,
392
342
} ) ;
393
- expect ( setBreakpointByUrlRegexMessage . params . urlRegex ) . toEqual (
394
- `${ sourceHost . replaceAll ( '.' , '\\.' ) } :${ serverRef . port } |example.com:2000` ,
395
- ) ;
343
+
344
+ // urlRegex rewriting is restricted to specific Android IPs that
345
+ // are well-known to route to the host. In this case we only
346
+ // replace hostname - longstanding behaviour.
347
+ if ( sourceHost === '10.0.2.2:8080' ) {
348
+ expect ( setBreakpointByUrlRegexMessage . params . urlRegex ) . toEqual (
349
+ `10\\.0\\.2\\.2:${ serverRef . port } |example.com:2000` ,
350
+ ) ;
351
+ } else {
352
+ // Otherwise expect no change.
353
+ expect ( setBreakpointByUrlRegexMessage . params . urlRegex ) . toEqual (
354
+ `localhost:${ serverRef . port } |example.com:2000` ,
355
+ ) ;
356
+ }
396
357
} finally {
397
358
device . close ( ) ;
398
359
debugger_ . close ( ) ;
@@ -411,7 +372,7 @@ describe.each(['HTTP', 'HTTPS'])(
411
372
vm : 'bar-vm' ,
412
373
} ,
413
374
{
414
- host : sourceHost + ':' + serverRef . port ,
375
+ deviceHostHeader : sourceHost ,
415
376
} ,
416
377
) ;
417
378
try {
@@ -451,7 +412,7 @@ describe.each(['HTTP', 'HTTPS'])(
451
412
vm : 'bar-vm' ,
452
413
} ,
453
414
{
454
- host : '127.0.0.1:' + serverRef . port ,
415
+ deviceHostHeader : '127.0.0.1:' + serverRef . port ,
455
416
} ,
456
417
) ;
457
418
try {
0 commit comments