OLD | NEW |
(Empty) | |
| 1 <script src = "../../resources/js-test.js"></script> |
| 2 <script src = "./script-tests/canvas-toBlob-toDataURL-race.js"></script> |
| 3 <script type = 'text/javascript'> |
| 4 description("Verifies if JPEG image encoding on main thread (toDataURL) conflict
s with image encoding on async thread (toBlob)"); |
| 5 |
| 6 //Fire a bunch of toBlob operations of canvas to keep the async thread busy |
| 7 var j = 0; // due to async nature of toBlob we need a separate counter |
| 8 for (var i = 0; i < numToBlobCalls; i++) |
| 9 { |
| 10 canvas.toBlob(function(blob) { |
| 11 url = URL.createObjectURL(blob); |
| 12 testImages[j++].src = url; |
| 13 }, "image/jpeg", 1.0); |
| 14 } |
| 15 |
| 16 //Then file a bunch of toDataURL operation on main thread, so both threads now c
ompete for image encoding |
| 17 for (var i = numToBlobCalls; i < (numToDataURLCalls + numToBlobCalls); i++) |
| 18 { |
| 19 testImages[i].src = canvas.toDataURL("image/jpeg", 1.0); |
| 20 } |
| 21 </script> |
OLD | NEW |