Fix for functions throwing exceptions unspecified by documentation. 08/192008/3
authorMichal Michalski <m.michalski2@partner.samsung.com>
Fri, 26 Oct 2018 12:51:01 +0000 (14:51 +0200)
committerMichal Michalski <m.michalski2@partner.samsung.com>
Mon, 29 Oct 2018 10:01:36 +0000 (10:01 +0000)
Functions for removing listeners threw exceptions if listener id
was not registered. This behavior was not specified in docs.
This commit disables those exception and silently returns from
functions if listener for given id is not found.

[Verification] TCT tests which call changed api functions passed.

Change-Id: I8fe1a07ade9a35bfbfa95c1a628eeff95a420e0f
Signed-off-by: Michal Michalski <m.michalski2@partner.samsung.com>
src/sound/sound_api.js
src/widgetservice/widgetservice_api.js

index 0eb824440a3b18b03589e9e0de7d5d8984d63f01..a72f8123cccb897f131c4eaecc0cc1f21949f600 100644 (file)
@@ -79,13 +79,12 @@ ListenerManager.prototype.addListener = function(callback) {
 };
 
 ListenerManager.prototype.removeListener = function(watchId) {
-  if (this.listeners.hasOwnProperty(watchId)) {
-    delete this.listeners[watchId];
-  } else {
-    throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
-        'Listener with id: ' + watchId + ' does not exist.');
+  if (!this.listeners.hasOwnProperty(watchId)) {
+    return;
   }
 
+  delete this.listeners[watchId];
+
   if (this.nativeSet && type_.isEmptyObject(this.listeners)) {
       this.native.callSync('SoundManager_removeDeviceStateChangeListener');
       this.native.removeListener(this.listenerName);
index 0ec0275d509bc0c74b221950bad66c7c357fb727..a534fd2837c1048ed5b4781dfa3ffdafb3dc6c53 100644 (file)
@@ -345,7 +345,7 @@ ListenerManager.prototype.addListener = function(callback) {
 
 ListenerManager.prototype.removeListener = function(watchId) {
   if (this.listeners[watchId] === null || this.listeners[watchId] === undefined) {
-    throw new WebAPIException(0, 'Watch id not found.', 'NotFoundError');
+    return;
   }
 
   if (this.listeners.hasOwnProperty(watchId)) {