[Utils] Change Utils.prototype.assert method to more generic 22/243722/1
authorRafal Walczyna <r.walczyna@samsung.com>
Wed, 9 Sep 2020 09:44:46 +0000 (11:44 +0200)
committerRafal Walczyna <r.walczyna@samsung.com>
Wed, 9 Sep 2020 09:48:45 +0000 (11:48 +0200)
Starfish engine, which is used in WebWidgets, does not support console.assert

[Verification] WebWidgetTCT runs succesfully

Change-Id: I6286537c6bc8995b5fd3c0a60f22b2d2595ed787
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
src/utils/utils_api.js

index 8108e7c..2ff6b09 100644 (file)
@@ -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;