mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
parent
8a8076c15b
commit
15b36b1cf0
@ -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();
|
||||
});
|
||||
|
10
lib/Page.js
10
lib/Page.js
@ -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;
|
||||
|
@ -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!']);
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user