OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> |
| 4 description("Tests basic functionalities of offscreenCanvas.getContext on the ma
in thread"); |
| 5 |
| 6 // Tests onstructor of OffscreenCanvas and length/width change |
| 7 var aCanvas = new OffscreenCanvas(40, 60); |
| 8 shouldBe("aCanvas.width", "40"); |
| 9 shouldBe("aCanvas.height", "60"); |
| 10 |
| 11 aCanvas.width = 110; |
| 12 aCanvas.height = 90; |
| 13 shouldBe("aCanvas.width", "110"); |
| 14 shouldBe("aCanvas.height", "90"); |
| 15 |
| 16 aCanvas.width = 0; // Zero dimension is allowed |
| 17 shouldBe("aCanvas.width", "0"); |
| 18 |
| 19 // Tests object type of getContext('2d') |
| 20 var ctx; |
| 21 shouldNotThrow("ctx = aCanvas.getContext('2d')"); |
| 22 shouldBeType("ctx", "OffscreenCanvasRenderingContext2D"); |
| 23 |
| 24 // Calling getContext on a different context type will return null |
| 25 var ctx2 = aCanvas.getContext("webgl"); |
| 26 shouldBeNull("ctx2"); |
| 27 |
| 28 // Calling getContext on the same context type will return the original context
type |
| 29 var ctx3 = aCanvas.getContext("2d"); |
| 30 shouldBeNonNull("ctx3"); |
| 31 shouldBeTrue("ctx3 == ctx"); |
| 32 |
| 33 // TODO: change the below part of the test when webgl is supported. |
| 34 // Calling getContext on an unimplemented context type will return null |
| 35 var bogusCanvas = new OffscreenCanvas(20, 20); |
| 36 var bogusCtx = bogusCanvas.getContext("webgl"); |
| 37 shouldBeNull("bogusCtx"); |
| 38 </script> |
OLD | NEW |