You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/11/05 03:46:52 UTC

git commit: Fix two long-failing tests

Updated Branches:
  refs/heads/cdvtest 8093c43ff -> 50aa90c59


Fix two long-failing tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/50aa90c5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/50aa90c5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/50aa90c5

Branch: refs/heads/cdvtest
Commit: 50aa90c593cc8e9d5767db4254bd11a1f9e6ba45
Parents: 8093c43
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Nov 4 21:46:29 2013 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Nov 4 21:46:29 2013 -0500

----------------------------------------------------------------------
 test/tests.js | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/50aa90c5/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index edff2d0..85d69e9 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -2062,9 +2062,13 @@ describe('File API', function() {
             window.requestFileSystem(window.PERSISTENT, 0, function(fs) {
                 runReaderTest(fs.root,'readAsDataURL', true, function(evt, fileData, fileDataAsBinaryString) {
                     expect(evt.target.result.substr(0,23)).toBe("data:text/plain;base64,");
-                    // TODO: See if this line is running in existing mobile spec tests
-                    // It fails with INVALID_CHARACTER_ERR on Safari 6.1
-                    expect(evt.target.result.slice(23)).toBe(atob(fileData));
+                    // btoa is not suitable for Unicode strings. See:
+                    // https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa#Unicode_Strings
+                    // This comparison target was generated with the following Python code instead:
+                    //
+                    // fd = '\xe2\x82\xac\xc3\xab - There is an exception to every rule.  Except this one.' + 'bin:\x01\x00'
+                    // print fd.encode('base64').replace('\n','')
+                    expect(evt.target.result.slice(23)).toBe('4oKsw6sgLSBUaGVyZSBpcyBhbiBleGNlcHRpb24gdG8gZXZlcnkgcnVsZS4gIEV4Y2VwdCB0aGlzIG9uZS5iaW46AQA=');
                     done();
                 }, done);
             });
@@ -2125,9 +2129,13 @@ describe('File API', function() {
             window.requestFileSystem(window.PERSISTENT, 0, function(fs) {
                 runReaderTest(fs.root, 'readAsDataURL', true, function(evt, fileData, fileDataAsBinaryString) {
                     expect(evt.target.result.slice(0, 23)).toBe("data:text/plain;base64,");
-                    // TODO: See if this line is running in existing mobile spec tests
-                    // It fails with INVALID_CHARACTER_ERR on Safari 6.1
-                    expect(evt.target.result.slice(23)).toBe(atob(fileDataAsBinaryString.slice( 10, -3)));
+                    // btoa is not suitable for Unicode strings. See:
+                    // https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa#Unicode_Strings
+                    // This comparison target was generated with the following Python code instead:
+                    //
+                    // fd = '\xe2\x82\xac\xc3\xab - There is an exception to every rule.  Except this one.' + 'bin:\x01\x00'
+                    // print fd[10,-3].encode('base64').strip()
+                    expect(evt.target.result.slice(23)).toBe('ZXJlIGlzIGFuIGV4Y2VwdGlvbiB0byBldmVyeSBydWxlLiAgRXhjZXB0IHRoaXMgb25lLmJpbg==');
                     done();
                 }, done, 10, -3);
             });