mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
add logEvents action for tests
This commit is contained in:
@ -4928,6 +4928,23 @@
|
|||||||
obj[prop].apply(this || window, Array.prototype.slice.call(arguments, 1));
|
obj[prop].apply(this || window, Array.prototype.slice.call(arguments, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.documentOpenOptions && this.documentOpenOptions["logEvents"])
|
||||||
|
{
|
||||||
|
let message = "[logEvent] " + name + " [";
|
||||||
|
for (let i = 1, len = arguments.length; i < len; i++)
|
||||||
|
{
|
||||||
|
if (Asc.checkReturnCommand(arguments[i]))
|
||||||
|
message += JSON.stringify(arguments[i]);
|
||||||
|
else
|
||||||
|
message += "{}";
|
||||||
|
|
||||||
|
if (i !== (len - 1))
|
||||||
|
message += ",";
|
||||||
|
}
|
||||||
|
message += "]";
|
||||||
|
console.log(message);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8230,5 +8230,64 @@ function (window, undefined) {
|
|||||||
{
|
{
|
||||||
return mm * AscCommon.g_dKoef_mm_to_pix;
|
return mm * AscCommon.g_dKoef_mm_to_pix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window["Asc"].checkReturnCommand = function(obj, recursionDepth)
|
||||||
|
{
|
||||||
|
let depth = (recursionDepth === undefined) ? 0 : recursionDepth;
|
||||||
|
if (depth > 10)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (typeof obj)
|
||||||
|
{
|
||||||
|
case "undefined":
|
||||||
|
case "boolean":
|
||||||
|
case "number":
|
||||||
|
case "string":
|
||||||
|
case "symbol":
|
||||||
|
case "bigint":
|
||||||
|
return true;
|
||||||
|
case "object":
|
||||||
|
{
|
||||||
|
if (!obj)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (Array.isArray(obj))
|
||||||
|
{
|
||||||
|
for (let i = 0, len = obj.length; i < len; i++)
|
||||||
|
{
|
||||||
|
if (!Asc.checkReturnCommand(obj[i], depth + 1))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.getPrototypeOf)
|
||||||
|
{
|
||||||
|
let prot = Object.getPrototypeOf(obj);
|
||||||
|
if (prot && prot.__proto__ && prot.__proto__.constructor && prot.__proto__.constructor.name)
|
||||||
|
{
|
||||||
|
if (prot.__proto__.constructor.name === "TypedArray")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let prop in obj)
|
||||||
|
{
|
||||||
|
if (obj.hasOwnProperty(prop))
|
||||||
|
{
|
||||||
|
if (!Asc.checkReturnCommand(obj[prop], depth + 1))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
})(window);
|
})(window);
|
||||||
|
|||||||
@ -1511,7 +1511,7 @@
|
|||||||
this.api._beforeEvalCommand();
|
this.api._beforeEvalCommand();
|
||||||
commandReturnValue = AscCommon.safePluginEval(value);
|
commandReturnValue = AscCommon.safePluginEval(value);
|
||||||
|
|
||||||
if (!checkReturnCommand(commandReturnValue))
|
if (!Asc.checkReturnCommand(commandReturnValue))
|
||||||
commandReturnValue = undefined;
|
commandReturnValue = undefined;
|
||||||
|
|
||||||
let _t = this;
|
let _t = this;
|
||||||
@ -1588,65 +1588,6 @@
|
|||||||
// export
|
// export
|
||||||
CPluginsManager.prototype["buttonClick"] = CPluginsManager.prototype.buttonClick;
|
CPluginsManager.prototype["buttonClick"] = CPluginsManager.prototype.buttonClick;
|
||||||
|
|
||||||
function checkReturnCommand(obj, recursionDepth)
|
|
||||||
{
|
|
||||||
let depth = (recursionDepth === undefined) ? 0 : recursionDepth;
|
|
||||||
if (depth > 10)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
switch (typeof obj)
|
|
||||||
{
|
|
||||||
case "undefined":
|
|
||||||
case "boolean":
|
|
||||||
case "number":
|
|
||||||
case "string":
|
|
||||||
case "symbol":
|
|
||||||
case "bigint":
|
|
||||||
return true;
|
|
||||||
case "object":
|
|
||||||
{
|
|
||||||
if (!obj)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Array.isArray(obj))
|
|
||||||
{
|
|
||||||
for (let i = 0, len = obj.length; i < len; i++)
|
|
||||||
{
|
|
||||||
if (!checkReturnCommand(obj[i], depth + 1))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.getPrototypeOf)
|
|
||||||
{
|
|
||||||
let prot = Object.getPrototypeOf(obj);
|
|
||||||
if (prot && prot.__proto__ && prot.__proto__.constructor && prot.__proto__.constructor.name)
|
|
||||||
{
|
|
||||||
if (prot.__proto__.constructor.name === "TypedArray")
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let prop in obj)
|
|
||||||
{
|
|
||||||
if (obj.hasOwnProperty(prop))
|
|
||||||
{
|
|
||||||
if (!checkReturnCommand(obj[prop], depth + 1))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMessage(event, channel, isObj)
|
function onMessage(event, channel, isObj)
|
||||||
{
|
{
|
||||||
if (!window.g_asc_plugins)
|
if (!window.g_asc_plugins)
|
||||||
@ -2086,5 +2027,5 @@
|
|||||||
document.body.removeChild(_elem);
|
document.body.removeChild(_elem);
|
||||||
_elem = null;
|
_elem = null;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
})(window, undefined);
|
})(window, undefined);
|
||||||
|
|||||||
Reference in New Issue
Block a user