2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <title>Test for OffscreenCanvas TransferToImageBitmap
</title>
11 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
12 <script src=
"../../js/js-test-pre.js"></script>
13 <script src=
"../../js/webgl-test-utils.js"></script>
14 <script src=
"../../js/tests/tex-image-and-sub-image-utils.js"></script>
15 <script src=
"../../js/tests/offscreencanvas-transfer-image-bitmap.js"></script>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <script id='myWorker' type='text/worker'
>
21 self.onmessage = function(e) {
22 var canvas = new OffscreenCanvas(
128,
128);
23 var gl = canvas.getContext(
"webgl2");
24 gl.clearColor(
1.0,
1.0,
0.0,
1.0);
25 gl.clear(gl.COLOR_BUFFER_BIT);
26 var image = canvas.transferToImageBitmap();
28 self.postMessage({ bitmap: image },
34 description("This test ensures that the transferToImageBitmap function of OffscreenCanvas webgl2 context is functional.");
35 if (!window
.OffscreenCanvas
) {
36 testPassed("No OffscreenCanvas support");
39 var blob
= new Blob([document
.getElementById('myWorker').textContent
]);
40 var worker
= new Worker(URL
.createObjectURL(blob
));
42 worker
.onmessage = function(msg
) {
43 testTransferToImageBitmap("webgl2", msg
.data
.bitmap
);
46 worker
.postMessage("Start Worker");