mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
parent
f1a4598cc1
commit
b9e3cce5fd
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user