mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(JSHandles): introduce JSHandles (#943)
This patch: - introduces ExecutionContext class that incapsulates javascript execution context. An examples of execution contexts are workers and frames - introduces JSHandle that holds a references to the javascript object in ExecutionContext - inherits ElementHandle from JSHandle Fixes #382.
This commit is contained in:
@@ -64,7 +64,8 @@ class Helper {
|
||||
* @param {!Object} remoteObject
|
||||
* @return {!Promise<!Object>}
|
||||
*/
|
||||
static async serializeRemoteObject(client, remoteObject) {
|
||||
static valueFromRemoteObject(remoteObject) {
|
||||
console.assert(!remoteObject.objectId, 'Cannot extract value when objectId is given');
|
||||
if (remoteObject.unserializableValue) {
|
||||
switch (remoteObject.unserializableValue) {
|
||||
case '-0':
|
||||
@@ -79,8 +80,17 @@ class Helper {
|
||||
throw new Error('Unsupported unserializable value: ' + remoteObject.unserializableValue);
|
||||
}
|
||||
}
|
||||
return remoteObject.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Session} client
|
||||
* @param {!Object} remoteObject
|
||||
* @return {!Promise<!Object>}
|
||||
*/
|
||||
static async serializeRemoteObject(client, remoteObject) {
|
||||
if (!remoteObject.objectId)
|
||||
return remoteObject.value;
|
||||
return Helper.valueFromRemoteObject(remoteObject);
|
||||
if (remoteObject.subtype === 'promise')
|
||||
return remoteObject.description;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user