Skip to content

Commit

Permalink
test: enable more tests for Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
mjzffr committed Jun 11, 2020
1 parent 4d93527 commit 42897bc
Show file tree
Hide file tree
Showing 17 changed files with 303 additions and 364 deletions.
33 changes: 15 additions & 18 deletions test/browsercontext.spec.js
Expand Up @@ -20,7 +20,7 @@ const utils = require('./utils');

describe('BrowserContext', function () {
setupTestBrowserHooks();
itFailsFirefox('should have default context', async () => {
it('should have default context', async () => {
const { browser } = getTestState();
expect(browser.browserContexts().length).toEqual(1);
const defaultContext = browser.browserContexts()[0];
Expand All @@ -30,7 +30,7 @@ describe('BrowserContext', function () {
expect(browser.defaultBrowserContext()).toBe(defaultContext);
expect(error.message).toContain('cannot be closed');
});
itFailsFirefox('should create new incognito context', async () => {
it('should create new incognito context', async () => {
const { browser } = getTestState();

expect(browser.browserContexts().length).toBe(1);
Expand All @@ -41,22 +41,19 @@ describe('BrowserContext', function () {
await context.close();
expect(browser.browserContexts().length).toBe(1);
});
itFailsFirefox(
'should close all belonging targets once closing context',
async () => {
const { browser } = getTestState();

expect((await browser.pages()).length).toBe(1);

const context = await browser.createIncognitoBrowserContext();
await context.newPage();
expect((await browser.pages()).length).toBe(2);
expect((await context.pages()).length).toBe(1);

await context.close();
expect((await browser.pages()).length).toBe(1);
}
);
it('should close all belonging targets once closing context', async () => {
const { browser } = getTestState();

expect((await browser.pages()).length).toBe(1);

const context = await browser.createIncognitoBrowserContext();
await context.newPage();
expect((await browser.pages()).length).toBe(2);
expect((await context.pages()).length).toBe(1);

await context.close();
expect((await browser.pages()).length).toBe(1);
});
itFailsFirefox('window.open should use parent tab context', async () => {
const { browser, server } = getTestState();

Expand Down
36 changes: 15 additions & 21 deletions test/click.spec.js
Expand Up @@ -32,7 +32,7 @@ describe('Page.click', function () {
await page.click('button');
expect(await page.evaluate(() => result)).toBe('Clicked');
});
itFailsFirefox('should click svg', async () => {
it('should click svg', async () => {
const { page } = getTestState();

await page.setContent(`
Expand All @@ -55,23 +55,20 @@ describe('Page.click', function () {
}
);
// @see https://github.com/puppeteer/puppeteer/issues/4281
itFailsFirefox(
'should click on a span with an inline element inside',
async () => {
const { page } = getTestState();
it('should click on a span with an inline element inside', async () => {
const { page } = getTestState();

await page.setContent(`
await page.setContent(`
<style>
span::before {
content: 'q';
}
</style>
<span onclick='javascript:window.CLICKED=42'></span>
`);
await page.click('span');
expect(await page.evaluate(() => window.CLICKED)).toBe(42);
}
);
await page.click('span');
expect(await page.evaluate(() => window.CLICKED)).toBe(42);
});
it('should not throw UnhandledPromiseRejection when page closes', async () => {
const { page } = getTestState();

Expand All @@ -98,12 +95,10 @@ describe('Page.click', function () {
await Promise.all([page.click('a'), page.waitForNavigation()]);
expect(page.url()).toBe(server.PREFIX + '/wrappedlink.html#clicked');
});
itFailsFirefox(
'should click when one of inline box children is outside of viewport',
async () => {
const { page } = getTestState();
it('should click when one of inline box children is outside of viewport', async () => {
const { page } = getTestState();

await page.setContent(`
await page.setContent(`
<style>
i {
position: absolute;
Expand All @@ -112,10 +107,9 @@ describe('Page.click', function () {
</style>
<span onclick='javascript:window.CLICKED = 42;'><i>woof</i><b>doggo</b></span>
`);
await page.click('span');
expect(await page.evaluate(() => window.CLICKED)).toBe(42);
}
);
await page.click('span');
expect(await page.evaluate(() => window.CLICKED)).toBe(42);
});
it('should select the text by triple clicking', async () => {
const { page, server } = getTestState();

Expand Down Expand Up @@ -244,7 +238,7 @@ describe('Page.click', function () {
)
).toBe('clicked');
});
itFailsFirefox('should double click the button', async () => {
it('should double click the button', async () => {
const { page, server } = getTestState();

await page.goto(server.PREFIX + '/input/button.html');
Expand Down Expand Up @@ -290,7 +284,7 @@ describe('Page.click', function () {
).toBe('context menu');
});
// @see https://github.com/puppeteer/puppeteer/issues/206
itFailsFirefox('should click links which cause navigation', async () => {
it('should click links which cause navigation', async () => {
const { page, server } = getTestState();

await page.setContent(`<a href="${server.EMPTY_PAGE}">empty.html</a>`);
Expand Down
52 changes: 23 additions & 29 deletions test/cookies.spec.js
Expand Up @@ -220,21 +220,18 @@ describe('Cookie specs', () => {
})
).toEqual(['foo=bar', 'password=123456']);
});
itFailsFirefox(
'should have |expires| set to |-1| for session cookies',
async () => {
const { page, server } = getTestState();
it('should have |expires| set to |-1| for session cookies', async () => {
const { page, server } = getTestState();

await page.goto(server.EMPTY_PAGE);
await page.setCookie({
name: 'password',
value: '123456',
});
const cookies = await page.cookies();
expect(cookies[0].session).toBe(true);
expect(cookies[0].expires).toBe(-1);
}
);
await page.goto(server.EMPTY_PAGE);
await page.setCookie({
name: 'password',
value: '123456',
});
const cookies = await page.cookies();
expect(cookies[0].session).toBe(true);
expect(cookies[0].expires).toBe(-1);
});
itFailsFirefox('should set cookie with reasonable defaults', async () => {
const { page, server } = getTestState();

Expand Down Expand Up @@ -348,22 +345,19 @@ describe('Cookie specs', () => {
expect(cookie.secure).toBe(true);
}
);
itFailsFirefox(
'should be able to set unsecure cookie for HTTP website',
async () => {
const { page, server } = getTestState();
it('should be able to set unsecure cookie for HTTP website', async () => {
const { page, server } = getTestState();

await page.goto(server.EMPTY_PAGE);
const HTTP_URL = 'http://example.com';
await page.setCookie({
url: HTTP_URL,
name: 'foo',
value: 'bar',
});
const [cookie] = await page.cookies(HTTP_URL);
expect(cookie.secure).toBe(false);
}
);
await page.goto(server.EMPTY_PAGE);
const HTTP_URL = 'http://example.com';
await page.setCookie({
url: HTTP_URL,
name: 'foo',
value: 'bar',
});
const [cookie] = await page.cookies(HTTP_URL);
expect(cookie.secure).toBe(false);
});
itFailsFirefox('should set a cookie on a different domain', async () => {
const { page, server } = getTestState();

Expand Down
2 changes: 1 addition & 1 deletion test/elementhandle.spec.js
Expand Up @@ -233,7 +233,7 @@ describe('ElementHandle specs', function () {
'Node is either not visible or not an HTMLElement'
);
});
itFailsFirefox('should throw for <br> elements', async () => {
it('should throw for <br> elements', async () => {
const { page } = getTestState();

await page.setContent('hello<br>goodbye');
Expand Down
2 changes: 1 addition & 1 deletion test/emulation.spec.js
Expand Up @@ -127,7 +127,7 @@ describe('Emulation', () => {
'iPhone'
);
});
it('should support clicking', async () => {
itFailsFirefox('should support clicking', async () => {
const { page, server } = getTestState();

await page.emulate(iPhone);
Expand Down
66 changes: 30 additions & 36 deletions test/evaluation.spec.js
Expand Up @@ -35,31 +35,31 @@ describe('Evaluation specs', function () {
const result = await page.evaluate(() => 7 * 3);
expect(result).toBe(21);
});
(bigint ? itFailsFirefox : xit)('should transfer BigInt', async () => {
(bigint ? it : xit)('should transfer BigInt', async () => {
const { page } = getTestState();

const result = await page.evaluate((a) => a, BigInt(42));
expect(result).toBe(BigInt(42));
});
itFailsFirefox('should transfer NaN', async () => {
it('should transfer NaN', async () => {
const { page } = getTestState();

const result = await page.evaluate((a) => a, NaN);
expect(Object.is(result, NaN)).toBe(true);
});
itFailsFirefox('should transfer -0', async () => {
it('should transfer -0', async () => {
const { page } = getTestState();

const result = await page.evaluate((a) => a, -0);
expect(Object.is(result, -0)).toBe(true);
});
itFailsFirefox('should transfer Infinity', async () => {
it('should transfer Infinity', async () => {
const { page } = getTestState();

const result = await page.evaluate((a) => a, Infinity);
expect(Object.is(result, Infinity)).toBe(true);
});
itFailsFirefox('should transfer -Infinity', async () => {
it('should transfer -Infinity', async () => {
const { page } = getTestState();

const result = await page.evaluate((a) => a, -Infinity);
Expand Down Expand Up @@ -202,31 +202,31 @@ describe('Evaluation specs', function () {
expect(result).not.toBe(object);
expect(result).toEqual(object);
});
(bigint ? itFailsFirefox : xit)('should return BigInt', async () => {
(bigint ? it : xit)('should return BigInt', async () => {
const { page } = getTestState();

const result = await page.evaluate(() => BigInt(42));
expect(result).toBe(BigInt(42));
});
itFailsFirefox('should return NaN', async () => {
it('should return NaN', async () => {
const { page } = getTestState();

const result = await page.evaluate(() => NaN);
expect(Object.is(result, NaN)).toBe(true);
});
itFailsFirefox('should return -0', async () => {
it('should return -0', async () => {
const { page } = getTestState();

const result = await page.evaluate(() => -0);
expect(Object.is(result, -0)).toBe(true);
});
itFailsFirefox('should return Infinity', async () => {
it('should return Infinity', async () => {
const { page } = getTestState();

const result = await page.evaluate(() => Infinity);
expect(Object.is(result, Infinity)).toBe(true);
});
itFailsFirefox('should return -Infinity', async () => {
it('should return -Infinity', async () => {
const { page } = getTestState();

const result = await page.evaluate(() => -Infinity);
Expand Down Expand Up @@ -298,30 +298,27 @@ describe('Evaluation specs', function () {
const result = await page.evaluate('2 + 5;\n// do some math!');
expect(result).toBe(7);
});
itFailsFirefox('should accept element handle as an argument', async () => {
it('should accept element handle as an argument', async () => {
const { page } = getTestState();

await page.setContent('<section>42</section>');
const element = await page.$('section');
const text = await page.evaluate((e) => e.textContent, element);
expect(text).toBe('42');
});
itFailsFirefox(
'should throw if underlying element was disposed',
async () => {
const { page } = getTestState();
it('should throw if underlying element was disposed', async () => {
const { page } = getTestState();

await page.setContent('<section>39</section>');
const element = await page.$('section');
expect(element).toBeTruthy();
await element.dispose();
let error = null;
await page
.evaluate((e) => e.textContent, element)
.catch((error_) => (error = error_));
expect(error.message).toContain('JSHandle is disposed');
}
);
await page.setContent('<section>39</section>');
const element = await page.$('section');
expect(element).toBeTruthy();
await element.dispose();
let error = null;
await page
.evaluate((e) => e.textContent, element)
.catch((error_) => (error = error_));
expect(error.message).toContain('JSHandle is disposed');
});
itFailsFirefox(
'should throw if elementHandles are from other frames',
async () => {
Expand Down Expand Up @@ -376,17 +373,14 @@ describe('Evaluation specs', function () {
expect(result).toEqual([42]);
}
);
itFailsFirefox(
'should transfer 100Mb of data from page to node.js',
async function () {
const { page } = getTestState();
it('should transfer 100Mb of data from page to node.js', async function () {
const { page } = getTestState();

const a = await page.evaluate(() =>
Array(100 * 1024 * 1024 + 1).join('a')
);
expect(a.length).toBe(100 * 1024 * 1024);
}
);
const a = await page.evaluate(() =>
Array(100 * 1024 * 1024 + 1).join('a')
);
expect(a.length).toBe(100 * 1024 * 1024);
});
it('should throw error with detailed information on exception inside promise ', async () => {
const { page } = getTestState();

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures.spec.js
Expand Up @@ -20,7 +20,7 @@ const { getTestState } = require('./mocha-utils');
const path = require('path');

describe('Fixtures', function () {
itFailsFirefox('dumpio option should work with pipe option ', async () => {
itChromeOnly('dumpio option should work with pipe option ', async () => {
const { defaultBrowserOptions, puppeteerPath } = getTestState();

let dumpioData = '';
Expand Down

0 comments on commit 42897bc

Please sign in to comment.