| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../resources/js-test.js"></script> |
| </head> |
| <body> |
| <script> |
| |
| description("Test transferControlToOffscreen."); |
| window.jsTestIsAsync = true; |
| |
| function createCanvas(width, height) { |
| var canvas = document.createElement("canvas"); |
| canvas.width = width; |
| canvas.height = height; |
| return canvas; |
| } |
| |
| // Tests whether transferControlToOffscreen can be run correctly. |
| var width = 50; |
| var height = 50; |
| var canvas1 = createCanvas(width, height); |
| var offscreenCanvas1; |
| try { |
| offscreenCanvas1 = canvas1.transferControlToOffscreen(); |
| testPassed("Successfully created layer for offscreencanvas"); |
| shouldBe("offscreenCanvas1.width", "width"); |
| shouldBe("offscreenCanvas1.height", "height"); |
| } catch (ex) { |
| testFailed(ex.message); |
| } |
| |
| // Tests whether transferControlToOffscreen throws exception correctly. |
| var canvas2 = createCanvas(50, 50); |
| var offscreenCanvas2; |
| var ctx = canvas2.getContext("2d"); |
| try { |
| offscreenCanvas2 = canvas2.transferControlToOffscreen(); |
| testFailed("transferControlToOffscreen from a canvas with context didn't throw an exception."); |
| } catch (ex) { |
| testPassed("transferControlToOffscreen from a canvas with context throws an exception: " + ex); |
| } |
| |
| finishJSTest(); |
| </script> |
| </body> |
| </html> |