Bug Fix TC-661: SpeechSynthesisUtterance.text has no effect
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 9 Dec 2014 13:13:30 +0000 (15:13 +0200)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Tue, 16 Dec 2014 19:28:38 +0000 (21:28 +0200)
Change-Id: Ib81bbe9931df993d5c3768705a76edb9b7b49b61

src/plugins/client-api/w3c-speech/crosswalk-extension/speech_api.js

index 9a80407..05215ca 100644 (file)
     });
   }
 
+  function _addPropertyWithSetterGetter(obj, prop, setter, getter) {
+    Object.defineProperty(obj, prop, {
+      set: setter,
+      get: getter,
+      configurable: true,
+      enumerable: true
+    });
+  }
+
   extension.setMessageListener(function(json) {
     var msg = JSON.parse(json);
     var reqno = msg.reqno;
 
   function SpeechSynthesisUtterance(text) {
     this._id = -1;
+    var _text = text ? text: '';
+    var _lang = 'english';
+    var _voiceURI = null;
+    var _volume = 1.0;
+    var _rate = 0.0;
+    var _pitch = 1.0;
 
     EventTarget.call(this, [
       'start',
       'boundary'
     ]);
 
-    _addProperty(this, 'text', text);
-    _addProperty(this, 'lang', 'english');
-    _addProperty(this, 'voiceURI');
-    _addProperty(this, 'volume', 1.0);
-    _addProperty(this, 'rate', 0, 0);
-    _addProperty(this, 'pitch', 1.0);
-
     var ut = this;
 
+    function setAttribute(name, value) {
+      if (ut._id == -1) {
+        DBG('Ignoring setAttribute request as no id preset for this object');
+        return;
+      }
+      var set = {};
+      set[name] = value;
+      _sendSyncMessage({
+        'reqno': _getNextReqId(),
+        'type': 'set',
+        'id': ut._id,
+        'set': set
+      });
+    }
+
+    _addPropertyWithSetterGetter(this, 'text', function(text) {
+      _text = text;
+      setAttribute('text', _text);
+    }, function() { return _text; });
+    _addPropertyWithSetterGetter(this, 'lang', function(lang) {
+      _lang = lang;
+      setAttribute('lang', lang);
+    }, function() { return _lang; });
+    _addPropertyWithSetterGetter(this, 'voiceURI', function(uri) {
+      _voiceURI = uri;
+      setAttribute('voiceURI', uri);
+    }, function() { return _voiceURI; });
+    _addPropertyWithSetterGetter(this, 'volume', function(volume) {
+      _volume = volume;
+      setAttribute('volume', volume);
+    }, function() { return _volume; });
+    _addPropertyWithSetterGetter(this, 'rate', function(rate) {
+      _rate = rate;
+      setAttribute('rate', rate);
+    }, function() { return _rate; });
+    _addPropertyWithSetterGetter(this, 'pitch', function(pitch) {
+      _pitch = pitch;
+      setAttribute('pitch', pitch);
+    }, function() { return _pitch; });
+
+
     this.addEventListener('end', function() {
       _dynamic_objects[ut._id] = null;
     });