blob: 97944a2caba6c0c0cb200f9df19fc7bcb9968acc [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Test OffscreenCanvas transferable with exception cases.");
var worker = new Worker('./resources/OffscreenCanvas-transferable.js');
var width = 50;
var height = 50;
var offscreenCanvas1 = new OffscreenCanvas(width, height);
var ctx;
shouldNotThrow("ctx = offscreenCanvas1.getContext('2d')");
shouldBeType("ctx", "OffscreenCanvasRenderingContext2D");
shouldThrow("worker.postMessage({data: offscreenCanvas1}, [offscreenCanvas1])");
var offscreenCanvas2 = new OffscreenCanvas(width, height);
worker.postMessage({data: offscreenCanvas2}, [offscreenCanvas2]);
shouldThrow("offscreenCanvas2.transferToImageBitmap()");
shouldThrow("worker.postMessage({data: offscreenCanvas2}, [offscreenCanvas2])");
shouldThrow("offscreenCanvas2.getContext('2d')");
// using a transferred OffscreenCanvas as a source image throws.
shouldThrow("ctx.drawImage(offscreenCanvas2, 0, 0)");
finishJSTest();
</script>
</body>
</html>