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/testharness.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
5 <script src="../../resources/testharnessreport.js"></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 function createCanvas(width, height) { | 9 function createCanvas(width, height) { |
10 var canvas = document.createElement("canvas"); | 10 var canvas = document.createElement("canvas"); |
(...skipping 10 matching lines...) Expand all Loading... |
21 try { | 21 try { |
22 offscreenCanvas1 = canvas1.transferControlToOffscreen(); | 22 offscreenCanvas1 = canvas1.transferControlToOffscreen(); |
23 assert_equals(offscreenCanvas1.width, width); | 23 assert_equals(offscreenCanvas1.width, width); |
24 assert_equals(offscreenCanvas1.height, height); | 24 assert_equals(offscreenCanvas1.height, height); |
25 } catch (ex) { | 25 } catch (ex) { |
26 assert_false(ex.message); | 26 assert_false(ex.message); |
27 } | 27 } |
28 }, "Tests whether transferControlToOffscreen can be run correctly."); | 28 }, "Tests whether transferControlToOffscreen can be run correctly."); |
29 | 29 |
30 test(function() { | 30 test(function() { |
31 var canvas2 = createCanvas(50, 50); | 31 var canvas2a = createCanvas(50, 50); |
32 var offscreenCanvas2; | 32 var offscreenCanvas2a; |
33 var ctx = canvas2.getContext("2d"); | 33 var ctx = canvas2a.getContext("2d"); |
34 assert_throws("InvalidStateError", function() { | 34 assert_throws("InvalidStateError", function() { |
35 offscreenCanvas2 = canvas2.transferControlToOffscreen(); | 35 offscreenCanvas2a = canvas2a.transferControlToOffscreen(); |
36 assert_false("transferControlToOffscreen from a canvas with context didn
't throw an exception."); | 36 assert_false("transferControlToOffscreen from a canvas with context didn
't throw an exception."); |
37 }, "transferControlToOffscreen from a canvas with context throws an exceptio
n"); | 37 }, "transferControlToOffscreen from a canvas with context throws an exceptio
n"); |
| 38 |
| 39 var canvas2b = createCanvas(10, 10); |
| 40 var offscreenCanvas2b = canvas2b.transferControlToOffscreen(); |
| 41 assert_throws("InvalidStateError", function() { |
| 42 var anotherOffscreenCanvas = canvas2b.transferControlToOffscreen(); |
| 43 }, "canvas.transferControlToOffscreen() is not allowed to called more than o
nce for the same canvas."); |
38 }, "Tests whether transferControlToOffscreen throws exception correctly."); | 44 }, "Tests whether transferControlToOffscreen throws exception correctly."); |
39 | 45 |
40 test(function() { | 46 test(function() { |
41 var canvas3 = createCanvas(10, 10); | 47 var canvas3 = createCanvas(10, 10); |
42 var offscreenCanvas3 = canvas3.transferControlToOffscreen(); | 48 var offscreenCanvas3 = canvas3.transferControlToOffscreen(); |
43 assert_equals(offscreenCanvas3.width, 10); | 49 assert_equals(offscreenCanvas3.width, 10); |
44 assert_equals(offscreenCanvas3.height, 10); | 50 assert_equals(offscreenCanvas3.height, 10); |
45 assert_throws("InvalidStateError", function() { offscreenCanvas3.width = 20;
}); | 51 assert_throws("InvalidStateError", function() { offscreenCanvas3.width = 20;
}); |
46 assert_throws("InvalidStateError", function() { offscreenCanvas3.height = 20
; }); | 52 assert_throws("InvalidStateError", function() { offscreenCanvas3.height = 20
; }); |
47 }, "Test if resizing on offscreencanvas transferred from html canvas has thrown
exceptions."); | 53 }, "Test if resizing on offscreencanvas transferred from html canvas has thrown
exceptions."); |
(...skipping 14 matching lines...) Expand all Loading... |
62 canvas4.toBlob(function() {}); | 68 canvas4.toBlob(function() {}); |
63 }, "canvas.toBlob is not allowed after transferring control to offscreen."); | 69 }, "canvas.toBlob is not allowed after transferring control to offscreen."); |
64 assert_throws("InvalidStateError", function() { | 70 assert_throws("InvalidStateError", function() { |
65 canvas4.toDataURL(); | 71 canvas4.toDataURL(); |
66 }, "canvas.toDataURL is not allowed after transferring control to offscreen.
"); | 72 }, "canvas.toDataURL is not allowed after transferring control to offscreen.
"); |
67 }, "Test if modifying canvas after it transfers controls to offscreen throw exce
ptions"); | 73 }, "Test if modifying canvas after it transfers controls to offscreen throw exce
ptions"); |
68 | 74 |
69 </script> | 75 </script> |
70 </body> | 76 </body> |
71 </html> | 77 </html> |
OLD | NEW |