tests: async fallback handlers (#15027)

This commit is contained in:
Ross Wollman 2022-06-21 16:53:36 -07:00 committed by GitHub
parent f2b3491705
commit 25bc4c4ac7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View file

@ -330,3 +330,24 @@ it('should chain fallback into page', async ({ context, page, server }) => {
await page.goto(server.EMPTY_PAGE);
expect(intercepted).toEqual([6, 5, 4, 3, 2, 1]);
});
it('should fall back async', async ({ page, context, server }) => {
const intercepted = [];
await context.route('**/empty.html', async route => {
intercepted.push(1);
await new Promise(r => setTimeout(r, 100));
route.fallback();
});
await context.route('**/empty.html', async route => {
intercepted.push(2);
await new Promise(r => setTimeout(r, 100));
route.fallback();
});
await context.route('**/empty.html', async route => {
intercepted.push(3);
await new Promise(r => setTimeout(r, 100));
route.fallback();
});
await page.goto(server.EMPTY_PAGE);
expect(intercepted).toEqual([3, 2, 1]);
});

View file

@ -40,6 +40,27 @@ it('should fall back', async ({ page, server }) => {
expect(intercepted).toEqual([3, 2, 1]);
});
it('should fall back async', async ({ page, server }) => {
const intercepted = [];
await page.route('**/empty.html', async route => {
intercepted.push(1);
await new Promise(r => setTimeout(r, 100));
route.fallback();
});
await page.route('**/empty.html', async route => {
intercepted.push(2);
await new Promise(r => setTimeout(r, 100));
route.fallback();
});
await page.route('**/empty.html', async route => {
intercepted.push(3);
await new Promise(r => setTimeout(r, 100));
route.fallback();
});
await page.goto(server.EMPTY_PAGE);
expect(intercepted).toEqual([3, 2, 1]);
});
it('should not chain fulfill', async ({ page, server }) => {
let failed = false;
await page.route('**/empty.html', route => {