forked from mirrors/gecko-dev
		
	 62a6b8f656
			
		
	
	
		62a6b8f656
		
	
	
	
	
		
			
			Automatic update from web-platform-tests TextDecoder: Passing explicit undefined to decode() Test various permutations of passing explicit undefined to decode(), which has two optional arguments. Chrome's binding layer had incorrect behavior here, which wasn't tested. Bug: 1172968 Change-Id: I6f20caa5db5505192cb8eb4b27e251bf7f42117b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2686917 Commit-Queue: Yuki Shiino <yukishiino@chromium.org> Auto-Submit: Joshua Bell <jsbell@chromium.org> Reviewed-by: Yuki Shiino <yukishiino@chromium.org> Cr-Commit-Position: refs/heads/master@{#853395} -- wpt-commits: 35f70910d3753c8b650fdfd4c716caedfefe88c9 wpt-pr: 27580
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| // META: title=Encoding API: TextDecoder decode() optional arguments
 | |
| 
 | |
| test(t => {
 | |
|   const decoder = new TextDecoder();
 | |
| 
 | |
|   // Just passing nothing.
 | |
|   assert_equals(
 | |
|     decoder.decode(undefined), '',
 | |
|     'Undefined as first arg should decode to empty string');
 | |
| 
 | |
|   // Flushing an incomplete sequence.
 | |
|   decoder.decode(new Uint8Array([0xc9]), {stream: true});
 | |
|   assert_equals(
 | |
|     decoder.decode(undefined), '\uFFFD',
 | |
|     'Undefined as first arg should flush the stream');
 | |
| 
 | |
| }, 'TextDecoder decode() with explicit undefined');
 | |
| 
 | |
| test(t => {
 | |
|   const decoder = new TextDecoder();
 | |
| 
 | |
|   // Just passing nothing.
 | |
|   assert_equals(
 | |
|     decoder.decode(undefined, undefined), '',
 | |
|     'Undefined as first arg should decode to empty string');
 | |
| 
 | |
|   // Flushing an incomplete sequence.
 | |
|   decoder.decode(new Uint8Array([0xc9]), {stream: true});
 | |
|   assert_equals(
 | |
|     decoder.decode(undefined, undefined), '\uFFFD',
 | |
|     'Undefined as first arg should flush the stream');
 | |
| 
 | |
| }, 'TextDecoder decode() with undefined and undefined');
 | |
| 
 | |
| test(t => {
 | |
|   const decoder = new TextDecoder();
 | |
| 
 | |
|   // Just passing nothing.
 | |
|   assert_equals(
 | |
|     decoder.decode(undefined, {}), '',
 | |
|     'Undefined as first arg should decode to empty string');
 | |
| 
 | |
|   // Flushing an incomplete sequence.
 | |
|   decoder.decode(new Uint8Array([0xc9]), {stream: true});
 | |
|   assert_equals(
 | |
|     decoder.decode(undefined, {}), '\uFFFD',
 | |
|     'Undefined as first arg should flush the stream');
 | |
| 
 | |
| }, 'TextDecoder decode() with undefined and options');
 |