1 function ok(expect, msg) {
2 postMessage({ type: "status", status: !!expect, msg });
5 onmessage = function (event) {
6 ok(!!event.data.bitmap1, "Get the 1st ImageBitmap from the main script.");
7 ok(!!event.data.bitmap2, "Get the 2nd ImageBitmap from the main script.");
8 ok(!!event.data.bitmap3, "Get the 3rd ImageBitmap from the main script.");
10 // send the first original ImageBitmap back to the main-thread
11 postMessage({ type: "bitmap1", bitmap: event.data.bitmap1 });
13 // create a new ImageBitmap from the 2nd original ImageBitmap
14 // and then send the newly created ImageBitmap back to the main-thread
15 var promise = createImageBitmap(event.data.bitmap2);
20 "Successfully create a new ImageBitmap from the 2nd original bitmap in worker."
23 // send the newly created ImageBitmap back to the main-thread
24 postMessage({ type: "bitmap2", bitmap });
27 postMessage({ type: "finish" });
32 "Cannot create a new bitmap from the original bitmap in worker."
37 // send the third original ImageBitmap back to the main-thread
38 postMessage({ type: "bitmap3", bitmap: event.data.bitmap3 });