修复执行uToolsapi时Unable to deserialize cloned 的报错

This commit is contained in:
fofolee 2020-06-30 21:17:40 +08:00
parent e6df0d579f
commit 777ea261c6

View File

@ -616,7 +616,15 @@ Contextify.function = (fnc, traps, deepTraps, flags, mock) => {
// Set context of all arguments to host's context.
args = Decontextify.arguments(args);
try {
try {
// fix 'Unable to deserialize cloned data due to invalid or unsupported version' error of utools api
if (typeof context == 'object') {
var keys = Object.keys(context)
if (keys.includes('ubrowser') || keys.includes('goto')) {
args = args.map(a => (typeof a == 'object') && JSON.parse(JSON.stringify(a)) || a)
}
}
// end of fix
return Contextify.value(fnc.apply(context, args));
} catch (e) {
throw Contextify.value(e);