If to method which takes object as parameter, array with one element
of this object will be passed them applicaiton will crash. This fix prevent
such situations and will throw TypeMissmatch
[Verification] Code compiles without error. Tested in chrome console and
execute automatic TCT (modules which have methods taking platform object as parameter -
account, alarm, application, bluetooth, bookmark, calendar, callhistory, contact,
content, download, exif, filesystem, iotcon, mediacontroller, messageport,
messaging, nfc, notification, push, time)
100% passrate
Change-Id: Idfd9ad6f1acc0a6d5fd140dfd655d1cab7d2291a
Signed-off-by: Lukasz Bardeli <l.bardeli@samsung.com>
(cherry picked from commit
faaf457e2aa1307f0c3406208374d71d5c98827b)
};
function _toPlatformObject(val, types) {
- var v;
var t;
- if (_type.isArray(val)) {
- v = val;
- } else {
- v = [val];
- }
if (_type.isArray(types)) {
t = types;
} else {
t = [types];
}
+
+ if (_type.isArray(val)) {
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
+ 'Cannot convert ' + String(val) + ' to ' + String(t[0].name) + '.');
+ }
+
var match = false;
for (var i = 0; i < t.length; ++i) {
- for (var j = 0; j < v.length; ++j) {
- match = match || (v[j] instanceof t[i]);
+ if (val instanceof t[i]) {
+ return val;
}
}
- if (match) {
- return val;
- }
throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Cannot convert ' + String(val) + ' to ' + String(t[0].name) + '.');