imagebitmap_structuredclone_iframe.html (1282B)
1 <!DOCTYPE HTML> 2 <meta charset="utf-8"> 3 <body> 4 <script type="application/javascript"> 5 6 function ok(expect, msg) { 7 window.parent.postMessage({"type": "status", status: !!expect, msg}, "*"); 8 } 9 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."); 13 14 // send the first original ImageBitmap back to the main window 15 window.parent.postMessage({"type":"bitmap1", "bitmap":event.data.bitmap1}, "*"); 16 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); 20 promise.then( 21 function(bitmap) { 22 ok(true, "Successfully create a new ImageBitmap from the 2nd original bitmap in worker."); 23 24 // send the newly created ImageBitmap back to the main window 25 window.parent.postMessage({"type":"bitmap2", "bitmap":bitmap}, "*"); 26 27 // finish the test 28 window.parent.postMessage({"type": "finish"}, "*"); 29 }, 30 function() { 31 ok(false, "Cannot create a new bitmap from the original bitmap in worker."); 32 } 33 ); 34 } 35 36 37 </script> 38 </body>