@@ -275,15 +275,6 @@ public CDPSession newCDPSession(Frame frame) {
275
275
276
276
@ Override
277
277
public void close (CloseOptions options ) {
278
- withLogging ("BrowserContext.close" , () -> closeImpl (options ));
279
- }
280
-
281
- @ Override
282
- public List <Cookie > cookies (String url ) {
283
- return cookies (url == null ? new ArrayList <>() : Collections .singletonList (url ));
284
- }
285
-
286
- private void closeImpl (CloseOptions options ) {
287
278
if (!closingOrClosed ) {
288
279
closingOrClosed = true ;
289
280
if (options == null ) {
@@ -318,54 +309,48 @@ private void closeImpl(CloseOptions options) {
318
309
runUntil (() -> {}, closePromise );
319
310
}
320
311
312
+ @ Override
313
+ public List <Cookie > cookies (String url ) {
314
+ return cookies (url == null ? new ArrayList <>() : Collections .singletonList (url ));
315
+ }
316
+
317
+
321
318
@ Override
322
319
public void addCookies (List <Cookie > cookies ) {
323
- withLogging ("BrowserContext.addCookies" , () -> {
324
- JsonObject params = new JsonObject ();
325
- params .add ("cookies" , gson ().toJsonTree (cookies ));
326
- sendMessage ("addCookies" , params );
327
- });
320
+ JsonObject params = new JsonObject ();
321
+ params .add ("cookies" , gson ().toJsonTree (cookies ));
322
+ sendMessage ("addCookies" , params );
328
323
}
329
324
330
325
@ Override
331
326
public void addInitScript (String script ) {
332
- withLogging ("BrowserContext.addInitScript" , () -> addInitScriptImpl (script ));
327
+ JsonObject params = new JsonObject ();
328
+ params .addProperty ("source" , script );
329
+ sendMessage ("addInitScript" , params );
333
330
}
334
331
335
332
@ Override
336
333
public void addInitScript (Path path ) {
337
- withLogging ("BrowserContext.addInitScript" , () -> {
338
- try {
339
- byte [] bytes = readAllBytes (path );
340
- addInitScriptImpl (new String (bytes , UTF_8 ));
341
- } catch (IOException e ) {
342
- throw new PlaywrightException ("Failed to read script from file" , e );
343
- }
344
- });
334
+ try {
335
+ byte [] bytes = readAllBytes (path );
336
+ addInitScript (new String (bytes , UTF_8 ));
337
+ } catch (IOException e ) {
338
+ throw new PlaywrightException ("Failed to read script from file" , e );
339
+ }
345
340
}
346
341
347
342
@ Override
348
343
public List <Page > backgroundPages () {
349
344
return new ArrayList <>(backgroundPages );
350
345
}
351
346
352
- private void addInitScriptImpl (String script ) {
353
- JsonObject params = new JsonObject ();
354
- params .addProperty ("source" , script );
355
- sendMessage ("addInitScript" , params );
356
- }
357
-
358
347
@ Override
359
348
public BrowserImpl browser () {
360
349
return browser ;
361
350
}
362
351
363
352
@ Override
364
353
public void clearCookies (ClearCookiesOptions options ) {
365
- withLogging ("BrowserContext.clearCookies" , () -> clearCookiesImpl (options ));
366
- }
367
-
368
- private void clearCookiesImpl (ClearCookiesOptions options ) {
369
354
if (options == null ) {
370
355
options = new ClearCookiesOptions ();
371
356
}
@@ -388,15 +373,11 @@ private static void setStringOrRegex(JsonObject params, String name, Object valu
388
373
389
374
@ Override
390
375
public void clearPermissions () {
391
- withLogging ( "BrowserContext.clearPermissions" , () -> sendMessage ("clearPermissions" ) );
376
+ sendMessage ("clearPermissions" );
392
377
}
393
378
394
379
@ Override
395
380
public List <Cookie > cookies (List <String > urls ) {
396
- return withLogging ("BrowserContext.cookies" , () -> cookiesImpl (urls ));
397
- }
398
-
399
- private List <Cookie > cookiesImpl (List <String > urls ) {
400
381
JsonObject params = new JsonObject ();
401
382
if (urls == null ) {
402
383
urls = new ArrayList <>();
@@ -409,7 +390,7 @@ private List<Cookie> cookiesImpl(List<String> urls) {
409
390
410
391
@ Override
411
392
public void exposeBinding (String name , BindingCallback playwrightBinding , ExposeBindingOptions options ) {
412
- withLogging ( "BrowserContext.exposeBinding" , () -> exposeBindingImpl (name , playwrightBinding , options ) );
393
+ exposeBindingImpl (name , playwrightBinding , options );
413
394
}
414
395
415
396
private void exposeBindingImpl (String name , BindingCallback playwrightBinding , ExposeBindingOptions options ) {
@@ -433,16 +414,11 @@ private void exposeBindingImpl(String name, BindingCallback playwrightBinding, E
433
414
434
415
@ Override
435
416
public void exposeFunction (String name , FunctionCallback playwrightFunction ) {
436
- withLogging ("BrowserContext.exposeFunction" ,
437
- () -> exposeBindingImpl (name , (BindingCallback .Source source , Object ... args ) -> playwrightFunction .call (args ), null ));
417
+ exposeBindingImpl (name , (BindingCallback .Source source , Object ... args ) -> playwrightFunction .call (args ), null );
438
418
}
439
419
440
420
@ Override
441
421
public void grantPermissions (List <String > permissions , GrantPermissionsOptions options ) {
442
- withLogging ("BrowserContext.grantPermissions" , () -> grantPermissionsImpl (permissions , options ));
443
- }
444
-
445
- private void grantPermissionsImpl (List <String > permissions , GrantPermissionsOptions options ) {
446
422
if (options == null ) {
447
423
options = new GrantPermissionsOptions ();
448
424
}
@@ -456,10 +432,6 @@ private void grantPermissionsImpl(List<String> permissions, GrantPermissionsOpti
456
432
457
433
@ Override
458
434
public PageImpl newPage () {
459
- return withLogging ("BrowserContext.newPage" , () -> newPageImpl ());
460
- }
461
-
462
- private PageImpl newPageImpl () {
463
435
if (ownerPage != null ) {
464
436
throw new PlaywrightException ("Please use browser.newContext()" );
465
437
}
@@ -508,10 +480,8 @@ public void routeFromHAR(Path har, RouteFromHAROptions options) {
508
480
}
509
481
510
482
private void route (UrlMatcher matcher , Consumer <Route > handler , RouteOptions options ) {
511
- withLogging ("BrowserContext.route" , () -> {
512
- routes .add (matcher , handler , options == null ? null : options .times );
513
- updateInterceptionPatterns ();
514
- });
483
+ routes .add (matcher , handler , options == null ? null : options .times );
484
+ updateInterceptionPatterns ();
515
485
}
516
486
517
487
@ Override
@@ -530,10 +500,8 @@ public void routeWebSocket(Predicate<String> predicate, Consumer<WebSocketRoute>
530
500
}
531
501
532
502
private void routeWebSocketImpl (UrlMatcher matcher , Consumer <WebSocketRoute > handler ) {
533
- withLogging ("BrowserContext.routeWebSocket" , () -> {
534
- webSocketRoutes .add (matcher , handler );
535
- updateWebSocketInterceptionPatterns ();
536
- });
503
+ webSocketRoutes .add (matcher , handler );
504
+ updateWebSocketInterceptionPatterns ();
537
505
}
538
506
539
507
void recordIntoHar (PageImpl page , Path har , RouteFromHAROptions options , HarContentPolicy contentPolicy ) {
@@ -572,46 +540,36 @@ public void setDefaultTimeout(double timeout) {
572
540
573
541
@ Override
574
542
public void setExtraHTTPHeaders (Map <String , String > headers ) {
575
- withLogging ("BrowserContext.setExtraHTTPHeaders" , () -> {
576
- JsonObject params = new JsonObject ();
577
- JsonArray jsonHeaders = new JsonArray ();
578
- for (Map .Entry <String , String > e : headers .entrySet ()) {
579
- JsonObject header = new JsonObject ();
580
- header .addProperty ("name" , e .getKey ());
581
- header .addProperty ("value" , e .getValue ());
582
- jsonHeaders .add (header );
583
- }
584
- params .add ("headers" , jsonHeaders );
585
- sendMessage ("setExtraHTTPHeaders" , params );
586
- });
543
+ JsonObject params = new JsonObject ();
544
+ JsonArray jsonHeaders = new JsonArray ();
545
+ for (Map .Entry <String , String > e : headers .entrySet ()) {
546
+ JsonObject header = new JsonObject ();
547
+ header .addProperty ("name" , e .getKey ());
548
+ header .addProperty ("value" , e .getValue ());
549
+ jsonHeaders .add (header );
550
+ }
551
+ params .add ("headers" , jsonHeaders );
552
+ sendMessage ("setExtraHTTPHeaders" , params );
587
553
}
588
554
589
555
@ Override
590
556
public void setGeolocation (Geolocation geolocation ) {
591
- withLogging ("BrowserContext.setGeolocation" , () -> {
592
- JsonObject params = new JsonObject ();
593
- if (geolocation != null ) {
594
- params .add ("geolocation" , gson ().toJsonTree (geolocation ));
595
- }
596
- sendMessage ("setGeolocation" , params );
597
- });
557
+ JsonObject params = new JsonObject ();
558
+ if (geolocation != null ) {
559
+ params .add ("geolocation" , gson ().toJsonTree (geolocation ));
560
+ }
561
+ sendMessage ("setGeolocation" , params );
598
562
}
599
563
600
564
@ Override
601
565
public void setOffline (boolean offline ) {
602
- withLogging ("BrowserContext.setOffline" , () -> {
603
- JsonObject params = new JsonObject ();
604
- params .addProperty ("offline" , offline );
605
- sendMessage ("setOffline" , params );
606
- });
566
+ JsonObject params = new JsonObject ();
567
+ params .addProperty ("offline" , offline );
568
+ sendMessage ("setOffline" , params );
607
569
}
608
570
609
571
@ Override
610
572
public String storageState (StorageStateOptions options ) {
611
- return withLogging ("BrowserContext.storageState" , () -> storageStateImpl (options ));
612
- }
613
-
614
- private String storageStateImpl (StorageStateOptions options ) {
615
573
if (options == null ) {
616
574
options = new StorageStateOptions ();
617
575
}
@@ -633,10 +591,8 @@ public TracingImpl tracing() {
633
591
634
592
@ Override
635
593
public void unrouteAll () {
636
- withLogging ("BrowserContext.unrouteAll" , () -> {
637
- routes .removeAll ();
638
- updateInterceptionPatterns ();
639
- });
594
+ routes .removeAll ();
595
+ updateInterceptionPatterns ();
640
596
}
641
597
642
598
@ Override
@@ -687,10 +643,8 @@ public R get() {
687
643
}
688
644
689
645
private void unroute (UrlMatcher matcher , Consumer <Route > handler ) {
690
- withLogging ("BrowserContext.unroute" , () -> {
691
- routes .remove (matcher , handler );
692
- updateInterceptionPatterns ();
693
- });
646
+ routes .remove (matcher , handler );
647
+ updateInterceptionPatterns ();
694
648
}
695
649
696
650
private void updateInterceptionPatterns () {
0 commit comments