Chromium Code Reviews| 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> |
|
fs
2016/08/23 08:50:58
OffscreenCanvas
sivag
2016/08/25 07:39:01
Done.
| |
| 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 length/width change | |
|
fs
2016/08/23 08:50:57
Add full stops ('.') at end up sentences - here an
sivag
2016/08/25 07:39:01
Done.
| |
| 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; |
| 22 ctx = aCanvas.getContext('2d'); | |
|
fs
2016/08/23 08:50:57
Maybe merge this with the previous line.
sivag
2016/08/25 07:39:01
Done.
| |
| 23 assert_true(ctx instanceof OffscreenCanvasRenderingContext2D); | |
|
fs
2016/08/23 08:50:57
Double space after instanceof.
sivag
2016/08/25 07:39:01
Done.
| |
| 24 // Calling getContext on a different context type will return null | |
| 25 var ctx2 = aCanvas.getContext("webgl"); | |
| 26 assert_equals(ctx2, null); | |
| 18 | 27 |
| 19 // Tests object type of getContext('2d') | 28 // Calling getContext on the same context type will return the original cont ext type |
| 20 var ctx; | 29 var ctx3 = aCanvas.getContext("2d"); |
| 21 shouldNotThrow("ctx = aCanvas.getContext('2d')"); | 30 assert_not_equals(ctx3, null); |
| 22 shouldBeType("ctx", "OffscreenCanvasRenderingContext2D"); | 31 assert_true(ctx3 == ctx); |
|
Srirama
2016/08/23 06:34:24
use assert_equals
sivag
2016/08/25 07:39:01
Done.
| |
| 23 | 32 |
| 24 // Calling getContext on a different context type will return null | 33 // TODO: change the below part of the test when webgl is supported. |
|
Justin Novosad
2016/08/23 15:53:00
This comment is no longer relevant. WebGL works no
sivag
2016/08/25 07:39:01
Done.
| |
| 25 var ctx2 = aCanvas.getContext("webgl"); | 34 // Calling getContext on an unimplemented context type will return null |
| 26 shouldBeNull("ctx2"); | 35 var bCanvas = new OffscreenCanvas(20, 20); |
| 27 | 36 var ctx4 = bCanvas.getContext("webgl"); |
| 28 // Calling getContext on the same context type will return the original context type | 37 assert_true(ctx4 instanceof WebGLRenderingContext); |
| 29 var ctx3 = aCanvas.getContext("2d"); | 38 }); |
| 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> | 39 </script> |
| OLD | NEW |