Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B3A0C1158A for ; Mon, 14 Apr 2014 19:33:46 +0000 (UTC) Received: (qmail 81055 invoked by uid 500); 14 Apr 2014 19:33:46 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 81014 invoked by uid 500); 14 Apr 2014 19:33:46 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 81007 invoked by uid 99); 14 Apr 2014 19:33:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Apr 2014 19:33:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C968598D5D7; Mon, 14 Apr 2014 19:33:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ian@apache.org To: commits@cordova.apache.org Message-Id: <92627603c1b343ea96117695eb92fea7@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Mon Apr 14 14:36:35 2014 -0400 Committer: Ian Clelland 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() {