[Common] Replacing JS warnings + errors 56/124156/2
authorSzymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Wed, 12 Apr 2017 08:12:03 +0000 (10:12 +0200)
committerSzymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Wed, 12 Apr 2017 08:12:03 +0000 (10:12 +0200)
[Verification] Related TCT result did not change

Change-Id: I32be5db87552997eaa0c173dea29bca13873b5eb
Signed-off-by: Szymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
src/application/application_api.js
src/bluetooth/bluetooth_api.js
src/calendar/js/calendar_alarm.js
src/content/js/manager.js
src/humanactivitymonitor/humanactivitymonitor_api.js
src/nfc/nfc_api.js
src/power/power_api.js
src/push/push_api.js
src/systeminfo/systeminfo_api.js
src/time/time_api.js
src/utils/utils_api.js

index b0d5774..b668dbb 100755 (executable)
@@ -565,7 +565,7 @@ var APPLICATION_EVENT_LISTENER = 'ApplicationEventListener';
 var applicationEventListener = new ListenerManager(native, APPLICATION_EVENT_LISTENER);
 
 ApplicationManager.prototype.addAppInfoEventListener = function() {
-  console.warn('DEPRECATION WARNING: addAppInfoEventListener() is deprecated and will be removed from next release. '
+  privUtils_.warn('DEPRECATION WARNING: addAppInfoEventListener() is deprecated and will be removed from next release. '
       + 'Use tizen.package.setPackageInfoEventListener() instead.');
 
   var args = AV.validateMethod(arguments, [
@@ -580,7 +580,7 @@ ApplicationManager.prototype.addAppInfoEventListener = function() {
 };
 
 ApplicationManager.prototype.removeAppInfoEventListener = function() {
-  console.warn('DEPRECATION WARNING: removeAppInfoEventListener() is deprecated and will be removed from next release. '
+  privUtils_.warn('DEPRECATION WARNING: removeAppInfoEventListener() is deprecated and will be removed from next release. '
       + 'Use tizen.package.unsetPackageInfoEventListener() instead.');
 
   var args = AV.validateMethod(arguments, [
index 117ff30..09979b3 100755 (executable)
@@ -2034,7 +2034,7 @@ BluetoothAdapter.prototype.setName = function() {
 
 BluetoothAdapter.prototype.setPowered = function() {
     privUtils_.log('Entered BluetoothAdapter.setPowered()');
-    console.warn('DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. '
+    privUtils_.warn('DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. '
         + 'Let the user turn on/off Bluetooth through the Settings application instead.');
 
     var args = AV.validateMethod(arguments, [
index 08c2638..6976ac5 100755 (executable)
@@ -19,6 +19,8 @@ var AlarmMethod = {
   DISPLAY: 'DISPLAY'
 };
 
+var privUtils_ = xwalk.utils;
+
 var CalendarAlarm = function(time, method, description) {
   validator_.isConstructorCall(this, CalendarAlarm);
 
@@ -30,7 +32,7 @@ var CalendarAlarm = function(time, method, description) {
   try {
     _method = converter_.toEnum(method, Object.keys(AlarmMethod), false);
   } catch (e) {
-    console.warn('Failed to convert method: "' + method + '" to enum AlarmMethod.');
+    privUtils_.warn('Failed to convert method: "' + method + '" to enum AlarmMethod.');
     _method = method;
   }
 
index 6498d59..db388dc 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 var T_ = xwalk.utils.type;
+var privUtils_ = xwalk.utils;
 var CONTENT_MANAGER_LISTENER_ID = 'ContentManagerChangeCallback';
 
 
@@ -335,7 +336,7 @@ ContentManager.prototype.removeChangeListener = function() {
 };
 
 ContentManager.prototype.setChangeListener = function(changeCallback) {
-  console.warn('DEPRECATION WARNING: setChangeListener() is deprecated and will be removed '
+  privUtils_.warn('DEPRECATION WARNING: setChangeListener() is deprecated and will be removed '
       + 'from next release. Use addChangeListener() instead.');
 
   var args = validator_.validateArgs(arguments, [{
@@ -370,7 +371,7 @@ ContentManager.prototype.setChangeListener = function(changeCallback) {
 };
 
 ContentManager.prototype.unsetChangeListener = function() {
-  console.warn('DEPRECATION WARNING: unsetChangeListener() is deprecated and will be removed '
+  privUtils_.warn('DEPRECATION WARNING: unsetChangeListener() is deprecated and will be removed '
       + 'from next release. Use removeChangeListener() instead.');
 
   var data = {};
index 81002eb..3f06004 100755 (executable)
@@ -97,7 +97,7 @@ function convertActivityData(type, data) {
     case HumanActivityType.SLEEP_MONITOR:
       return new HumanActivitySleepMonitorData(data);
     default:
-      console.error('Uknown human activity type: ' + type);
+      utils_.error('Uknown human activity type: ' + type);
   }
 }
 
@@ -127,7 +127,7 @@ function convertActivityRecorderData(type, data) {
       func = HumanActivityRecorderPressureData;
       break;
     default:
-      console.error('Uknown human activity recorder type: ' + type);
+      utils_.error('Uknown human activity recorder type: ' + type);
       return;
   }
 
index db3d0e3..8aa8b58 100644 (file)
@@ -272,7 +272,7 @@ function NFCAdapter() {
 }
 
 NFCAdapter.prototype.setPowered = function() {
-  console.warn('DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. Let the user turn NFC on/off '
+  privUtils_.warn('DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. Let the user turn NFC on/off '
       + 'through the Settings application instead.');
 
   var args = validator_.validateArgs(arguments, [
index f7a711d..06453eb 100755 (executable)
@@ -18,6 +18,7 @@ var JSON_ = xwalk.JSON;
 var validator_ = xwalk.utils.validator;
 var types_ = validator_.Types;
 var native_ = new xwalk.utils.NativeManager(extension);
+var privUtils_ = xwalk.utils;
 
 function ListenerManager(native, listenerName) {
   this.listener;
@@ -127,7 +128,7 @@ PowerManager.prototype.request = function(resource, state) {
     ]);
 
     if (args['state'] && args.state === PowerScreenState['SCREEN_BRIGHT']) {
-        console.warn('DEPRECATION WARNING: SCREEN_BRIGHT is deprecated and will be removed from next release.');
+        privUtils_.warn('DEPRECATION WARNING: SCREEN_BRIGHT is deprecated and will be removed from next release.');
     }
 
     var nativeParam = {
@@ -278,7 +279,7 @@ PowerManager.prototype.restoreScreenBrightness = function() {
  * Turns on the screen.
  */
 PowerManager.prototype.turnScreenOn = function() {
-    console.warn('DEPRECATION WARNING: turnScreenOn() is deprecated and will be removed from next release. Use request() instead.');
+    privUtils_.warn('DEPRECATION WARNING: turnScreenOn() is deprecated and will be removed from next release. Use request() instead.');
 
     var nativeParam = {
     };
@@ -295,7 +296,7 @@ PowerManager.prototype.turnScreenOn = function() {
  * Turns off the screen.
  */
 PowerManager.prototype.turnScreenOff = function() {
-    console.warn('DEPRECATION WARNING: turnScreenOff() is deprecated and will be removed from next release. Use release() instead.');
+    privUtils_.warn('DEPRECATION WARNING: turnScreenOff() is deprecated and will be removed from next release. Use release() instead.');
 
     var nativeParam = {
     };
index 6e623a6..78d4113 100644 (file)
@@ -17,7 +17,7 @@
 var native = new xwalk.utils.NativeManager(extension);
 var validator = xwalk.utils.validator;
 var validatorType = xwalk.utils.type;
-
+var privUtils_ = xwalk.utils;
 
 /**
  * @const
@@ -59,7 +59,7 @@ function PushManager() {
 }
 
 PushManager.prototype.registerService = function() {
-  console.warn('DEPRECATION WARNING: registerService() is deprecated and will be removed from next release. Use register() instead.');
+  privUtils_.warn('DEPRECATION WARNING: registerService() is deprecated and will be removed from next release. Use register() instead.');
   var data = validator.validateArgs(arguments, [
     {
       name: 'appControl',
@@ -121,7 +121,7 @@ PushManager.prototype.register = function() {
 };
 
 PushManager.prototype.unregisterService = function() {
-  console.warn('DEPRECATION WARNING: unregisterService() is deprecated and will be removed from next release. Use unregister() instead.');
+  privUtils_.warn('DEPRECATION WARNING: unregisterService() is deprecated and will be removed from next release. Use unregister() instead.');
   var data = validator.validateArgs(arguments, [
     {
       name: 'successCallback',
@@ -182,7 +182,7 @@ PushManager.prototype.unregister = function() {
 };
 
 PushManager.prototype.connectService = function(notificationCallback) {
-  console.warn('DEPRECATION WARNING: connectService() is deprecated and will be removed from next release. Use connect() instead.');
+  privUtils_.warn('DEPRECATION WARNING: connectService() is deprecated and will be removed from next release. Use connect() instead.');
   var data = validator.validateArgs(arguments, [
     {
       name: 'notificationCallback',
@@ -246,7 +246,7 @@ PushManager.prototype.connect = function(notificationCallback) {
 };
 
 PushManager.prototype.disconnectService = function() {
-  console.warn('DEPRECATION WARNING: disconnectService() is deprecated and will be removed from next release. Use disconnect() instead.');
+  privUtils_.warn('DEPRECATION WARNING: disconnectService() is deprecated and will be removed from next release. Use disconnect() instead.');
   var ret = native.callSync('Push_disconnectService', {});
   if (native.isFailure(ret)) {
     throw native.getErrorObject(ret);
index ce4755b..e09c977 100644 (file)
@@ -737,7 +737,7 @@ var SystemInfo = function() {
 };
 
 SystemInfo.prototype.getCapabilities = function() {
-    console.warn('DEPRECATION WARNING: getCapabilities() is deprecated and will be removed from next release. Use getCapability() instead.');
+    privUtils_.warn('DEPRECATION WARNING: getCapabilities() is deprecated and will be removed from next release. Use getCapability() instead.');
 
     var result = native_.callSync('SystemInfo_getCapabilities', {});
     if (native_.isFailure(result)) {
index 95c9d6f..ba31ab8 100644 (file)
@@ -533,7 +533,7 @@ tizen.TZDate.prototype.toString = function() {
 
 tizen.TZDate.prototype.getTimezoneAbbreviation = function() {
   utils_.log('Entered TZDate.getTimezoneAbbreviation');
-  console.warn('DEPRECATION WARNING: getTimezoneAbbreviation() is deprecated and will be removed from next release.');
+  utils_.warn('DEPRECATION WARNING: getTimezoneAbbreviation() is deprecated and will be removed from next release.');
 
   var result = native_.callSync('TZDate_getTimezoneAbbreviation',
       {timezone: String(this._timezoneName),
index ca61725..1653b54 100644 (file)
@@ -5,10 +5,16 @@
 
 //Object xwalk.JSON - guaranteed to not being modified by the application programmer
 var JSON_ = {stringify: JSON.stringify, parse: JSON.parse};
-Object.freeze(JSON_)
+Object.freeze(JSON_);
 exports.JSON = JSON_;
 
 var _enableJsLogs = false;
+var _console = {
+  error: console.error,
+  log: console.log,
+  warn: console.warn
+};
+Object.freeze(_console);
 
 var _global = {};
 if (typeof window != 'undefined') {
@@ -146,11 +152,19 @@ function Utils() {
   });
 }
 
+Utils.prototype.error = function() {
+  _console.error.apply(_console, arguments);
+};
+
 Utils.prototype.log = function() {
   if (_enableJsLogs) {
-    console.log.apply(console, arguments);
+    _console.log.apply(_console, arguments);
   }
-}
+};
+
+Utils.prototype.warn = function() {
+  _console.warn.apply(_console, arguments);
+};
 
 Utils.prototype.repackFilter = function(filter) {
   if (filter instanceof tizen.AttributeFilter) {
@@ -975,19 +989,19 @@ var NativeManager = function(extension) {
   // TODO: Remove mockup if WRT implements sendRuntimeMessage
   // This is temporary mockup!
   extension.sendRuntimeMessage = extension.sendRuntimeMessage || function() {
-    console.error('Runtime did not implement extension.sendRuntimeMessage!');
+    _console.error('Runtime did not implement extension.sendRuntimeMessage!');
     throw new WebAPIException(WebAPIException.UNKNOWN_ERR,
         'Runtime did not implement extension.sendRuntimeMessage!');
   };
 
   extension.sendRuntimeAsyncMessage = extension.sendRuntimeAsyncMessage || function() {
-    console.error('Runtime did not implement extension.sendRuntimeAsyncMessage!');
+    _console.error('Runtime did not implement extension.sendRuntimeAsyncMessage!');
     throw new WebAPIException(WebAPIException.UNKNOWN_ERR,
         'Runtime did not implement extension.sendRuntimeAsyncMessage!');
   };
 
   extension.sendRuntimeSyncMessage = extension.sendRuntimeSyncMessage || function() {
-    console.error('Runtime did not implement extension.sendRuntimeSyncMessage!');
+    _console.error('Runtime did not implement extension.sendRuntimeSyncMessage!');
     throw new WebAPIException(WebAPIException.UNKNOWN_ERR,
         'Runtime did not implement extension.sendRuntimeSyncMessage!');
   };
@@ -1028,7 +1042,7 @@ var NativeManager = function(extension) {
       delete msg[this.CALLBACK_ID_KEY];
 
       if (!_type.isFunction(this.callbacks_[id])) {
-        console.error('Wrong callback identifier. Ignoring message.');
+        _console.error('Wrong callback identifier. Ignoring message.');
         return;
       }
 
@@ -1037,8 +1051,8 @@ var NativeManager = function(extension) {
         try {
           f(msg);
         } catch (e) {
-          console.error('########## exception');
-          console.error(e);
+          _console.error('########## exception');
+          _console.error(e);
         }
       }, 0);
       delete this.callbacks_[id];
@@ -1051,7 +1065,7 @@ var NativeManager = function(extension) {
       delete msg[this.LISTENER_ID_KEY];
 
       if (!_type.isFunction(this.listeners_[id])) {
-        console.error('Wrong listener identifier. Ignoring message.');
+        _console.error('Wrong listener identifier. Ignoring message.');
         return;
       }
 
@@ -1060,15 +1074,15 @@ var NativeManager = function(extension) {
         try {
           f(msg);
         } catch (e) {
-          console.error('########## exception');
-          console.error(e);
+          _console.error('########## exception');
+          _console.error(e);
         }
       }, 0);
 
       return;
     }
 
-    console.error('Missing callback or listener identifier. Ignoring message.');
+    _console.error('Missing callback or listener identifier. Ignoring message.');
 
   }.bind(this));
 };
@@ -1174,7 +1188,7 @@ NativeManager.prototype.callIfPossible = function(callback) {
  *            age: 28
  *        }
  *    });
- *    console.log(result);
+ *    _console.log(result);
  *
  *    To send async method and handle response:
  *    bridge.async({
@@ -1229,7 +1243,7 @@ var NativeBridge = (function (extension, debug) {
 
         CallbackManager.prototype = {
             add: function (/*callbacks, cid?*/) {
-                if (debug) console.log('bridge.CallbackManager.add');
+                if (debug) _console.log('bridge.CallbackManager.add');
                 var args = Array.prototype.slice.call(arguments);
                 var c = args.shift();
                 var cid = args.pop();
@@ -1246,11 +1260,11 @@ var NativeBridge = (function (extension, debug) {
                 return cid;
             },
             remove: function (cid) {
-                if (debug)  console.log('bridge.CallbackManager.remove, cid: ' + cid);
+                if (debug)  _console.log('bridge.CallbackManager.remove, cid: ' + cid);
                 if (_collection[cid]) delete _collection[cid];
             },
             call: function (cid, key, args, keep) {
-                if (debug) console.log('bridge.CallbackManager.call, cid: '+ cid + ', key: ' + key);
+                if (debug) _console.log('bridge.CallbackManager.call, cid: '+ cid + ', key: ' + key);
                 var callbacks = _collection[cid];
                 keep = !!keep;
                 if (callbacks) {
@@ -1282,13 +1296,13 @@ var NativeBridge = (function (extension, debug) {
 
         ListenerManager.prototype = {
             add: function (l) {
-                if (debug) console.log('bridge.ListenerManager.add');
+                if (debug) _console.log('bridge.ListenerManager.add');
                 var id = _next();
                 _listeners[id] = l;
                 return id;
             },
             resolve: function (id, action, data, keep) {
-                if (debug) console.log('bridge.ListenerManager.resolve, id: ' + id + ', action: ' + action);
+                if (debug) _console.log('bridge.ListenerManager.resolve, id: ' + id + ', action: ' + action);
                 keep = !!keep;
                 var l = _listeners[id];
                 if (l) {
@@ -1298,7 +1312,7 @@ var NativeBridge = (function (extension, debug) {
                 return l;
             },
             remove: function (id) {
-                if (debug) console.log('bridge.ListenerManager.remove, id: ' + id);
+                if (debug) _console.log('bridge.ListenerManager.remove, id: ' + id);
                 var l = _listeners[id];
                 if (l) {
                     var cm = Callbacks.getInstance();
@@ -1333,12 +1347,12 @@ var NativeBridge = (function (extension, debug) {
     })();
 
     var Listener = function () {
-        if (debug) console.log('bridge: Listener constructor');
+        if (debug) _console.log('bridge: Listener constructor');
         this.cid = null;
     };
     Listener.prototype = {
         then: function (c) {
-            if (debug) console.log('bridge.Listener.then');
+            if (debug) _console.log('bridge.Listener.then');
             var cm = Callbacks.getInstance();
             this.cid = cm.add(c, this.cid);
             return this;
@@ -1352,7 +1366,7 @@ var NativeBridge = (function (extension, debug) {
               cmd: data.cmd,
               args: data
             });
-            if (debug) console.log('bridge.sync, json: ' + json);
+            if (debug) _console.log('bridge.sync, json: ' + json);
             var result = extension.internal.sendSyncMessage(json);
             var obj = JSON_.parse(result);
             if (obj.error)
@@ -1366,7 +1380,7 @@ var NativeBridge = (function (extension, debug) {
                 cmd: data.cmd,
                 args: data
             });
-            if (debug) console.log('bridge.async, json: ' + json);
+            if (debug) _console.log('bridge.async, json: ' + json);
             setTimeout(function () {
                 extension.postMessage(json);
             });
@@ -1399,7 +1413,7 @@ var NativeBridge = (function (extension, debug) {
          *}
          */
 
-        if (debug) console.log('bridge.setMessageListener, json: ' + json);
+        if (debug) _console.log('bridge.setMessageListener, json: ' + json);
         var data = JSON_.parse(json);
         if (data.cid && data.action) {
             setTimeout(function() {