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();
|
||||
});
|
||||
itFailsFirefox('should wait for a target', async () => {
|
||||
const { browser, server } = getTestState();
|
||||
const { browser, puppeteer, server } = getTestState();
|
||||
|
||||
const context = await browser.createIncognitoBrowserContext();
|
||||
let resolved = false;
|
||||
|
||||
const targetPromise = context.waitForTarget(
|
||||
(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();
|
||||
expect(resolved).toBe(false);
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
try {
|
||||
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();
|
||||
});
|
||||
|
||||
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 error = await context
|
||||
|
@ -53,7 +53,7 @@ describe('Emulation', () => {
|
||||
await page.setViewport({ width: 400, height: 300 });
|
||||
expect(await page.evaluate(() => window.innerWidth)).toBe(400);
|
||||
});
|
||||
itFailsFirefox('should support touch emulation', async () => {
|
||||
it('should support touch emulation', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
await page.goto(server.PREFIX + '/mobile.html');
|
||||
@ -77,7 +77,7 @@ describe('Emulation', () => {
|
||||
return promise;
|
||||
}
|
||||
});
|
||||
itFailsFirefox('should be detectable by Modernizr', async () => {
|
||||
it('should be detectable by Modernizr', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
await page.goto(server.PREFIX + '/detect-touch.html');
|
||||
@ -90,18 +90,15 @@ describe('Emulation', () => {
|
||||
'YES'
|
||||
);
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should detect touch when applying viewport with touches',
|
||||
async () => {
|
||||
it('should detect touch when applying viewport with touches', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
await page.setViewport({ width: 800, height: 600, hasTouch: true });
|
||||
await page.addScriptTag({ url: server.PREFIX + '/modernizr.js' });
|
||||
expect(
|
||||
await page.evaluate(() => globalThis.Modernizr.touchevents)
|
||||
).toBe(true);
|
||||
}
|
||||
expect(await page.evaluate(() => globalThis.Modernizr.touchevents)).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
itFailsFirefox('should support landscape emulation', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
@ -261,7 +258,7 @@ describe('Emulation', () => {
|
||||
it('should work', async () => {
|
||||
const { page } = getTestState();
|
||||
|
||||
page.evaluate(() => {
|
||||
await page.evaluate(() => {
|
||||
globalThis.date = new Date(1479579154987);
|
||||
});
|
||||
await page.emulateTimezone('America/Jamaica');
|
||||
|
@ -253,18 +253,31 @@ describe('Target', function () {
|
||||
|
||||
describe('Browser.waitForTarget', () => {
|
||||
itFailsFirefox('should wait for a target', async () => {
|
||||
const { browser, server } = getTestState();
|
||||
const { browser, puppeteer, server } = getTestState();
|
||||
|
||||
let resolved = false;
|
||||
const targetPromise = browser.waitForTarget(
|
||||
(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();
|
||||
expect(resolved).toBe(false);
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
try {
|
||||
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();
|
||||
});
|
||||
it('should timeout waiting for a non-existent target', async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user