mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Roll chromium to r494365 (#271)
This patch: - rolls chromium to r494365 - starts using Runtime.evaluate(awaitPromise: true), with new semantic we can avoid additional Runtime.awaitPromise call - stops resolving promises for Console event
This commit is contained in:
parent
1e5d9fd8c0
commit
56eab00fa7
@ -51,7 +51,7 @@ class ElementHandle {
|
|||||||
stringifiedArgs.push(...args.map(x => JSON.stringify(x)));
|
stringifiedArgs.push(...args.map(x => JSON.stringify(x)));
|
||||||
let functionDeclaration = `function() { return (${pageFunction})(${stringifiedArgs.join(',')}) }`;
|
let functionDeclaration = `function() { return (${pageFunction})(${stringifiedArgs.join(',')}) }`;
|
||||||
const objectId = this._remoteObject.objectId;
|
const objectId = this._remoteObject.objectId;
|
||||||
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.callFunctionOn', { objectId, functionDeclaration, returnByValue: false});
|
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.callFunctionOn', { objectId, functionDeclaration, returnByValue: false, awaitPromise: true});
|
||||||
if (exceptionDetails)
|
if (exceptionDetails)
|
||||||
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
|
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
|
||||||
return await helper.serializeRemoteObject(this._client, remoteObject);
|
return await helper.serializeRemoteObject(this._client, remoteObject);
|
||||||
|
@ -196,7 +196,7 @@ class Frame {
|
|||||||
async _rawEvaluate(pageFunction, ...args) {
|
async _rawEvaluate(pageFunction, ...args) {
|
||||||
let expression = helper.evaluationString(pageFunction, ...args);
|
let expression = helper.evaluationString(pageFunction, ...args);
|
||||||
const contextId = this._defaultContextId;
|
const contextId = this._defaultContextId;
|
||||||
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.evaluate', { expression, contextId, returnByValue: false});
|
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.evaluate', { expression, contextId, returnByValue: false, awaitPromise: true});
|
||||||
if (exceptionDetails)
|
if (exceptionDetails)
|
||||||
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
|
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
|
||||||
return remoteObject;
|
return remoteObject;
|
||||||
|
@ -54,16 +54,6 @@ class Helper {
|
|||||||
* @return {!Promise<!Object>}
|
* @return {!Promise<!Object>}
|
||||||
*/
|
*/
|
||||||
static async serializeRemoteObject(client, remoteObject) {
|
static async serializeRemoteObject(client, remoteObject) {
|
||||||
if (remoteObject.subtype === 'promise') {
|
|
||||||
let response = (await client.send('Runtime.awaitPromise', {
|
|
||||||
promiseObjectId: remoteObject.objectId,
|
|
||||||
returnByValue: false
|
|
||||||
}));
|
|
||||||
Helper.releaseObject(client, remoteObject);
|
|
||||||
if (response.exceptionDetails)
|
|
||||||
throw new Error('Evaluation failed: ' + Helper.getExceptionMessage(response.exceptionDetails));
|
|
||||||
remoteObject = response.result;
|
|
||||||
}
|
|
||||||
if (remoteObject.unserializableValue) {
|
if (remoteObject.unserializableValue) {
|
||||||
switch (remoteObject.unserializableValue) {
|
switch (remoteObject.unserializableValue) {
|
||||||
case '-0':
|
case '-0':
|
||||||
@ -80,6 +70,8 @@ class Helper {
|
|||||||
}
|
}
|
||||||
if (!remoteObject.objectId)
|
if (!remoteObject.objectId)
|
||||||
return remoteObject.value;
|
return remoteObject.value;
|
||||||
|
if (remoteObject.subtype === 'promise')
|
||||||
|
return remoteObject.description;
|
||||||
try {
|
try {
|
||||||
let response = await client.send('Runtime.callFunctionOn', {
|
let response = await client.send('Runtime.callFunctionOn', {
|
||||||
objectId: remoteObject.objectId,
|
objectId: remoteObject.objectId,
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
"ws": "^3.0.0"
|
"ws": "^3.0.0"
|
||||||
},
|
},
|
||||||
"puppeteer": {
|
"puppeteer": {
|
||||||
"chromium_revision": "493985"
|
"chromium_revision": "494365"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"commonmark": "^0.27.0",
|
"commonmark": "^0.27.0",
|
||||||
|
@ -504,6 +504,7 @@ describe('Page', function() {
|
|||||||
console.dir('calling console.dir');
|
console.dir('calling console.dir');
|
||||||
console.warn('calling console.warn');
|
console.warn('calling console.warn');
|
||||||
console.error('calling console.error');
|
console.error('calling console.error');
|
||||||
|
console.log(Promise.resolve('should not wait until resolved!'));
|
||||||
}),
|
}),
|
||||||
// Wait for 5 events to hit.
|
// Wait for 5 events to hit.
|
||||||
waitForEvents(page, 'console', 5)
|
waitForEvents(page, 'console', 5)
|
||||||
@ -514,6 +515,7 @@ describe('Page', function() {
|
|||||||
'calling console.dir',
|
'calling console.dir',
|
||||||
'calling console.warn',
|
'calling console.warn',
|
||||||
'calling console.error',
|
'calling console.error',
|
||||||
|
'Promise',
|
||||||
]);
|
]);
|
||||||
}));
|
}));
|
||||||
it('should not fail for window object', SX(async function() {
|
it('should not fail for window object', SX(async function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user