test: XMLHttpRequest upload events (#21501)

https://github.com/microsoft/playwright/issues/21489
This commit is contained in:
Max Schmitt 2023-03-09 16:21:01 +01:00 committed by GitHub
parent 7746807d9f
commit 9191c72a3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -208,3 +208,23 @@ it('webkit should define window.safari', async ({ page, server, browserName }) =
const defined = await page.evaluate(() => !!(window as any).safari);
expect(defined).toBeTruthy();
});
it('make sure that XMLHttpRequest upload events are emitted correctly', async ({ page, server, browserName, platform }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/21489' });
it.fixme(browserName === 'webkit' && platform === 'win32');
await page.goto(server.EMPTY_PAGE);
const events = await page.evaluate(async () => {
const events: string[] = [];
const xhr = new XMLHttpRequest();
xhr.upload.addEventListener('loadstart', () => events.push('loadstart'));
xhr.upload.addEventListener('progress', () => events.push('progress'));
xhr.upload.addEventListener('load', () => events.push('load'));
xhr.upload.addEventListener('loadend', () => events.push('loadend'));
xhr.open('POST', '/simple.json');
xhr.send('hello');
await new Promise(f => xhr.onload = f);
return events;
});
expect(events).toEqual(['loadstart', 'progress', 'load', 'loadend']);
});