4 <script type=
"application/javascript">
6 function ok(expect, msg) {
7 window.parent.postMessage({
"type":
"status", status: !!expect, msg},
"*");
10 window.onmessage = function(event) {
11 ok(!!event.data.bitmap1,
"Get the 1st ImageBitmap from the main script.");
12 ok(!!event.data.bitmap2,
"Get the 2st ImageBitmap from the main script.");
14 // send the first original ImageBitmap back to the main window
15 window.parent.postMessage({
"type":
"bitmap1",
"bitmap":event.data.bitmap1},
"*");
17 // create a new ImageBitmap from the
2nd original ImageBitmap
18 // and then send the newly created ImageBitmap back to the main window
19 var promise = createImageBitmap(event.data.bitmap2);
22 ok(true,
"Successfully create a new ImageBitmap from the 2nd original bitmap in worker.");
24 // send the newly created ImageBitmap back to the main window
25 window.parent.postMessage({
"type":
"bitmap2",
"bitmap":bitmap},
"*");
28 window.parent.postMessage({
"type":
"finish"},
"*");
31 ok(false,
"Cannot create a new bitmap from the original bitmap in worker.");