Fail navigation when main resource fails to load

This patch fails navigation when the main resource fails to load.

Fixes #148.
This commit is contained in:
Andrey Lushnikov 2017-07-27 17:54:39 -07:00
parent f1a4598cc1
commit b9e3cce5fd
2 changed files with 13 additions and 1 deletions

View File

@ -260,7 +260,10 @@ class Page extends EventEmitter {
}
await result;
helper.removeEventListeners([listener]);
return responses.get(this.mainFrame().url());
let response = responses.get(this.mainFrame().url());
if (!response)
throw new Error('Failed to navigate: ' + url);
return response;
}
/**

View File

@ -461,6 +461,15 @@ describe('Puppeteer', function() {
}
expect(error.message).toContain('SSL Certificate error');
}));
it('should fail when main resources failed to load', SX(async function() {
let error = null;
try {
await page.navigate('chrome-devtools://devtools/bundled/inspector.html');
} catch (e) {
error = e;
}
expect(error.message).toContain('Failed to navigate');
}));
it('should fail when exceeding maximum navigation timeout', SX(async function() {
let error = null;
// Hang for request to the empty.html