cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject spec commit: CB-6413: Fix feature detection of ArrayBuffer/Blob support on Sony Android 2.3.7
Date Mon, 14 Apr 2014 19:33:45 GMT
Repository: cordova-mobile-spec
Updated Branches:
  refs/heads/master 75a86b17b -> 9c6d91aa7


CB-6413: Fix feature detection of ArrayBuffer/Blob support on Sony Android 2.3.7


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/9c6d91aa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/9c6d91aa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/9c6d91aa

Branch: refs/heads/master
Commit: 9c6d91aa79f6f3ff552b12c1ac8fa3ebd78138f8
Parents: 75a86b1
Author: Ian Clelland <iclelland@chromium.org>
Authored: Mon Apr 14 14:36:35 2014 -0400
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Mon Apr 14 14:36:35 2014 -0400

----------------------------------------------------------------------
 autotest/tests/file.tests.js | 61 ++++++++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/9c6d91aa/autotest/tests/file.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js
index 4ca47f0..aa933e2 100644
--- a/autotest/tests/file.tests.js
+++ b/autotest/tests/file.tests.js
@@ -3643,7 +3643,9 @@ describe('File API', function() {
         });
         it("file.spec.105 should be able to write binary data from a Blob", function() {
             // Skip test if Blobs are not supported (e.g.: Android 2.3).
-            if (typeof window.Blob == 'undefined' || typeof window.ArrayBuffer == 'undefined')
{
+            if ( (typeof window.Blob != 'function' &&
+                  typeof window.WebKitBlobBuilder == 'undefined') ||
+                typeof window.ArrayBuffer == 'undefined') {
                 return;
             }
             var fileName = "blobwriter.bin",
@@ -3676,12 +3678,12 @@ describe('File API', function() {
             }
             try {
                 // Mobile Safari: Use Blob constructor
-                blob = new Blob([data], {"type": "application/octet-stream"})
+                blob = new Blob([data], {"type": "application/octet-stream"});
             } catch(e) {
                 if (window.WebKitBlobBuilder) {
                     // Android Browser: Use deprecated BlobBuilder
-                    var builder = new WebKitBlobBuilder()
-                    builder.append(data)
+                    var builder = new WebKitBlobBuilder();
+                    builder.append(data);
                     blob = builder.getBlob('application/octet-stream');
                 } else {
                     // We have no way defined to create a Blob, so fail
@@ -3689,17 +3691,18 @@ describe('File API', function() {
                 }
             }
 
-            // creates file, then write content
-            runs(function() {
-                createFile(fileName, write_file);
-            });
+            if (typeof blob !== 'undefined') {// creates file, then write content
+                runs(function() {
+                    createFile(fileName, write_file);
+                });
 
-            waitsFor(function() { return verifier.wasCalled; }, "verifier", Tests.TEST_TIMEOUT);
+                waitsFor(function() { return verifier.wasCalled; }, "verifier", Tests.TEST_TIMEOUT);
 
-            runs(function() {
-                expect(verifier).toHaveBeenCalled();
-                expect(fail).not.toHaveBeenCalled();
-            });
+                runs(function() {
+                    expect(verifier).toHaveBeenCalled();
+                    expect(fail).not.toHaveBeenCalled();
+                });
+            }
         });
         it("file.spec.106 should be able to write a File to a FileWriter", function() {
             var dummyFileName = 'dummy.txt',
@@ -3809,7 +3812,9 @@ describe('File API', function() {
         });
         it("file.spec.108 should be able to write binary data from a File", function() {
             // Skip test if Blobs are not supported (e.g.: Android 2.3).
-            if (typeof window.Blob == 'undefined' || typeof window.ArrayBuffer == 'undefined')
{
+            if ( (typeof window.Blob != 'function' &&
+                  typeof window.WebKitBlobBuilder == 'undefined') ||
+                typeof window.ArrayBuffer == 'undefined') {
                 return;
             }
             var dummyFileName = "blobwriter.bin",
@@ -3861,12 +3866,12 @@ describe('File API', function() {
             }
             try {
                 // Mobile Safari: Use Blob constructor
-                blob = new Blob([data], {"type": "application/octet-stream"})
+                blob = new Blob([data], {"type": "application/octet-stream"});
             } catch(e) {
                 if (window.WebKitBlobBuilder) {
                     // Android Browser: Use deprecated BlobBuilder
-                    var builder = new WebKitBlobBuilder()
-                    builder.append(data)
+                    var builder = new WebKitBlobBuilder();
+                    builder.append(data);
                     blob = builder.getBlob('application/octet-stream');
                 } else {
                     // We have no way defined to create a Blob, so fail
@@ -3874,19 +3879,21 @@ describe('File API', function() {
                 }
             }
 
-            runs(function() {
-                writeFile(dummyFileName, blob, function(dummyFileWriter) {
-                    openFile(dummyFileName, function(file) {
-                        writeFile(outputFileName, file, verifier);
+            if (typeof blob !== 'undefined') {// creates file, then write content
+                runs(function() {
+                    writeFile(dummyFileName, blob, function(dummyFileWriter) {
+                        openFile(dummyFileName, function(file) {
+                            writeFile(outputFileName, file, verifier);
+                        });
                     });
                 });
-            });
-            waitsFor(function() { return (verifier.wasCalled || fail.wasCalled); }, "callbacks
never called", Tests.TEST_TIMEOUT);
+                waitsFor(function() { return (verifier.wasCalled || fail.wasCalled); }, "callbacks
never called", Tests.TEST_TIMEOUT);
 
-            runs(function() {
-                expect(verifier).toHaveBeenCalled();
-                expect(fail).not.toHaveBeenCalled();
-            });
+                runs(function() {
+                    expect(verifier).toHaveBeenCalled();
+                    expect(fail).not.toHaveBeenCalled();
+                });
+            }
         });
     });
     describe('Backwards compatibility', function() {


Mime
View raw message