mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(firefox): basic support for Network (#3988)
This patch introduces basic Request and Response events for page. It also teaches navigation methods, e.g. `page.goto` to return navigation response.
This commit is contained in:
@@ -33,11 +33,11 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
await page.goto(server.PREFIX + '/redirect/1.html');
|
||||
expect(page.url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
it_fails_ffox('should navigate to about:blank', async({page, server}) => {
|
||||
it('should navigate to about:blank', async({page, server}) => {
|
||||
const response = await page.goto('about:blank');
|
||||
expect(response).toBe(null);
|
||||
});
|
||||
it_fails_ffox('should return response when page changes its URL after load', async({page, server}) => {
|
||||
it('should return response when page changes its URL after load', async({page, server}) => {
|
||||
const response = await page.goto(server.PREFIX + '/historyapi.html');
|
||||
expect(response.status()).toBe(200);
|
||||
});
|
||||
@@ -66,7 +66,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.securityDetails()).toBe(null);
|
||||
});
|
||||
it_fails_ffox('should work when page calls history API in beforeunload', async({page, server}) => {
|
||||
it('should work when page calls history API in beforeunload', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.evaluate(() => {
|
||||
window.addEventListener('beforeunload', () => history.replaceState(null, 'initial', window.location.href), false);
|
||||
@@ -90,7 +90,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
else
|
||||
expect(error.message).toContain('Invalid url');
|
||||
});
|
||||
it_fails_ffox('should fail when navigating to bad SSL', async({page, httpsServer}) => {
|
||||
it('should fail when navigating to bad SSL', async({page, httpsServer}) => {
|
||||
// Make sure that network events do not emit 'undefined'.
|
||||
// @see https://crbug.com/750469
|
||||
page.on('request', request => expect(request).toBeTruthy());
|
||||
@@ -98,7 +98,10 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
page.on('requestfailed', request => expect(request).toBeTruthy());
|
||||
let error = null;
|
||||
await page.goto(httpsServer.EMPTY_PAGE).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('should fail when navigating to bad SSL after redirects', async({page, server, httpsServer}) => {
|
||||
server.setRedirect('/redirect/1.html', '/redirect/2.html');
|
||||
@@ -167,7 +170,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
expect(error).toBe(null);
|
||||
expect(loaded).toBe(true);
|
||||
});
|
||||
it_fails_ffox('should work when navigating to valid url', async({page, server}) => {
|
||||
it('should work when navigating to valid url', async({page, server}) => {
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response.ok()).toBe(true);
|
||||
});
|
||||
@@ -175,12 +178,12 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
const response = await page.goto('data:text/html,hello');
|
||||
expect(response.ok()).toBe(true);
|
||||
});
|
||||
it_fails_ffox('should work when navigating to 404', async({page, server}) => {
|
||||
it('should work when navigating to 404', async({page, server}) => {
|
||||
const response = await page.goto(server.PREFIX + '/not-found');
|
||||
expect(response.ok()).toBe(false);
|
||||
expect(response.status()).toBe(404);
|
||||
});
|
||||
it_fails_ffox('should return last response in redirect chain', async({page, server}) => {
|
||||
it('should return last response in redirect chain', async({page, server}) => {
|
||||
server.setRedirect('/redirect/1.html', '/redirect/2.html');
|
||||
server.setRedirect('/redirect/2.html', '/redirect/3.html');
|
||||
server.setRedirect('/redirect/3.html', server.EMPTY_PAGE);
|
||||
@@ -293,7 +296,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
expect(requests.length).toBe(1);
|
||||
expect(requests[0].url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
it_fails_ffox('should work with self requesting page', async({page, server}) => {
|
||||
it('should work with self requesting page', async({page, server}) => {
|
||||
const response = await page.goto(server.PREFIX + '/self-request.html');
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.url()).toContain('self-request.html');
|
||||
@@ -323,7 +326,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
});
|
||||
|
||||
describe('Page.waitForNavigation', function() {
|
||||
it_fails_ffox('should work', async({page, server}) => {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [response] = await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
@@ -352,7 +355,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
await bothFiredPromise;
|
||||
await navigationPromise;
|
||||
});
|
||||
it_fails_ffox('should work with clicking on anchor links', async({page, server}) => {
|
||||
it('should work with clicking on anchor links', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`<a href='#foobar'>foobar</a>`);
|
||||
const [response] = await Promise.all([
|
||||
@@ -362,7 +365,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
expect(response).toBe(null);
|
||||
expect(page.url()).toBe(server.EMPTY_PAGE + '#foobar');
|
||||
});
|
||||
it_fails_ffox('should work with history.pushState()', async({page, server}) => {
|
||||
it('should work with history.pushState()', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`
|
||||
<a onclick='javascript:pushState()'>SPA</a>
|
||||
@@ -377,7 +380,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
expect(response).toBe(null);
|
||||
expect(page.url()).toBe(server.PREFIX + '/wow.html');
|
||||
});
|
||||
it_fails_ffox('should work with history.replaceState()', async({page, server}) => {
|
||||
it('should work with history.replaceState()', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`
|
||||
<a onclick='javascript:replaceState()'>SPA</a>
|
||||
@@ -436,7 +439,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
|
||||
});
|
||||
|
||||
describe('Page.goBack', function() {
|
||||
it_fails_ffox('should work', async({page, server}) => {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user