@@ -171,6 +171,39 @@ module.exports = {
171171 SyntaxError
172172 ) ;
173173
174+ // partial padding
175+ s2t [ 'throws' ] (
176+ function ( ) { method ( 'ZXhhZg=' ) ; } ,
177+ SyntaxError
178+ ) ;
179+ s2t [ 'throws' ] (
180+ function ( ) { method ( 'ZXhhZg=' , { lastChunkHandling : 'loose' } ) ; } ,
181+ SyntaxError
182+ ) ;
183+ s2t . deepEqual ( method ( 'ZXhhZg=' , { lastChunkHandling : 'stop-before-partial' } ) , new Uint8Array ( [ 101 , 120 , 97 ] ) ) ;
184+ s2t [ 'throws' ] (
185+ function ( ) { method ( 'ZXhhZg=' , { lastChunkHandling : 'strict' } ) ; } ,
186+ SyntaxError
187+ ) ;
188+
189+ // excess padding
190+ s2t [ 'throws' ] (
191+ function ( ) { method ( 'ZXhhZg===' ) ; } ,
192+ SyntaxError
193+ ) ;
194+ s2t [ 'throws' ] (
195+ function ( ) { method ( 'ZXhhZg===' , { lastChunkHandling : 'loose' } ) ; } ,
196+ SyntaxError
197+ ) ;
198+ s2t [ 'throws' ] (
199+ function ( ) { method ( 'ZXhhZg===' , { lastChunkHandling : 'stop-before-partial' } ) ; } ,
200+ SyntaxError
201+ ) ;
202+ s2t [ 'throws' ] (
203+ function ( ) { method ( 'ZXhhZg===' , { lastChunkHandling : 'strict' } ) ; } ,
204+ SyntaxError
205+ ) ;
206+
174207 s2t . end ( ) ;
175208 } ) ;
176209
@@ -194,6 +227,16 @@ module.exports = {
194227 ) ;
195228 s2t . deepEqual ( results ( ) , [ ] ) ;
196229
230+ s2t [ 'throws' ] (
231+ function ( ) { method ( 'Zg==' , { alphabet : Object ( 'base64' ) } ) ; } ,
232+ TypeError
233+ ) ;
234+
235+ s2t [ 'throws' ] (
236+ function ( ) { method ( 'Zg==' , { lastChunkHandling : Object ( 'loose' ) } ) ; } ,
237+ TypeError
238+ ) ;
239+
197240 s2t . test ( 'getters' , { skip : ! defineProperties . supportsDescriptors } , function ( s3t ) {
198241 var base64UrlOptions = { } ;
199242 var alphabetResults = s3t . intercept ( base64UrlOptions , 'alphabet' , { get : function ( ) { return 'base64url' ; } } ) ;
@@ -246,6 +289,7 @@ module.exports = {
246289 forEach ( standardBase64Vectors , function ( pair ) {
247290 var arr = method ( pair [ 0 ] ) ;
248291 s2t . equal ( getProto ( arr ) , Uint8Array . prototype , 'decoding ' + pair [ 0 ] ) ;
292+ s2t . equal ( arr . buffer . byteLength , pair [ 1 ] . length , 'decoding ' + pair [ 0 ] ) ;
249293 s2t . deepEqual ( arr , new Uint8Array ( pair [ 1 ] ) , 'decoding ' + pair [ 0 ] ) ;
250294 } ) ;
251295
@@ -303,6 +347,9 @@ module.exports = {
303347 ] ;
304348 forEach ( whitespaceKinds , function ( pair ) {
305349 var arr = method ( pair [ 0 ] ) ;
350+
351+ s2t . equal ( arr . length , 1 ) ;
352+ s2t . equal ( arr . buffer . byteLength , 1 ) ;
306353 s2t . deepEqual ( arr , new Uint8Array ( [ 102 ] ) , 'ascii whitespace: ' + pair [ 1 ] ) ;
307354 } ) ;
308355
0 commit comments