| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> | 2 <title>Tests basic functionalities of OffscreenCanvas.getContext on the main thr
ead.</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 3 <script> | 5 <script> |
| 4 description("Tests basic functionalities of offscreenCanvas.getContext on the ma
in thread"); | 6 test(function() { |
| 7 // Tests constructor of OffscreenCanvas and height/width change. |
| 8 var aCanvas = new OffscreenCanvas(40, 60); |
| 9 assert_equals(aCanvas.width, 40); |
| 10 assert_equals(aCanvas.height, 60); |
| 5 | 11 |
| 6 // Tests onstructor of OffscreenCanvas and length/width change | 12 aCanvas.width = 110; |
| 7 var aCanvas = new OffscreenCanvas(40, 60); | 13 aCanvas.height = 90; |
| 8 shouldBe("aCanvas.width", "40"); | 14 assert_equals(aCanvas.width, 110); |
| 9 shouldBe("aCanvas.height", "60"); | 15 assert_equals(aCanvas.height, 90); |
| 10 | 16 |
| 11 aCanvas.width = 110; | 17 aCanvas.width = 0; // Zero dimension is allowed. |
| 12 aCanvas.height = 90; | 18 assert_equals(aCanvas.width, 0); |
| 13 shouldBe("aCanvas.width", "110"); | |
| 14 shouldBe("aCanvas.height", "90"); | |
| 15 | 19 |
| 16 aCanvas.width = 0; // Zero dimension is allowed | 20 // Tests object type of getContext('2d'). |
| 17 shouldBe("aCanvas.width", "0"); | 21 var ctx = aCanvas.getContext('2d'); |
| 22 assert_true(ctx instanceof OffscreenCanvasRenderingContext2D); |
| 23 // Calling getContext on a different context type will return null. |
| 24 var ctx2 = aCanvas.getContext("webgl"); |
| 25 assert_equals(ctx2, null); |
| 18 | 26 |
| 19 // Tests object type of getContext('2d') | 27 // Calling getContext on the same context type will return the original cont
ext type. |
| 20 var ctx; | 28 var ctx3 = aCanvas.getContext("2d"); |
| 21 shouldNotThrow("ctx = aCanvas.getContext('2d')"); | 29 assert_not_equals(ctx3, null); |
| 22 shouldBeType("ctx", "OffscreenCanvasRenderingContext2D"); | 30 assert_equals(ctx3, ctx); |
| 23 | 31 |
| 24 // Calling getContext on a different context type will return null | 32 var bCanvas = new OffscreenCanvas(20, 20); |
| 25 var ctx2 = aCanvas.getContext("webgl"); | 33 var ctx4 = bCanvas.getContext("webgl"); |
| 26 shouldBeNull("ctx2"); | 34 assert_true(ctx4 instanceof WebGLRenderingContext); |
| 27 | 35 }); |
| 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 bCanvas = new OffscreenCanvas(20, 20); | |
| 36 var ctx4 = bCanvas.getContext("webgl"); | |
| 37 shouldBeType("ctx4", "WebGLRenderingContext"); | |
| 38 </script> | 36 </script> |
| OLD | NEW |