cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse <purplecabb...@gmail.com>
Subject window.btoa
Date Wed, 11 Sep 2013 22:44:18 GMT
I have 2 failing tests left on wp7 due to a lack of support for window.btoa
The current FileTransfer.js implementation of getBasicAuthHeader relies on
window.btoa otherwise it does nothing.

There is no reason the conversion could not be done in native code,
presumably faster and easier, so I am wondering why someone chose to just
return null if the window did not have the method.
I also cannot easily override/clobber this method, since it is essentially
private.

(note all tests pass on wp8, which uses ie10.  wp7 is eternally ie9)

I have several options for fixing this, each with their own
strengths/weaknesses

a. polyfill window.btoa ( and atob ) using [1]
b. fix the js implementation so it will pass username:password on to
native, if it cannot pass base64 encoded data. ( this means changing the
common FileTransfer.js )
c. provide a different implementation in js for windows phone ( using a
windows phone only version of FileTransfer.js and clobbering )
d. some sort of mixture of the above, like polyfill via plugin.xml so we
can only include the polyfill in wp7

Thinking through this while writing it, I am thinking d. makes the most
sense, although it should probably be done by the File plugin, which needs
it also, and is a dependency of FileTransfer anyway.

Any other thoughts, platform specific considerations here?



[1] https://github.com/davidchambers/Base64.js/blob/master/LICENSE

@purplecabbage
risingj.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message