[Filesystem] Fixing return behaviour for FileHandle object 77/193777/1
authorPiotr Kosko/Native/Web API (SWP) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
Mon, 26 Nov 2018 08:08:12 +0000 (09:08 +0100)
committerPiotr Kosko/Native/Web API (SWP) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
Mon, 26 Nov 2018 08:08:12 +0000 (09:08 +0100)
[Bug] When returning the asynchronous error while doing an operation on
  FileHandle, the processing was not interrupted. Missing return statement
  in those cases was added.

[Verification] Code compiles without errors.
  TCT passrate for Filesystem - 100%

Change-Id: Ie8ba77922fa74c0263c40e55a157c2979b893cff
Signed-off-by: Piotr Kosko/Native/Web API (SWP) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
src/filesystem/js/file.js
src/filesystem/js/file_handle.js

index 990e42810b813c6c039ca0df110219478a89017d..0885dead3848092c0b821742df2a5e233d414954 100644 (file)
@@ -74,7 +74,7 @@ File.prototype.toURI = function() {
 function stringToRegex(str) {
   var _regString = '^';
   if (str === '') {
-    return new RegExp(_regString, 'i');
+    return new RegExp(_regString + "$", 'i');
   }
   // single '\' sign is not visible in JS string, escaping % wildcard need to be done by '\\%'
   str = str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
index d45a1d174f3ff81d9ed442e3dd9b86828e6c76b1..3d9a2ed9e252840c25a26df9ab57a70c7eb3ed46 100644 (file)
@@ -68,6 +68,7 @@ FileHandle.prototype.seekNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
   var data = {id: this.id, offset: args.offset, blocking: false};
   if (undefined === args.whence) {
@@ -128,6 +129,7 @@ FileHandle.prototype.readStringNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
   if ((this.mode === 'w') || (this.mode === 'a')) {
     setTimeout(function() {
@@ -135,6 +137,7 @@ FileHandle.prototype.readStringNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is write-only'));
     }, 0);
+    return;
   }
   var data = {id: this.id, encoding: args.inputEncoding, blocking: false};
   if (!type_.isNullOrUndefined(args.count)) {
@@ -196,6 +199,7 @@ FileHandle.prototype.writeStringNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
   if ('r' === this.mode) {
     setTimeout(function() {
@@ -203,6 +207,7 @@ FileHandle.prototype.writeStringNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only'));
     }, 0);
+    return;
   }
   var data =
       {id: this.id, string: args.string, encoding: args.outputEncoding, blocking: false};
@@ -265,6 +270,7 @@ FileHandle.prototype.readBlobNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
 
   var data = {id: this.id, blocking: false};
@@ -339,12 +345,14 @@ FileHandle.prototype.writeBlobNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   } else if (this.mode === 'r') {
     setTimeout(function() {
       native_.callIfPossible(
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only'));
     }, 0);
+    return;
   }
 
   var encodedData = ArrayToString(blobToUint8Array(args.blob));
@@ -365,6 +373,7 @@ FileHandle.prototype.writeBlobNonBlocking = function() {
     setTimeout(function() {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     }, 0);
+    return;
   }
 };
 
@@ -403,6 +412,7 @@ FileHandle.prototype.readDataNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
   if ((this.mode === 'w') || (this.mode === 'a')) {
     setTimeout(function() {
@@ -410,6 +420,7 @@ FileHandle.prototype.readDataNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is write-only'));
     }, 0);
+    return;
   }
 
   var data = {id: this.id, blocking: false};
@@ -470,12 +481,14 @@ FileHandle.prototype.writeDataNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   } else if (this.mode === 'r') {
     setTimeout(function() {
       native_.callIfPossible(
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only'));
     }, 0);
+    return;
   }
 
   var encodedData = ArrayToString(args.data);
@@ -527,6 +540,7 @@ FileHandle.prototype.flushNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
   if (this.mode === 'r') {
     setTimeout(function() {
@@ -534,6 +548,7 @@ FileHandle.prototype.flushNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only'));
     }, 0);
+    return;
   }
   var data = {id: this.id, blocking: false};
 
@@ -583,6 +598,7 @@ FileHandle.prototype.syncNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
   if (this.mode === 'r') {
     setTimeout(function() {
@@ -590,6 +606,7 @@ FileHandle.prototype.syncNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only'));
     }, 0);
+    return;
   }
   var data = {id: this.id, blocking: false};
 
@@ -635,6 +652,7 @@ FileHandle.prototype.closeNonBlocking = function() {
           args.errorCallback,
           new WebAPIException(WebAPIException.IO_ERR, 'FileHandle is not opened'));
     }, 0);
+    return;
   }
 
   var data = {id: this.id, blocking: false};