mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 01:32:45 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <script>
 | |
|     test(() => {
 | |
|         let testCounter = 1;
 | |
|         function testPart(part) {
 | |
|             try {
 | |
|                 println(`${testCounter}. ${JSON.stringify(part())}`);
 | |
|             } catch (e) {
 | |
|                 println(`${testCounter}. Exception: ${e.name}`);
 | |
|             }
 | |
|             testCounter++;
 | |
|         }
 | |
| 
 | |
|         for (const Rect of [DOMRect, DOMRectReadOnly]) {
 | |
|             println(`Testing ${Rect.name}:`);
 | |
|             
 | |
|             // 1. Creating a DOMRect with no arguments
 | |
|             testPart(() => new Rect());
 | |
| 
 | |
|             // 2. Creating a DOMRect with positive x, y, width and height
 | |
|             testPart(() => new Rect(10, 20, 30, 40));
 | |
| 
 | |
|             // 3. Creating a DOMRect with negative x and y values
 | |
|             testPart(() => new Rect(-10, -20, 30, 40));
 | |
| 
 | |
|             // 4. Creating a DOMRect with DOMRect.fromRect()
 | |
|             testPart(() => Rect.fromRect({ x: 10, y: 20, width: 30, height: 40 }));
 | |
| 
 | |
|             // 5. Creating a DOMRect with NaN x value
 | |
|             testPart(() => new Rect(NaN, 20, 30, 40));
 | |
| 
 | |
|             // 6. Creating a DOMRect with NaN y value
 | |
|             testPart(() => new Rect(10, NaN, 30, 40));
 | |
| 
 | |
|             // 7. Creating a DOMRect with NaN width value
 | |
|             testPart(() => new Rect(10, 20, NaN, 40));
 | |
| 
 | |
|             // 8. Creating a DOMRect with NaN height value
 | |
|             testPart(() => new Rect(10, 20, 30, NaN));
 | |
| 
 | |
|             testCounter = 1;
 | |
|         }
 | |
|     });
 | |
| </script>
 | 
