mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: add test configuration options for running tests against multiple products (#5964)
* chore: remove "Extracting..." log message Fixes #5741. * test: support extra Launcher options and skips The extra Launcher options and skipping conditions enable unit tests to be run more easily by third-parties, e.g. browser vendors that are interested in Puppeteer support. Extra Launcher options were previously removed as part of switching away from the custom test harness. * test: enable more tests for Firefox
This commit is contained in:
committed by
Mathias Bynens
parent
5c91dfbf3f
commit
3d56a9e76f
@@ -57,15 +57,12 @@ describe('navigation', function () {
|
||||
const response = await page.goto('about:blank');
|
||||
expect(response).toBe(null);
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should return response when page changes its URL after load',
|
||||
async () => {
|
||||
const { page, server } = getTestState();
|
||||
it('should return response when page changes its URL after load', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
const response = await page.goto(server.PREFIX + '/historyapi.html');
|
||||
expect(response.status()).toBe(200);
|
||||
}
|
||||
);
|
||||
const response = await page.goto(server.PREFIX + '/historyapi.html');
|
||||
expect(response.status()).toBe(200);
|
||||
});
|
||||
it('should work with subframes return 204', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
@@ -88,34 +85,28 @@ describe('navigation', function () {
|
||||
if (isChrome) expect(error.message).toContain('net::ERR_ABORTED');
|
||||
else expect(error.message).toContain('NS_BINDING_ABORTED');
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should navigate to empty page with domcontentloaded',
|
||||
async () => {
|
||||
const { page, server } = getTestState();
|
||||
it('should navigate to empty page with domcontentloaded', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
const response = await page.goto(server.EMPTY_PAGE, {
|
||||
waitUntil: 'domcontentloaded',
|
||||
});
|
||||
expect(response.status()).toBe(200);
|
||||
}
|
||||
);
|
||||
itFailsFirefox(
|
||||
'should work when page calls history API in beforeunload',
|
||||
async () => {
|
||||
const { page, server } = getTestState();
|
||||
const response = await page.goto(server.EMPTY_PAGE, {
|
||||
waitUntil: 'domcontentloaded',
|
||||
});
|
||||
expect(response.status()).toBe(200);
|
||||
});
|
||||
it('should work when page calls history API in beforeunload', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.evaluate(() => {
|
||||
window.addEventListener(
|
||||
'beforeunload',
|
||||
() => history.replaceState(null, 'initial', window.location.href),
|
||||
false
|
||||
);
|
||||
});
|
||||
const response = await page.goto(server.PREFIX + '/grid.html');
|
||||
expect(response.status()).toBe(200);
|
||||
}
|
||||
);
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.evaluate(() => {
|
||||
window.addEventListener(
|
||||
'beforeunload',
|
||||
() => history.replaceState(null, 'initial', window.location.href),
|
||||
false
|
||||
);
|
||||
});
|
||||
const response = await page.goto(server.PREFIX + '/grid.html');
|
||||
expect(response.status()).toBe(200);
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should navigate to empty page with networkidle0',
|
||||
async () => {
|
||||
@@ -179,22 +170,18 @@ describe('navigation', function () {
|
||||
expect(requests[0]).toBe('request');
|
||||
expect(requests[1]).toBe('requestfailed');
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should fail when navigating to bad SSL after redirects',
|
||||
async () => {
|
||||
const { page, server, httpsServer, isChrome } = getTestState();
|
||||
it('should fail when navigating to bad SSL after redirects', async () => {
|
||||
const { page, server, httpsServer, isChrome } = getTestState();
|
||||
|
||||
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((error_) => (error = error_));
|
||||
if (isChrome)
|
||||
expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE);
|
||||
else expect(error.message).toContain('SSL_ERROR_UNKNOWN');
|
||||
}
|
||||
);
|
||||
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((error_) => (error = error_));
|
||||
if (isChrome) expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE);
|
||||
else expect(error.message).toContain('SSL_ERROR_UNKNOWN');
|
||||
});
|
||||
it('should throw if networkidle is passed as an option', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
@@ -206,20 +193,17 @@ describe('navigation', function () {
|
||||
'"networkidle" option is no longer supported'
|
||||
);
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should fail when main resources failed to load',
|
||||
async () => {
|
||||
const { page, isChrome } = getTestState();
|
||||
it('should fail when main resources failed to load', async () => {
|
||||
const { page, isChrome } = getTestState();
|
||||
|
||||
let error = null;
|
||||
await page
|
||||
.goto('http://localhost:44123/non-existing-url')
|
||||
.catch((error_) => (error = error_));
|
||||
if (isChrome)
|
||||
expect(error.message).toContain('net::ERR_CONNECTION_REFUSED');
|
||||
else expect(error.message).toContain('NS_ERROR_CONNECTION_REFUSED');
|
||||
}
|
||||
);
|
||||
let error = null;
|
||||
await page
|
||||
.goto('http://localhost:44123/non-existing-url')
|
||||
.catch((error_) => (error = error_));
|
||||
if (isChrome)
|
||||
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 () => {
|
||||
const { page, server, puppeteer } = getTestState();
|
||||
|
||||
@@ -284,7 +268,7 @@ describe('navigation', function () {
|
||||
expect(error).toBe(null);
|
||||
expect(loaded).toBe(true);
|
||||
});
|
||||
itFailsFirefox('should work when navigating to valid url', async () => {
|
||||
it('should work when navigating to valid url', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
@@ -296,26 +280,23 @@ describe('navigation', function () {
|
||||
const response = await page.goto('data:text/html,hello');
|
||||
expect(response.ok()).toBe(true);
|
||||
});
|
||||
itFailsFirefox('should work when navigating to 404', async () => {
|
||||
it('should work when navigating to 404', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
const response = await page.goto(server.PREFIX + '/not-found');
|
||||
expect(response.ok()).toBe(false);
|
||||
expect(response.status()).toBe(404);
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should return last response in redirect chain',
|
||||
async () => {
|
||||
const { page, server } = getTestState();
|
||||
it('should return last response in redirect chain', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
server.setRedirect('/redirect/1.html', '/redirect/2.html');
|
||||
server.setRedirect('/redirect/2.html', '/redirect/3.html');
|
||||
server.setRedirect('/redirect/3.html', server.EMPTY_PAGE);
|
||||
const response = await page.goto(server.PREFIX + '/redirect/1.html');
|
||||
expect(response.ok()).toBe(true);
|
||||
expect(response.url()).toBe(server.EMPTY_PAGE);
|
||||
}
|
||||
);
|
||||
server.setRedirect('/redirect/1.html', '/redirect/2.html');
|
||||
server.setRedirect('/redirect/2.html', '/redirect/3.html');
|
||||
server.setRedirect('/redirect/3.html', server.EMPTY_PAGE);
|
||||
const response = await page.goto(server.PREFIX + '/redirect/1.html');
|
||||
expect(response.ok()).toBe(true);
|
||||
expect(response.url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should wait for network idle to succeed navigation',
|
||||
async () => {
|
||||
@@ -401,22 +382,19 @@ describe('navigation', function () {
|
||||
process.removeListener('warning', warningHandler);
|
||||
expect(warning).toBe(null);
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should not leak listeners during bad navigation',
|
||||
async () => {
|
||||
const { page } = getTestState();
|
||||
it('should not leak listeners during bad navigation', async () => {
|
||||
const { page } = getTestState();
|
||||
|
||||
let warning = null;
|
||||
const warningHandler = (w) => (warning = w);
|
||||
process.on('warning', warningHandler);
|
||||
for (let i = 0; i < 20; ++i)
|
||||
await page.goto('asdf').catch((error) => {
|
||||
/* swallow navigation error */
|
||||
});
|
||||
process.removeListener('warning', warningHandler);
|
||||
expect(warning).toBe(null);
|
||||
}
|
||||
);
|
||||
let warning = null;
|
||||
const warningHandler = (w) => (warning = w);
|
||||
process.on('warning', warningHandler);
|
||||
for (let i = 0; i < 20; ++i)
|
||||
await page.goto('asdf').catch((error) => {
|
||||
/* swallow navigation error */
|
||||
});
|
||||
process.removeListener('warning', warningHandler);
|
||||
expect(warning).toBe(null);
|
||||
});
|
||||
it('should not leak listeners during navigation of 11 pages', async () => {
|
||||
const { context, server } = getTestState();
|
||||
|
||||
@@ -467,28 +445,25 @@ describe('navigation', function () {
|
||||
expect(requests[0].url()).toBe(server.EMPTY_PAGE);
|
||||
}
|
||||
);
|
||||
itFailsFirefox('should work with self requesting page', async () => {
|
||||
it('should work with self requesting page', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
const response = await page.goto(server.PREFIX + '/self-request.html');
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.url()).toContain('self-request.html');
|
||||
});
|
||||
itFailsFirefox(
|
||||
'should fail when navigating and show the url at the error message',
|
||||
async () => {
|
||||
const { page, httpsServer } = getTestState();
|
||||
it('should fail when navigating and show the url at the error message', async () => {
|
||||
const { page, httpsServer } = getTestState();
|
||||
|
||||
const url = httpsServer.PREFIX + '/redirect/1.html';
|
||||
let error = null;
|
||||
try {
|
||||
await page.goto(url);
|
||||
} catch (error_) {
|
||||
error = error_;
|
||||
}
|
||||
expect(error.message).toContain(url);
|
||||
const url = httpsServer.PREFIX + '/redirect/1.html';
|
||||
let error = null;
|
||||
try {
|
||||
await page.goto(url);
|
||||
} catch (error_) {
|
||||
error = error_;
|
||||
}
|
||||
);
|
||||
expect(error.message).toContain(url);
|
||||
});
|
||||
itFailsFirefox('should send referer', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
@@ -644,7 +619,7 @@ describe('navigation', function () {
|
||||
);
|
||||
});
|
||||
|
||||
describeFailsFirefox('Page.goBack', function () {
|
||||
describe('Page.goBack', function () {
|
||||
it('should work', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
@@ -662,7 +637,7 @@ describe('navigation', function () {
|
||||
response = await page.goForward();
|
||||
expect(response).toBe(null);
|
||||
});
|
||||
it('should work with HistoryAPI', async () => {
|
||||
itFailsFirefox('should work with HistoryAPI', async () => {
|
||||
const { page, server } = getTestState();
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
||||
Reference in New Issue
Block a user