OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 | 8 |
9 description("Test transferControlToOffscreen."); | 9 description("Test transferControlToOffscreen."); |
10 window.jsTestIsAsync = true; | 10 window.jsTestIsAsync = true; |
11 | 11 |
| 12 function createCanvas(width, height) { |
| 13 var canvas = document.createElement("canvas"); |
| 14 canvas.width = width; |
| 15 canvas.height = height; |
| 16 return canvas; |
| 17 } |
| 18 |
| 19 // Tests whether transferControlToOffscreen can be run correctly. |
12 var width = 50; | 20 var width = 50; |
13 var height = 50; | 21 var height = 50; |
14 var canvas = document.createElement("canvas"); | 22 var canvas1 = createCanvas(width, height); |
15 canvas.width = width; | 23 var offscreenCanvas1; |
16 canvas.height = height; | 24 try { |
| 25 offscreenCanvas1 = canvas1.transferControlToOffscreen(); |
| 26 testPassed("Successfully created layer for offscreencanvas"); |
| 27 shouldBe("offscreenCanvas1.width", "width"); |
| 28 shouldBe("offscreenCanvas1.height", "height"); |
| 29 } catch (ex) { |
| 30 testFailed(ex.message); |
| 31 } |
17 | 32 |
18 var offscreenCanvas = canvas.transferControlToOffscreen(); | 33 // Tests whether transferControlToOffscreen throws exception correctly. |
19 shouldBe("offscreenCanvas.width", "width"); | 34 var canvas2 = createCanvas(50, 50); |
20 shouldBe("offscreenCanvas.height", "height"); | 35 var offscreenCanvas2; |
21 | 36 var ctx = canvas2.getContext("2d"); |
22 var ctx = canvas.getContext("2d"); | |
23 try { | 37 try { |
24 offscreenCanvas = canvas.transferControlToOffscreen(); | 38 offscreenCanvas2 = canvas2.transferControlToOffscreen(); |
25 testFailed("transferControlToOffscreen from a canvas with context didn't thr
ow an exception."); | 39 testFailed("transferControlToOffscreen from a canvas with context didn't thr
ow an exception."); |
26 } catch (ex) { | 40 } catch (ex) { |
27 testPassed("transferControlToOffscreen from a canvas with context throws an
exception: " + ex); | 41 testPassed("transferControlToOffscreen from a canvas with context throws an
exception: " + ex); |
28 } | 42 } |
29 | 43 |
30 finishJSTest(); | 44 finishJSTest(); |
31 </script> | 45 </script> |
32 </body> | 46 </body> |
33 </html> | 47 </html> |
OLD | NEW |