From: Piotr Kosko/Native/Web API (PLT) /SRPOL/Professional/삼성전자 Date: Wed, 17 Apr 2019 06:55:20 +0000 (+0200) Subject: [Content] Some attributes are readonly since 5.5 X-Git-Tag: submit/tizen/20190418.053050~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8a86c99c773de2b6c7cd26fc26333adb79d32dc;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Content] Some attributes are readonly since 5.5 [Feature] name, description, rating, geolocation and orientation attributes are readonly since 5.5. For backward compatibility, the attributes are allowed for modifications for apps with required version lower than 5.5 modified editableAttributes member also to remove readonly attributes from this array. [ACR] http://suprem.sec.samsung.net/jira/browse/TWDAPI-203 [Verification] TCT passrate 100% when running with 5.0 TCT - backward compatibility. 14 fails on latest TCT, TCT passrate 100% with TCT fixed by TCT team. Change-Id: I8382372c51105fb7e11c3037d5994e2de76d59fa Signed-off-by: Piotr Kosko/Native/Web API (PLT) /SRPOL/Professional/삼성전자 --- diff --git a/src/content/js/common.js b/src/content/js/common.js index e60816bb..99d9258e 100755 --- a/src/content/js/common.js +++ b/src/content/js/common.js @@ -21,6 +21,8 @@ var validator_ = utils_.validator; var types_ = validator_.Types; var native_ = new xwalk.utils.NativeManager(extension); +var isEarlierThan55 = utils_.isAppVersionEarlierThan('5.5'); + var EditManager = function() { this.isAllowed = false; }; diff --git a/src/content/js/datatypes.js b/src/content/js/datatypes.js index 60b95cc7..27863f6b 100755 --- a/src/content/js/datatypes.js +++ b/src/content/js/datatypes.js @@ -122,7 +122,15 @@ function ContentDirectory(data) { function Content(data) { - var editableAttributes = ['name', 'rating', 'description']; + var editableAttributes = ['isFavorite']; + // since 5.5 these attributes are readonly, it is disallowed to modify them, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55) { + editableAttributes.push('name'); + editableAttributes.push('rating'); + editableAttributes.push('description'); + } var id; var name; var type; @@ -159,8 +167,15 @@ function Content(data) { return name; }, set: function(v) { - if (!type_.isNull(v)) { - name = converter_.toString(v, false); + // since 5.5 this attribute is readonly, it is disallowed to modify it, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55 || edit_.isAllowed) { + if (!type_.isNull(v)) { + name = converter_.toString(v, false); + } + } else { + utils_.warn('Since 5.5 "name" attribute is readonly, modifying it has no effect.'); } }, enumerable: true @@ -258,7 +273,14 @@ function Content(data) { return description; }, set: function(v) { - description = converter_.toString(v, true); + // since 5.5 this attribute is readonly, it is disallowed to modify it, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55 || edit_.isAllowed) { + description = converter_.toString(v, true); + } else { + utils_.warn('Since 5.5 "description" attribute is readonly, modifying it has no effect.'); + } }, enumerable: true }, @@ -267,8 +289,15 @@ function Content(data) { return rating; }, set: function(v) { - if (!type_.isNull(v) && v >= 0 && v <= 10) { - rating = converter_.toUnsignedLong(v, false); + // since 5.5 this attribute is readonly, it is disallowed to modify it, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55 || edit_.isAllowed) { + if (!type_.isNull(v) && v >= 0 && v <= 10) { + rating = converter_.toUnsignedLong(v, false); + } + } else { + utils_.warn('Since 5.5 "rating" attribute is readonly, modifying it has no effect.'); } }, enumerable: true @@ -303,7 +332,12 @@ function VideoContent(data) { Content.call(this, data); var editableAttributes = this.editableAttributes; - editableAttributes.push('geolocation'); + // since 5.5 this attribute is readonly, it is disallowed to modify it, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55) { + editableAttributes.push('geolocation'); + } var geolocation; var album; @@ -323,10 +357,17 @@ function VideoContent(data) { return geolocation; }, set: function(v) { - if (!type_.isNull(v)) { - var latitude = converter_.toDouble(v.latitude, false); - var longitude = converter_.toDouble(v.longitude, false); - geolocation = new tizen.SimpleCoordinates(latitude, longitude); + // since 5.5 this attribute is readonly, it is disallowed to modify it, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55 || edit_.isAllowed) { + if (!type_.isNull(v)) { + var latitude = converter_.toDouble(v.latitude, false); + var longitude = converter_.toDouble(v.longitude, false); + geolocation = new tizen.SimpleCoordinates(latitude, longitude); + } + } else { + utils_.warn('Since 5.5 "geolocation" attribute is readonly, modifying it has no effect.'); } }, enumerable: true @@ -615,8 +656,13 @@ function ImageContent(data) { Content.call(this, data); var editableAttributes = this.editableAttributes; - editableAttributes.push('geolocation'); - editableAttributes.push('orientation'); + // since 5.5 these attributes are readonly, it is disallowed to modify them, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55) { + editableAttributes.push('geolocation'); + editableAttributes.push('orientation'); + } var geolocation; var width; @@ -634,10 +680,17 @@ function ImageContent(data) { return geolocation; }, set: function(v) { - if (!type_.isNull(v)) { - var latitude = converter_.toDouble(v.latitude, false); - var longitude = converter_.toDouble(v.longitude, false); - geolocation = new tizen.SimpleCoordinates(latitude, longitude); + // since 5.5 this attribute is readonly, it is disallowed to modify it, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55 || edit_.isAllowed) { + if (!type_.isNull(v)) { + var latitude = converter_.toDouble(v.latitude, false); + var longitude = converter_.toDouble(v.longitude, false); + geolocation = new tizen.SimpleCoordinates(latitude, longitude); + } + } else { + utils_.warn('Since 5.5 "geolocation" attribute is readonly, modifying it has no effect.'); } }, enumerable: true @@ -669,8 +722,15 @@ function ImageContent(data) { return orientation; }, set: function(v) { - if (!type_.isNull(v)) { - orientation = converter_.toEnum(v, Object.keys(ImageContentOrientation), false); + // since 5.5 this attribute is readonly, it is disallowed to modify it, + // but for applications developed for earlier versions backward compatibility + // is kept + if (isEarlierThan55 || edit_.isAllowed) { + if (!type_.isNull(v)) { + orientation = converter_.toEnum(v, Object.keys(ImageContentOrientation), false); + } + } else { + utils_.warn('Since 5.5 "orientation" attribute is readonly, modifying it has no effect.'); } }, enumerable: true