mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test(firefox): further unify Puppeteer-Firefox and Puppeteer tests (#3894)
This patch: - changes Puppeteer-Firefox plumbing of defaultBrowserOptions to align with the way we do it for Puppeteer. - plumbs puppeeteer-dependent Errors and DeviceDescriptors down to every test. - unifies a few tests between Puppeteer-Firefox and Puppeteer. **Note:** in future, we should expose errors as `puppeteer.errors` and device descriptors as `puppeteer.devices` to make it easy to pass around Puppeteer/Puppeteer-Firefox instance. References #3889.
This commit is contained in:
@@ -15,14 +15,24 @@
|
||||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {TimeoutError} = utils.requireRoot('Errors');
|
||||
|
||||
module.exports.addTests = function({testRunner, expect}) {
|
||||
module.exports.addTests = function({testRunner, expect, Errors}) {
|
||||
const {describe, xdescribe, fdescribe} = testRunner;
|
||||
const {it, fit, xit} = testRunner;
|
||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||
const {TimeoutError} = Errors;
|
||||
|
||||
describe('Page.goto', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(page.url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
it('should work with redirects', async({page, server}) => {
|
||||
server.setRedirect('/redirect/1.html', '/redirect/2.html');
|
||||
server.setRedirect('/redirect/2.html', '/empty.html');
|
||||
await page.goto(server.PREFIX + '/redirect/1.html');
|
||||
expect(page.url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
it('should navigate to about:blank', async({page, server}) => {
|
||||
const response = await page.goto('about:blank');
|
||||
expect(response).toBe(null);
|
||||
@@ -523,4 +533,13 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
await navigationPromise;
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.reload', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.evaluate(() => window._foo = 10);
|
||||
await page.reload();
|
||||
expect(await page.evaluate(() => window._foo)).toBe(undefined);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user