test: worker interception for existing workers (#32494)

Failing test for https://github.com/microsoft/playwright/issues/32355
This commit is contained in:
Yury Semikhatsky 2024-09-06 13:17:49 -07:00 committed by GitHub
parent 11441c0fe1
commit df2bc2d0dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -100,8 +100,7 @@ it('should work with glob', async () => {
expect(globToRegex('$^+.\\*()|\\?\\{\\}\\[\\]')).toEqual(/^\$\^\+\.\*\(\)\|\?\{\}\[\]$/);
});
it('should intercept network activity from worker', async function({ page, server, isAndroid, browserName, browserMajorVersion }) {
it.skip(browserName === 'firefox' && browserMajorVersion < 114, 'https://github.com/microsoft/playwright/issues/21760');
it('should intercept network activity from worker', async function({ page, server, isAndroid }) {
it.skip(isAndroid);
await page.goto(server.EMPTY_PAGE);
@ -122,6 +121,35 @@ it('should intercept network activity from worker', async function({ page, serve
expect(msg.text()).toBe('intercepted');
});
it('should intercept worker requests when enabled after worker creation', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/32355' }
}, async function({ page, server, isAndroid, browserName }) {
it.skip(isAndroid);
it.fixme(browserName === 'chromium');
await page.goto(server.EMPTY_PAGE);
server.setRoute('/data_for_worker', (req, res) => res.end('failed to intercept'));
const url = server.PREFIX + '/data_for_worker';
await page.evaluate(url => {
(window as any).w = new Worker(URL.createObjectURL(new Blob([`
onmessage = function(e) {
fetch("${url}").then(response => response.text()).then(console.log);
};
`], { type: 'application/javascript' })));
}, url);
await page.route(url, route => {
route.fulfill({
status: 200,
body: 'intercepted',
}).catch(e => null);
});
const [msg] = await Promise.all([
page.waitForEvent('console'),
page.evaluate(() => (window as any).w.postMessage(''))
]);
expect(msg.text()).toBe('intercepted');
});
it('should intercept network activity from worker 2', async function({ page, server, isAndroid }) {
it.skip(isAndroid);