blob: 766022e2d38878d21dd2acbb97efe8f0d747b309 [file] [log] [blame]
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src = "./script-tests/canvas-toBlob-toDataURL-race.js"></script>
<script>
test(function(t) {
createAllTestCases(t);
//Fire a bunch of toBlob operations of canvas to keep the async thread busy
var j = 0; // due to async nature of toBlob we need a separate counter
for (var i = 0; i < numToBlobCalls; i++)
{
canvas.toBlob(function(blob) {
url = URL.createObjectURL(blob);
testImages[j++].src = url;
}, "image/webp", 1.0);
}
//Then file a bunch of toDataURL operation on main thread, so both threads now compete for image encoding
for (var i = numToBlobCalls; i < (numToDataURLCalls + numToBlobCalls); i++)
{
testImages[i].src = canvas.toDataURL("image/webp", 1.0);
}
}, "Verifies if WEBP image encoding on main thread (toDataURL) conflicts with image encoding on async thread (toBlob)");
</script>