Commit 1b9eb692 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Fix Execute Script for salesforce.com

Some web sites (e.g., salesforce.com) modifies the prototype of
AsyncFunction object, causing errors in Execute Script endpoint.
The CL works around this issue by avoid directly using AsyncFunction
object.

Bug: chromedriver:3103
Change-Id: If328aab279bd818f5766381cc537d9612674599c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1785738Reviewed-by: default avatarRohan Pavone <rohpavone@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693851}
parent db4fbec4
......@@ -11,9 +11,10 @@
* @param {!Array<*>} args Arguments to be passed to the script.
*/
function executeScript(script, args) {
const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
try {
return Promise.resolve(new AsyncFunction(script).apply(null, args));
// Convert script (as a string) into an async function.
const f = (new Function('return async function(){' + script + '}'))();
return Promise.resolve(f.apply(null, args));
} catch (e) {
return Promise.reject(e);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment