Drop unneeded Page Event's prefixes.

This patch drops 'Page.Event.' prefix in every puppeteer's page
event. This makes it convenient to subscribe to events by their
string value.
This commit is contained in:
Andrey Lushnikov 2017-05-13 11:12:06 -07:00
parent 8a8076c15b
commit 15b36b1cf0
3 changed files with 8 additions and 8 deletions

View File

@ -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.ConsoleMessage', console.log);
page.on('ConsoleMessage', console.log);
await page.evaluate(detectFeatures);
browser.close();
});

View File

@ -416,11 +416,11 @@ Page.ScreenshotTypes = {
};
Page.Events = {
ConsoleMessage: 'Page.Events.ConsoleMessage',
DialogOpened: 'Page.Events.DialogOpened',
ExceptionThrown: 'Page.Events.ExceptionThrown',
ResourceLoadingFailed: 'Page.Events.ResourceLoadingFailed',
ResponseReceived: 'Page.Events.ResponseReceived',
ConsoleMessage: 'ConsoleMessage',
DialogOpened: 'DialogOpened',
ExceptionThrown: 'ExceptionThrown',
ResourceLoadingFailed: 'ResourceLoadingFailed',
ResponseReceived: 'ResponseReceived',
};
module.exports = Page;

View File

@ -33,9 +33,9 @@ describe('Puppeteer', function() {
expect(result).toBe(56);
}));
it('Page.Events.ConsoleMessage', SX(async function() {
it('Page Events: ConsoleMessage', SX(async function() {
var msgs = [];
page.on('Page.Events.ConsoleMessage', msg => msgs.push(msg));
page.on('ConsoleMessage', msg => msgs.push(msg));
await page.evaluate(() => console.log('Message!'));
expect(msgs).toEqual(['Message!']);
}));