Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: worker interception for existing workers (#32494)
Yury Semikhatskydf2bc2d0dc59
diff --git a/tests/page/interception.spec.ts b/tests/page/interception.spec.tsindex 7f3ef98000..338ac97a05 100644--- a/tests/page/interception.spec.ts+++ b/tests/page/interception.spec.ts@@ -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, serveexpect(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);