mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(Console): Introduce ConsoleMessage type (#909)
This patch introduces ConsoleMessage type and starts dispatching it for the 'console' event. BREAKING CHANGE: this breaks the api of the 'console' event. Fixes #744.
This commit is contained in:
17
lib/Page.js
17
lib/Page.js
@@ -313,7 +313,9 @@ class Page extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
const values = await Promise.all(event.args.map(arg => helper.serializeRemoteObject(this._client, arg)));
|
||||
this.emit(Page.Events.Console, ...values);
|
||||
const text = values.join(' ');
|
||||
const message = new ConsoleMessage(event.type, text, values);
|
||||
this.emit(Page.Events.Console, message);
|
||||
}
|
||||
|
||||
_onDialog(event) {
|
||||
@@ -875,6 +877,19 @@ Page.Viewport;
|
||||
* @property {("Strict"|"Lax")=} sameSite
|
||||
*/
|
||||
|
||||
class ConsoleMessage {
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {string} text
|
||||
* @param {!Array<*>} args
|
||||
*/
|
||||
constructor(type, text, args) {
|
||||
this.type = type;
|
||||
this.text = text;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = Page;
|
||||
helper.tracePublicAPI(Page);
|
||||
|
||||
Reference in New Issue
Block a user