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