* Execute the given script following the Execute-Script specification laid out
* in the W3C WebDriver spec, except for serialization/deserialization of args,
* which is handled by callFunction.
*
* @param {string} script The script to be executed.
* @param {!Array<*>} args Arguments to be passed to the script.
*/
function executeScript(script, args) {
try {
const f = (new Function('return async function(){' + script + '}'))();
const Promise = window.cdc_adoQpoasnfa76pfcZLmcfl_Promise || window.Promise;
return Promise.resolve(f.apply(null, args));
} catch (e) {
return Promise.reject(e);
}
}