test: serviceWorker should intercept document request (#21031)

Not sure whats actually going on here, turns out this breaks the trace
viewer on firefox. -> all the iframes won't work.

Can't repro on stock firefox, so seems like something fishy on our end.

References #20259
This commit is contained in:
Max Schmitt 2023-02-21 19:36:19 +01:00 коммит произвёл GitHub
Родитель 44eccc0add
Коммит 147e388ec3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -186,3 +186,20 @@ it('should set CloseEvent.wasClean to false when the server terminates a WebSock
}), server.PORT);
expect(wasClean).toBe(false);
});
it('serviceWorker should intercept document request', async ({ page, server, browserName }) => {
it.fixme(browserName === 'firefox');
server.setRoute('/sw.js', (req, res) => {
res.setHeader('Content-Type', 'application/javascript');
res.end(`
self.addEventListener('fetch', event => {
event.respondWith(new Response('intercepted'));
});
`);
});
await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => navigator.serviceWorker.register('/sw.js'));
await page.reload();
expect(await page.textContent('body')).toBe('intercepted');
});