mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Rename Page.Events.ConsoleMessageAdded -> Page.Events.ConsoleMessage
This patch: - renames ConsoleMessageAdded into ConsoleMessage for the sake of clarity - adds a test to cover basic functionality
This commit is contained in:
parent
2b0d0e6551
commit
8a8076c15b
@ -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('Page.Events.ConsoleMessageAdded', console.log);
|
||||
page.on('Page.Events.ConsoleMessage', console.log);
|
||||
await page.evaluate(detectFeatures);
|
||||
browser.close();
|
||||
});
|
||||
|
@ -204,7 +204,7 @@ class Page extends EventEmitter {
|
||||
|
||||
_onConsoleAPI(event) {
|
||||
var values = event.args.map(arg => arg.value || arg.description || '');
|
||||
this.emit(Page.Events.ConsoleMessageAdded, values.join(' '));
|
||||
this.emit(Page.Events.ConsoleMessage, values.join(' '));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -416,7 +416,7 @@ Page.ScreenshotTypes = {
|
||||
};
|
||||
|
||||
Page.Events = {
|
||||
ConsoleMessageAdded: 'Page.Events.ConsoleMessageAdded',
|
||||
ConsoleMessage: 'Page.Events.ConsoleMessage',
|
||||
DialogOpened: 'Page.Events.DialogOpened',
|
||||
ExceptionThrown: 'Page.Events.ExceptionThrown',
|
||||
ResourceLoadingFailed: 'Page.Events.ResourceLoadingFailed',
|
||||
|
@ -63,7 +63,7 @@ class WebPage {
|
||||
this._pageEvents = new AsyncEmitter(this._page);
|
||||
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.ConsoleMessageAdded, msg => (this.onConsoleMessage || noop).call(null, msg));
|
||||
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));
|
||||
}
|
||||
|
@ -33,6 +33,13 @@ describe('Puppeteer', function() {
|
||||
expect(result).toBe(56);
|
||||
}));
|
||||
|
||||
it('Page.Events.ConsoleMessage', SX(async function() {
|
||||
var msgs = [];
|
||||
page.on('Page.Events.ConsoleMessage', msg => msgs.push(msg));
|
||||
await page.evaluate(() => console.log('Message!'));
|
||||
expect(msgs).toEqual(['Message!']);
|
||||
}));
|
||||
|
||||
describe('Page.setInPageCallback', function() {
|
||||
it('should work', SX(async function() {
|
||||
await page.setInPageCallback('callController', function(a, b) {
|
||||
|
Loading…
Reference in New Issue
Block a user