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) {
11
11
if ( options == null ) {
12
12
options = { headers : { } } ;
13
13
}
14
- options . url = url ;
14
+
15
15
let request = null ;
16
16
17
+ if ( url instanceof Request ) {
18
+ request = url
19
+ } else {
20
+ options . url = url ;
21
+ }
22
+
17
23
const beforeHooks = hooks . listeners ( "before" ) ;
18
24
const afterHooks = hooks . listeners ( "after" ) ;
19
25
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