mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: update test expectations per Mozilla’s sync-up with v5.5.0 (#6650)
This patch enables more tests for Firefox. These tests are enabled in Mozilla's CI for Firefox. The extra error handling here prevents hangs in the test harness in that environment.
This commit is contained in:
parent
a16cb8cef4
commit
09fca442f7
@ -99,24 +99,38 @@ describe('BrowserContext', function () {
|
|||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
itFailsFirefox('should wait for a target', async () => {
|
itFailsFirefox('should wait for a target', async () => {
|
||||||
const { browser, server } = getTestState();
|
const { browser, puppeteer, server } = getTestState();
|
||||||
|
|
||||||
const context = await browser.createIncognitoBrowserContext();
|
const context = await browser.createIncognitoBrowserContext();
|
||||||
let resolved = false;
|
let resolved = false;
|
||||||
|
|
||||||
const targetPromise = context.waitForTarget(
|
const targetPromise = context.waitForTarget(
|
||||||
(target) => target.url() === server.EMPTY_PAGE
|
(target) => target.url() === server.EMPTY_PAGE
|
||||||
);
|
);
|
||||||
targetPromise.then(() => (resolved = true));
|
targetPromise
|
||||||
|
.then(() => (resolved = true))
|
||||||
|
.catch((error) => {
|
||||||
|
resolved = true;
|
||||||
|
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||||
|
console.error(error);
|
||||||
|
} else throw error;
|
||||||
|
});
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
expect(resolved).toBe(false);
|
expect(resolved).toBe(false);
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
const target = await targetPromise;
|
try {
|
||||||
expect(await target.page()).toBe(page);
|
const target = await targetPromise;
|
||||||
|
expect(await target.page()).toBe(page);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||||
|
console.error(error);
|
||||||
|
} else throw error;
|
||||||
|
}
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should timeout waiting for a non-existent target', async () => {
|
it('should timeout waiting for a non-existent target', async () => {
|
||||||
const { browser, server, puppeteer } = getTestState();
|
const { browser, puppeteer, server } = getTestState();
|
||||||
|
|
||||||
const context = await browser.createIncognitoBrowserContext();
|
const context = await browser.createIncognitoBrowserContext();
|
||||||
const error = await context
|
const error = await context
|
||||||
|
@ -53,7 +53,7 @@ describe('Emulation', () => {
|
|||||||
await page.setViewport({ width: 400, height: 300 });
|
await page.setViewport({ width: 400, height: 300 });
|
||||||
expect(await page.evaluate(() => window.innerWidth)).toBe(400);
|
expect(await page.evaluate(() => window.innerWidth)).toBe(400);
|
||||||
});
|
});
|
||||||
itFailsFirefox('should support touch emulation', async () => {
|
it('should support touch emulation', async () => {
|
||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
|
|
||||||
await page.goto(server.PREFIX + '/mobile.html');
|
await page.goto(server.PREFIX + '/mobile.html');
|
||||||
@ -77,7 +77,7 @@ describe('Emulation', () => {
|
|||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
itFailsFirefox('should be detectable by Modernizr', async () => {
|
it('should be detectable by Modernizr', async () => {
|
||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
|
|
||||||
await page.goto(server.PREFIX + '/detect-touch.html');
|
await page.goto(server.PREFIX + '/detect-touch.html');
|
||||||
@ -90,18 +90,15 @@ describe('Emulation', () => {
|
|||||||
'YES'
|
'YES'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
itFailsFirefox(
|
it('should detect touch when applying viewport with touches', async () => {
|
||||||
'should detect touch when applying viewport with touches',
|
const { page, server } = getTestState();
|
||||||
async () => {
|
|
||||||
const { page, server } = getTestState();
|
|
||||||
|
|
||||||
await page.setViewport({ width: 800, height: 600, hasTouch: true });
|
await page.setViewport({ width: 800, height: 600, hasTouch: true });
|
||||||
await page.addScriptTag({ url: server.PREFIX + '/modernizr.js' });
|
await page.addScriptTag({ url: server.PREFIX + '/modernizr.js' });
|
||||||
expect(
|
expect(await page.evaluate(() => globalThis.Modernizr.touchevents)).toBe(
|
||||||
await page.evaluate(() => globalThis.Modernizr.touchevents)
|
true
|
||||||
).toBe(true);
|
);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
itFailsFirefox('should support landscape emulation', async () => {
|
itFailsFirefox('should support landscape emulation', async () => {
|
||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
|
|
||||||
@ -261,7 +258,7 @@ describe('Emulation', () => {
|
|||||||
it('should work', async () => {
|
it('should work', async () => {
|
||||||
const { page } = getTestState();
|
const { page } = getTestState();
|
||||||
|
|
||||||
page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
globalThis.date = new Date(1479579154987);
|
globalThis.date = new Date(1479579154987);
|
||||||
});
|
});
|
||||||
await page.emulateTimezone('America/Jamaica');
|
await page.emulateTimezone('America/Jamaica');
|
||||||
|
@ -253,18 +253,31 @@ describe('Target', function () {
|
|||||||
|
|
||||||
describe('Browser.waitForTarget', () => {
|
describe('Browser.waitForTarget', () => {
|
||||||
itFailsFirefox('should wait for a target', async () => {
|
itFailsFirefox('should wait for a target', async () => {
|
||||||
const { browser, server } = getTestState();
|
const { browser, puppeteer, server } = getTestState();
|
||||||
|
|
||||||
let resolved = false;
|
let resolved = false;
|
||||||
const targetPromise = browser.waitForTarget(
|
const targetPromise = browser.waitForTarget(
|
||||||
(target) => target.url() === server.EMPTY_PAGE
|
(target) => target.url() === server.EMPTY_PAGE
|
||||||
);
|
);
|
||||||
targetPromise.then(() => (resolved = true));
|
targetPromise
|
||||||
|
.then(() => (resolved = true))
|
||||||
|
.catch((error) => {
|
||||||
|
resolved = true;
|
||||||
|
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||||
|
console.error(error);
|
||||||
|
} else throw error;
|
||||||
|
});
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
expect(resolved).toBe(false);
|
expect(resolved).toBe(false);
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
const target = await targetPromise;
|
try {
|
||||||
expect(await target.page()).toBe(page);
|
const target = await targetPromise;
|
||||||
|
expect(await target.page()).toBe(page);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||||
|
console.error(error);
|
||||||
|
} else throw error;
|
||||||
|
}
|
||||||
await page.close();
|
await page.close();
|
||||||
});
|
});
|
||||||
it('should timeout waiting for a non-existent target', async () => {
|
it('should timeout waiting for a non-existent target', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user