From c0ded69243c6e3909fca94aeb156360a82731e87 Mon Sep 17 00:00:00 2001 From: Rafal Walczyna Date: Wed, 9 Sep 2020 11:44:46 +0200 Subject: [PATCH] [Utils] Change Utils.prototype.assert method to more generic Starfish engine, which is used in WebWidgets, does not support console.assert [Verification] WebWidgetTCT runs succesfully Change-Id: I6286537c6bc8995b5fd3c0a60f22b2d2595ed787 Signed-off-by: Rafal Walczyna --- src/utils/utils_api.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 8108e7c..2ff6b09 100644 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -212,7 +212,15 @@ function Utils() { Utils.prototype.error = console.error.bind(console); Utils.prototype.warn = console.warn.bind(console); Utils.prototype.log = _enableJsLogs ? console.log.bind(console) : function() {}; -Utils.prototype.assert = console.assert.bind(console); +if (console.assert) { + Utils.prototype.assert = console.assert.bind(console); +} else { + Utils.prototype.assert = function() { + if (false === arguments[0]) { + console.error("Assertion failed: ", Array.prototype.slice.call(arguments, 1)); + } + } +} Utils.prototype.global = _global; -- 2.7.4