feat(console): dispatch JSHandles as console arguments (#975)

This patch starts dispatching JSHandle instances as console arguments.

BREAKING CHANGE: this changes the API of the ConsoleMessage.

Fixes #324.
This commit is contained in:
Andrey Lushnikov
2017-10-09 17:01:01 -07:00
committed by GitHub
parent 8d1d9fec65
commit e6af6e19d6
4 changed files with 8 additions and 31 deletions

View File

@@ -83,31 +83,6 @@ class Helper {
return remoteObject.value;
}
/**
* @param {!Session} client
* @param {!Object} remoteObject
* @return {!Promise<!Object>}
*/
static async serializeRemoteObject(client, remoteObject) {
if (!remoteObject.objectId)
return Helper.valueFromRemoteObject(remoteObject);
if (remoteObject.subtype === 'promise')
return remoteObject.description;
try {
const response = await client.send('Runtime.callFunctionOn', {
objectId: remoteObject.objectId,
functionDeclaration: 'function() { return this; }',
returnByValue: true,
});
return response.result.value;
} catch (e) {
// Return description for unserializable object, e.g. 'window'.
return remoteObject.description;
} finally {
Helper.releaseObject(client, remoteObject);
}
}
/**
* @param {!Session} client
* @param {!Object} remoteObject