diff --git a/examples/features.js b/examples/features.js index 6838e8ed..7e4d277a 100644 --- a/examples/features.js +++ b/examples/features.js @@ -21,7 +21,7 @@ var browser = new Browser(); browser.newPage().then(async page => { var modernizrPath = path.join('..', 'third_party', 'phantomjs', 'examples', 'modernizr.js'); await page.injectFile(modernizrPath); - page.on('ConsoleMessage', console.log); + page.on('consolemessage', console.log); await page.evaluate(detectFeatures); browser.close(); }); diff --git a/examples/pagecallback.js b/examples/pagecallback.js index f7eb0b9b..2ffdb06a 100644 --- a/examples/pagecallback.js +++ b/examples/pagecallback.js @@ -18,7 +18,7 @@ var Browser = require('../lib/Browser'); var browser = new Browser(); browser.newPage().then(async page => { - page.on('ConsoleMessage', console.log); + page.on('consolemessage', console.log); await page.setInPageCallback('callPhantom', msg => { console.log("Received by the 'phantom' main context: "+msg); return "Hello there, I'm coming to you from the 'phantom' context instead"; diff --git a/lib/Page.js b/lib/Page.js index 581338b4..45497e80 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -60,7 +60,7 @@ class Page extends EventEmitter { client.on('Network.responseReceived', event => this.emit(Page.Events.ResponseReceived, event.response)); client.on('Network.loadingFailed', event => this.emit(Page.Events.ResourceLoadingFailed, event)); client.on('Runtime.consoleAPICalled', event => this._onConsoleAPI(event)); - client.on('Page.javascriptDialogOpening', dialog => this.emit(Page.Events.DialogOpened, dialog)); + client.on('Page.javascriptDialogOpening', dialog => this.emit(Page.Events.Dialog, dialog)); client.on('Runtime.exceptionThrown', exception => this._handleException(exception.exceptionDetails)); } @@ -199,7 +199,7 @@ class Page extends EventEmitter { stack = exceptionDetails.stackTrace.callFrames.map(cf => cf.url); } var stackTrace = exceptionDetails.stackTrace; - this.emit(Page.Events.ExceptionThrown, exceptionDetails.exception.description, stack); + this.emit(Page.Events.Exception, exceptionDetails.exception.description, stack); } _onConsoleAPI(event) { @@ -416,11 +416,11 @@ Page.ScreenshotTypes = { }; Page.Events = { - ConsoleMessage: 'ConsoleMessage', - DialogOpened: 'DialogOpened', - ExceptionThrown: 'ExceptionThrown', - ResourceLoadingFailed: 'ResourceLoadingFailed', - ResponseReceived: 'ResponseReceived', + ConsoleMessage: 'consolemessage', + Dialog: 'dialog', + Exception: 'exception', + ResourceLoadingFailed: 'resourceloadingfailed', + ResponseReceived: 'responsereceived', }; module.exports = Page; diff --git a/phantomjs/WebPage.js b/phantomjs/WebPage.js index e968d753..e4d7af40 100644 --- a/phantomjs/WebPage.js +++ b/phantomjs/WebPage.js @@ -64,8 +64,8 @@ class WebPage { this._pageEvents.on(PageEvents.ResponseReceived, response => this._onResponseReceived(response)); this._pageEvents.on(PageEvents.ResourceLoadingFailed, event => (this.onResourceError || noop).call(null, event)); this._pageEvents.on(PageEvents.ConsoleMessage, msg => (this.onConsoleMessage || noop).call(null, msg)); - this._pageEvents.on(PageEvents.DialogOpened, dialog => this._onDialog(dialog)); - this._pageEvents.on(PageEvents.ExceptionThrown, (exception, stack) => (this._onError || noop).call(null, exception, stack)); + this._pageEvents.on(PageEvents.Dialog, dialog => this._onDialog(dialog)); + this._pageEvents.on(PageEvents.Exception, (exception, stack) => (this._onError || noop).call(null, exception, stack)); } _onResponseReceived(response) { diff --git a/test/test.js b/test/test.js index 7031c738..ef4cbf8d 100644 --- a/test/test.js +++ b/test/test.js @@ -35,7 +35,7 @@ describe('Puppeteer', function() { it('Page Events: ConsoleMessage', SX(async function() { var msgs = []; - page.on('ConsoleMessage', msg => msgs.push(msg)); + page.on('consolemessage', msg => msgs.push(msg)); await page.evaluate(() => console.log('Message!')); expect(msgs).toEqual(['Message!']); }));