test(firefox): enable more tests on Puppeteer-Firefox (#3937)

References #3889
This commit is contained in:
Andrey Lushnikov 2019-02-07 07:15:19 -08:00 committed by GitHub
parent 96792793ea
commit 49e8704ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 21 deletions

View File

@ -136,7 +136,7 @@ module.exports.addTests = function({testRunner, expect, FFOX}) {
'Keyup: ~ Backquote 192 [Shift]'].join('\n'));
await keyboard.up('Shift');
});
it_fails_ffox('should not type canceled events', async({page, server}) => {
it('should not type canceled events', async({page, server}) => {
await page.goto(server.PREFIX + '/input/textarea.html');
await page.focus('textarea');
await page.evaluate(() => {
@ -146,7 +146,7 @@ module.exports.addTests = function({testRunner, expect, FFOX}) {
if (event.key === 'l')
event.preventDefault();
if (event.key === 'o')
Promise.resolve().then(() => event.preventDefault());
event.preventDefault();
}, false);
});
await page.keyboard.type('Hello World!');

View File

@ -54,7 +54,7 @@ module.exports.addTests = function({testRunner, expect, FFOX}) {
expect(event.isTrusted).toBe(true);
expect(event.button).toBe(0);
});
it_fails_ffox('should resize the textarea', async({page, server}) => {
it('should resize the textarea', async({page, server}) => {
await page.goto(server.PREFIX + '/input/textarea.html');
const {x, y, width, height} = await page.evaluate(dimensions);
const mouse = page.mouse;
@ -63,21 +63,26 @@ module.exports.addTests = function({testRunner, expect, FFOX}) {
await mouse.move(x + width + 100, y + height + 100);
await mouse.up();
const newDimensions = await page.evaluate(dimensions);
expect(newDimensions.width).toBe(width + 104);
expect(newDimensions.height).toBe(height + 104);
expect(newDimensions.width).toBe(Math.round(width + 104));
expect(newDimensions.height).toBe(Math.round(height + 104));
});
it_fails_ffox('should select the text with mouse', async({page, server}) => {
it('should select the text with mouse', async({page, server}) => {
await page.goto(server.PREFIX + '/input/textarea.html');
await page.focus('textarea');
const text = 'This is the text that we are going to try to select. Let\'s see how it goes.';
await page.keyboard.type(text);
// Firefox needs an extra frame here after typing or it will fail to set the scrollTop
await page.evaluate(() => new Promise(requestAnimationFrame));
await page.evaluate(() => document.querySelector('textarea').scrollTop = 0);
const {x, y} = await page.evaluate(dimensions);
await page.mouse.move(x + 2,y + 2);
await page.mouse.down();
await page.mouse.move(100,100);
await page.mouse.up();
expect(await page.evaluate(() => window.getSelection().toString())).toBe(text);
expect(await page.evaluate(() => {
const textarea = document.querySelector('textarea');
return textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
})).toBe(text);
});
it('should trigger hover state', async({page, server}) => {
await page.goto(server.PREFIX + '/input/scrollable.html');

View File

@ -16,7 +16,7 @@
const utils = require('./utils');
module.exports.addTests = function({testRunner, expect, Errors}) {
module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, it_fails_ffox} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
@ -48,7 +48,7 @@ module.exports.addTests = function({testRunner, expect, Errors}) {
});
await page.goto(server.PREFIX + '/frames/one-frame.html');
});
it_fails_ffox('should fail when server returns 204', async({page, server}) => {
it('should fail when server returns 204', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.statusCode = 204;
res.end();
@ -56,7 +56,11 @@ module.exports.addTests = function({testRunner, expect, Errors}) {
let error = null;
await page.goto(server.EMPTY_PAGE).catch(e => error = e);
expect(error).not.toBe(null);
expect(error.message).toContain('net::ERR_ABORTED');
console.log(error.message);
if (CHROME)
expect(error.message).toContain('net::ERR_ABORTED');
else
expect(error.message).toContain('NS_BINDING_ABORTED');
});
it_fails_ffox('should navigate to empty page with domcontentloaded', async({page, server}) => {
const response = await page.goto(server.EMPTY_PAGE, {waitUntil: 'domcontentloaded'});
@ -79,10 +83,13 @@ module.exports.addTests = function({testRunner, expect, Errors}) {
const response = await page.goto(server.EMPTY_PAGE, {waitUntil: 'networkidle2'});
expect(response.status()).toBe(200);
});
it_fails_ffox('should fail when navigating to bad url', async({page, server}) => {
it('should fail when navigating to bad url', async({page, server}) => {
let error = null;
await page.goto('asdfasdf').catch(e => error = e);
expect(error.message).toContain('Cannot navigate to invalid URL');
if (CHROME)
expect(error.message).toContain('Cannot navigate to invalid URL');
else
expect(error.message).toContain('Invalid url');
});
it_fails_ffox('should fail when navigating to bad SSL', async({page, httpsServer}) => {
// Make sure that network events do not emit 'undefined'.
@ -94,22 +101,28 @@ module.exports.addTests = function({testRunner, expect, Errors}) {
await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);
expect(error.message).toContain('net::ERR_CERT_AUTHORITY_INVALID');
});
it_fails_ffox('should fail when navigating to bad SSL after redirects', async({page, server, httpsServer}) => {
it('should fail when navigating to bad SSL after redirects', async({page, server, httpsServer}) => {
server.setRedirect('/redirect/1.html', '/redirect/2.html');
server.setRedirect('/redirect/2.html', '/empty.html');
let error = null;
await page.goto(httpsServer.PREFIX + '/redirect/1.html').catch(e => error = e);
expect(error.message).toContain('net::ERR_CERT_AUTHORITY_INVALID');
if (CHROME)
expect(error.message).toContain('net::ERR_CERT_AUTHORITY_INVALID');
else
expect(error.message).toContain('SSL_ERROR_UNKNOWN');
});
it_fails_ffox('should throw if networkidle is passed as an option', async({page, server}) => {
let error = null;
await page.goto(server.EMPTY_PAGE, {waitUntil: 'networkidle'}).catch(err => error = err);
expect(error.message).toContain('"networkidle" option is no longer supported');
});
it_fails_ffox('should fail when main resources failed to load', async({page, server}) => {
it('should fail when main resources failed to load', async({page, server}) => {
let error = null;
await page.goto('http://localhost:44123/non-existing-url').catch(e => error = e);
expect(error.message).toContain('net::ERR_CONNECTION_REFUSED');
if (CHROME)
expect(error.message).toContain('net::ERR_CONNECTION_REFUSED');
else
expect(error.message).toContain('NS_ERROR_CONNECTION_REFUSED');
});
it('should fail when exceeding maximum navigation timeout', async({page, server}) => {
// Hang for request to the empty.html

View File

@ -50,12 +50,12 @@ module.exports.addTests = function({testRunner, expect, puppeteer, Errors}) {
expect(await originalPage.evaluate(() => ['Hello', 'world'].join(' '))).toBe('Hello world');
expect(await originalPage.$('body')).toBeTruthy();
});
it_fails_ffox('should report when a new page is created and closed', async({page, server, context}) => {
const otherPagePromise = new Promise(fulfill => context.once('targetcreated', target => fulfill(target.page())));
await page.evaluate(url => window.open(url), server.CROSS_PROCESS_PREFIX);
const otherPage = await otherPagePromise;
it('should report when a new page is created and closed', async({page, server, context}) => {
const [otherPage] = await Promise.all([
context.waitForTarget(target => target.url() === server.CROSS_PROCESS_PREFIX + '/empty.html').then(target => target.page()),
page.evaluate(url => window.open(url), server.CROSS_PROCESS_PREFIX + '/empty.html'),
]);
expect(otherPage.url()).toContain(server.CROSS_PROCESS_PREFIX);
expect(await otherPage.evaluate(() => ['Hello', 'world'].join(' '))).toBe('Hello world');
expect(await otherPage.$('body')).toBeTruthy();