[Content] Some attributes are readonly since 5.5 27/203727/4
authorPiotr Kosko/Native/Web API (PLT) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
Wed, 17 Apr 2019 06:55:20 +0000 (08:55 +0200)
committerPiotr Kosko/Native/Web API (PLT) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
Wed, 17 Apr 2019 11:40:20 +0000 (13:40 +0200)
[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/삼성전자 <p.kosko@samsung.com>
src/content/js/common.js
src/content/js/datatypes.js

index e60816bbde457a6981121d31a573624e151c437a..99d9258ed3e6651214beb11120b5ed580f351373 100755 (executable)
@@ -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;
 };
index 60b95cc77bf05e5a9ce49c4c031177c779881f3d..27863f6b3a1071f40e605f503004f109f23fd3ed 100755 (executable)
@@ -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