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:
Andrey Lushnikov
2017-09-29 11:27:22 -07:00
committed by GitHub
parent cfece3451d
commit f6255029bd
5 changed files with 59 additions and 18 deletions

View File

@@ -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);