mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Rename Page.Events.Error into Page.Events.PageError
The 'error' event has a special treatment in Node: https://nodejs.org/api/events.html#events_error_events To avoid this, this patch renames the 'error' event into the 'pageerror'.
This commit is contained in:
parent
19e882f505
commit
64fed38c60
@ -201,7 +201,7 @@ class Page extends EventEmitter {
|
||||
*/
|
||||
async _handleException(exceptionDetails) {
|
||||
let message = await helper.getExceptionMessage(this._client, exceptionDetails);
|
||||
this.emit(Page.Events.Error, new Error(message));
|
||||
this.emit(Page.Events.PageError, new Error(message));
|
||||
}
|
||||
|
||||
async _onConsoleAPI(event) {
|
||||
@ -617,7 +617,9 @@ function convertPrintParameterToInches(parameter) {
|
||||
Page.Events = {
|
||||
ConsoleMessage: 'consolemessage',
|
||||
Dialog: 'dialog',
|
||||
Error: 'error',
|
||||
// Can'e use just 'error' due to node.js special treatment of error events.
|
||||
// @see https://nodejs.org/api/events.html#events_error_events
|
||||
PageError: 'pageerror',
|
||||
Request: 'request',
|
||||
Response: 'response',
|
||||
RequestFailed: 'requestfailed',
|
||||
|
@ -64,7 +64,7 @@ class WebPage {
|
||||
this._pageEvents.on(PageEvents.Confirm, message => this._onConfirm(message));
|
||||
this._pageEvents.on(PageEvents.Alert, message => this._onAlert(message));
|
||||
this._pageEvents.on(PageEvents.Dialog, dialog => this._onDialog(dialog));
|
||||
this._pageEvents.on(PageEvents.Error, error => (this._onError || noop).call(null, error.message, error.stack));
|
||||
this._pageEvents.on(PageEvents.PageError, error => (this._onError || noop).call(null, error.message, error.stack));
|
||||
}
|
||||
|
||||
get onInitialized() {
|
||||
|
@ -336,9 +336,9 @@ describe('Puppeteer', function() {
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Page.Events.Error', function() {
|
||||
describe('Page.Events.PageError', function() {
|
||||
it('should fire', function(done) {
|
||||
page.on('error', error => {
|
||||
page.on('pageerror', error => {
|
||||
expect(error.message).toContain('Fancy');
|
||||
done();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user