Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: xhr request type for main resource url (#23174)

Yury Semikhatsky33f3a6002d0e
diff --git a/tests/page/page-event-request.spec.ts b/tests/page/page-event-request.spec.ts
index a76f6b1d95..70a574a241 100644
--- a/tests/page/page-event-request.spec.ts
+++ b/tests/page/page-event-request.spec.ts
@@ -118,3 +118,19 @@ it('should fire requestfailed when intercepting race', async ({ page, server, br
await promsie;
});
+
+it('main resource xhr should have type xhr', async ({ page, server, browserName }) => {
+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/22812' });
+ it.fixme(browserName === 'webkit');
+ await page.goto(server.EMPTY_PAGE);
+ const [request] = await Promise.all([
+ page.waitForEvent('request'),
+ page.evaluate(() => {
+ const x = new XMLHttpRequest();
+ x.open('GET', location.href, false);
+ x.send();
+ })
+ ]);
+ expect(request.isNavigationRequest()).toBe(false);
+ expect(request.resourceType()).toBe('xhr');
+});