From: Tomasz Marciniak Date: Fri, 19 Jun 2015 08:05:25 +0000 (+0200) Subject: [Mediacontroller] Check if watch id exists before removing. X-Git-Tag: submit/tizen/20150702.103311^2~2^2~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d7f8e550cfa98aea4f0dd1e60d28dfe7efb2494;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Mediacontroller] Check if watch id exists before removing. [Verification] Code compiles without errors. Below tests pass: MediaControllerServerInfo_removeServerStatusChangeListener_watchId_invalid :MediaControllerServerInfo_removePlaybackInfoChangeListener_watchId_invalid Change-Id: I74646150669cc5d8e95893e7bd605ca885cd5568 Signed-off-by: Tomasz Marciniak --- diff --git a/src/mediacontroller/mediacontroller_api.js b/src/mediacontroller/mediacontroller_api.js index a018b07c..309ca9cd 100755 --- a/src/mediacontroller/mediacontroller_api.js +++ b/src/mediacontroller/mediacontroller_api.js @@ -62,6 +62,10 @@ 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.', 'InvalidValuesError'); + } + if (this.listeners.hasOwnProperty(watchId)) { delete this.listeners[watchId]; }