OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> |
| 4 description("Tests that the OffScreenCanvas can handle invalid arguments"); |
| 5 |
| 6 // Since blink uses signed int internally, this case tests how the constructor |
| 7 // responds to the arguments that are larger than INT_MAX which would cause |
| 8 // overflow. The current implementation is expected to clamp. |
| 9 var setWidth = Math.pow(2, 31); |
| 10 var setHeight = Math.pow(2, 31); |
| 11 var obj = {Name: "John Doe", Age: 30}; |
| 12 |
| 13 var canvas1 = new OffScreenCanvas(setWidth, setHeight); |
| 14 shouldBe("canvas1.width", "setWidth-1"); |
| 15 shouldBe("canvas1.height", "setHeight-1"); |
| 16 |
| 17 canvas1.width = null; |
| 18 canvas1.height = null; |
| 19 shouldBe("canvas1.width", "0"); |
| 20 shouldBe("canvas1.height", "0"); |
| 21 |
| 22 shouldThrow("new OffScreenCanvas(-1, -1)"); |
| 23 |
| 24 var canvas2 = new OffScreenCanvas(null, null); |
| 25 shouldBe("canvas2.width", "0"); |
| 26 shouldBe("canvas2.height", "0"); |
| 27 |
| 28 canvas2.width = setWidth; |
| 29 canvas2.height = setHeight; |
| 30 shouldBe("canvas2.width", "setWidth-1"); |
| 31 shouldBe("canvas2.height", "setHeight-1"); |
| 32 |
| 33 shouldThrow("canvas2.width = -1"); |
| 34 shouldThrow("canvas2.height = -1"); |
| 35 |
| 36 shouldThrow("canvas2.width = obj"); |
| 37 shouldThrow("canvas2.height = obj"); |
| 38 |
| 39 shouldThrow("new OffScreenCanvas(obj, obj)"); |
| 40 </script> |
OLD | NEW |