mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:52:43 +00:00 
			
		
		
		
	 eb6a7ccc59
			
		
	
	
		eb6a7ccc59
		
	
	
	
	
		
			
			This verifies that XHR.open() throws a Syntax Error if an illegal token is passed to the method argument.
		
			
				
	
	
		
			20 lines
		
	
	
	
		
			555 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
	
		
			555 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <script>
 | |
|     test(() => {
 | |
|         const SYNTAX_ERR = 12;
 | |
|         const illegalTokens = "\"(),/:;<=>?@[\\]{}";
 | |
|         let i = 0;
 | |
|         for (const token of illegalTokens) {
 | |
|             const xhr = new XMLHttpRequest();
 | |
|             try {
 | |
|                 xhr.open(token, "data:text/plain,", true);
 | |
|             }
 | |
|             catch (e) {
 | |
|                 if (e.code === SYNTAX_ERR)
 | |
|                     i += 1;
 | |
|             }
 | |
|         }
 | |
|         if (i === illegalTokens.length)
 | |
|             println("PASS");
 | |
|     });
 | |
| </script>
 |