blob: e881b63c0d1e52d926029c1165e6cee65f3e4559 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
function createCanvas(width, height) {
var canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
return canvas;
}
test(function() {
var width = 50;
var height = 50;
var canvas1 = createCanvas(width, height);
var offscreenCanvas1;
try {
offscreenCanvas1 = canvas1.transferControlToOffscreen();
assert_equals(offscreenCanvas1.width, width);
assert_equals(offscreenCanvas1.height, height);
} catch (ex) {
assert_false(ex.message);
}
}, "Tests whether transferControlToOffscreen can be run correctly.");
test(function() {
var canvas2 = createCanvas(50, 50);
var offscreenCanvas2;
var ctx = canvas2.getContext("2d");
assert_throws("InvalidStateError", function() {
offscreenCanvas2 = canvas2.transferControlToOffscreen();
assert_false("transferControlToOffscreen from a canvas with context didn't throw an exception.");
}, "transferControlToOffscreen from a canvas with context throws an exception");
}, "Tests whether transferControlToOffscreen throws exception correctly.");
test(function() {
var canvas3 = createCanvas(10, 10);
var offscreenCanvas3 = canvas3.transferControlToOffscreen();
assert_equals(offscreenCanvas3.width, 10);
assert_equals(offscreenCanvas3.height, 10);
assert_throws("InvalidStateError", function() { offscreenCanvas3.width = 20; });
assert_throws("InvalidStateError", function() { offscreenCanvas3.height = 20; });
}, "Test if resizing on offscreencanvas transferred from html canvas has thrown exceptions.");
</script>
</body>
</html>