mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 01:02:45 +00:00 
			
		
		
		
	LibWeb: Add test for valueAsNumber
This commit is contained in:
		
							parent
							
								
									3572a047d1
								
							
						
					
					
						commit
						d503fd51ec
					
				
					 2 changed files with 95 additions and 0 deletions
				
			
		|  | @ -0,0 +1,49 @@ | |||
| <input id="input-element" value="100" style="display: none;" /> | ||||
| <script src="../include.js"></script> | ||||
| <script> | ||||
|     test(() => { | ||||
|         const inputElement = document.getElementById("input-element"); | ||||
| 
 | ||||
|         const allInputTypes = [ | ||||
|             "hidden", | ||||
|             "text", | ||||
|             "search", | ||||
|             "tel", | ||||
|             "url", | ||||
|             "email", | ||||
|             "password", | ||||
|             "date", | ||||
|             "month", | ||||
|             "week", | ||||
|             "time", | ||||
|             "datetime-local", | ||||
|             "number", | ||||
|             "range", | ||||
|             "color", | ||||
|             "checkbox", | ||||
|             "radio", | ||||
|             "file", | ||||
|             "submit", | ||||
|             "image", | ||||
|             "reset", | ||||
|             "button", | ||||
|         ]; | ||||
| 
 | ||||
|         println("valueAsNumber getter:"); | ||||
|         for (const type of allInputTypes) { | ||||
|             inputElement.type = type; | ||||
|             println(`${type}: ${inputElement.valueAsNumber}`); | ||||
|         } | ||||
| 
 | ||||
|         println("valueAsNumber setter:"); | ||||
|         for (const type of allInputTypes) { | ||||
|             try { | ||||
|                 inputElement.type = type; | ||||
|                 inputElement.valueAsNumber = 100; | ||||
|                 println(`${type} did not throw: ${inputElement.valueAsNumber}`); | ||||
|             } catch (e) { | ||||
|                 println(`${type} threw exception: ${e.name}: ${e.message}`); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| </script> | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Luke Wilde
						Luke Wilde