mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:52:46 +00:00 
			
		
		
		
	 debb5690ce
			
		
	
	
		debb5690ce
		
	
	
	
	
		
			
			This implements enough to represent <input type=image> with its loaded source image (or fallback to its alt text, if applicable). This does not implement acquring coordinates from user-activated click events on the image.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			991 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			991 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="./include.js"></script>
 | |
| <script type="text/javascript">
 | |
|     const SOURCES = ["../../Layout/input/120.png", "file:///i-do-no-exist-i-swear.png"];
 | |
| 
 | |
|     const runTest = source => {
 | |
|         let input = document.createElement("input");
 | |
|         input.type = "image";
 | |
|         input.alt = "submit";
 | |
| 
 | |
|         return new Promise((resolve, reject) => {
 | |
|             input.addEventListener("load", () => {
 | |
|                 resolve(`${input.src} loaded`);
 | |
|             });
 | |
|             input.addEventListener("error", () => {
 | |
|                 resolve(`${input.src} failed`);
 | |
|             });
 | |
| 
 | |
|             input.setAttribute("src", source);
 | |
|         });
 | |
|     };
 | |
| 
 | |
|     asyncTest(done => {
 | |
|         let promises = SOURCES.map(source => runTest(source));
 | |
| 
 | |
|         Promise.allSettled(promises)
 | |
|             .then(results => results.map(result => result.value))
 | |
|             .then(results => results.sort())
 | |
|             .then(results => results.forEach(println))
 | |
|             .finally(done);
 | |
|     });
 | |
| </script>
 |