From 1d7f8e550cfa98aea4f0dd1e60d28dfe7efb2494 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Fri, 19 Jun 2015 10:05:25 +0200 Subject: [PATCH] [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 --- src/mediacontroller/mediacontroller_api.js | 4 ++++ 1 file changed, 4 insertions(+) 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]; } -- 2.34.1