Skip to content

Commit

Permalink
test: sync XHR interception (microsoft#28462)
Browse files Browse the repository at this point in the history
The test now ensures that the request is actually continued.

Reference microsoft#28461
  • Loading branch information
yury-s authored Dec 5, 2023
1 parent c701895 commit d437e26
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/page/page-route.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,24 @@ it('should show custom HTTP headers', async ({ page, server }) => {
});

// @see https://github.com/GoogleChrome/puppeteer/issues/4337
it('should work with redirect inside sync XHR', async ({ page, server }) => {
it('should work with redirect inside sync XHR', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28461' });
it.fixme(browserName === 'webkit', 'No Network.requestIntercepted for the request');
await page.goto(server.EMPTY_PAGE);
server.setRedirect('/logo.png', '/pptr.png');
await page.route('**/*', route => route.continue());
let continuePromise;
await page.route('**/*', route => {
continuePromise = route.continue();
});
const status = await page.evaluate(async () => {
const request = new XMLHttpRequest();
request.open('GET', '/logo.png', false); // `false` makes the request synchronous
request.send(null);
return request.status;
});
expect(status).toBe(200);
expect(continuePromise).toBeTruthy();
await continuePromise;
});

it('should pause intercepted XHR until continue', async ({ page, server, browserName }) => {
Expand Down

0 comments on commit d437e26

Please sign in to comment.