File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ export const EventEmitter = function (nodeStyle) {
38
38
const event = args . shift ( ) ;
39
39
if ( ! nodeStyle ) {
40
40
args [ 0 ] = mergeObjects ( args [ 0 ] , fakeEvent ( event ) ) ;
41
+ Object . defineProperty ( args [ 0 ] , "target" , {
42
+ writable : false ,
43
+ value : this ,
44
+ } ) ;
41
45
}
42
46
const legacylistener = emitter [ `on${ event } ` ] ;
43
47
if ( legacylistener ) {
Original file line number Diff line number Diff line change
1
+ import { test , expect } from "@playwright/test" ;
2
+
3
+ test ( "event target should be xhr self" , async ( { page } ) => {
4
+ await page . goto ( "http://127.0.0.1:8080/example/common.html" ) ;
5
+ const res = await page . evaluate ( async ( ) => {
6
+ return new Promise ( resolve => {
7
+ const xhr = new XMLHttpRequest ( ) ;
8
+ xhr . open ( "GET" , "example1.txt" ) ;
9
+ xhr . addEventListener ( "load" , function ( e ) {
10
+ resolve ( e . target === xhr ) ;
11
+ } ) ;
12
+ xhr . send ( ) ;
13
+ } ) ;
14
+ } ) ;
15
+ expect ( res ) . toEqual ( true ) ;
16
+ } ) ;
You can’t perform that action at this time.
0 commit comments