File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,15 @@ const Xhook = function(url, options) {
1111 if ( options == null ) {
1212 options = { headers : { } } ;
1313 }
14- options . url = url ;
14+
1515 let request = null ;
1616
17+ if ( url instanceof Request ) {
18+ request = url
19+ } else {
20+ options . url = url ;
21+ }
22+
1723 const beforeHooks = hooks . listeners ( "before" ) ;
1824 const afterHooks = hooks . listeners ( "after" ) ;
1925
Original file line number Diff line number Diff line change 1+ import { test , expect } from "@playwright/test" ;
2+ import { createWaitting } from '../test.util' ;
3+
4+ test ( "Should preserve headers of Request" , async ( { page } ) => {
5+ const url = "http://127.0.0.1:8080/example/common.html"
6+ await page . goto ( url ) ;
7+ const { waitting, $resolve } = createWaitting ( )
8+ page . on ( 'requestfinished' , ( req ) => {
9+ $resolve ( req . headers ( ) )
10+ } )
11+ await page . evaluate ( ( url ) => {
12+ const req = new Request ( url , {
13+ headers : {
14+ "custom-xhook-header" : "1"
15+ }
16+ } )
17+ fetch ( req )
18+ } , url )
19+ const headers = await waitting ;
20+ expect ( headers ) . toMatchObject ( { 'custom-xhook-header' : '1' } )
21+ } ) ;
22+
You can’t perform that action at this time.
0 commit comments