mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Return remote object description for unserializable objects
This patch starts handling unserializable objects by returning their description. Fixes #86.
This commit is contained in:
@@ -75,13 +75,21 @@ class Helper {
|
||||
}
|
||||
if (!remoteObject.objectId)
|
||||
return remoteObject.value;
|
||||
let response = await client.send('Runtime.callFunctionOn', {
|
||||
objectId: remoteObject.objectId,
|
||||
functionDeclaration: 'function() { return this; }',
|
||||
returnByValue: true,
|
||||
});
|
||||
client.send('Runtime.releaseObject', {objectId: remoteObject.objectId});
|
||||
return response.result.value;
|
||||
try {
|
||||
let 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 {
|
||||
client.send('Runtime.releaseObject', {objectId: remoteObject.objectId}).catch(e => {
|
||||
// While we were serializing object, the page might've navigated.
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user