summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-png.html
blob: 3bbcaa76aa565aabead35ea57dd5e4a150c0b261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script src = "../../resources/js-test.js"></script>
<script src = "script-tests/canvas-toBlob-toDataURL-race.js"></script>
<script type = 'text/javascript'>
description("Verifies if synchronous PNG image encoding (toDataURL) conflicts with asynchronous image encoding (toBlob)");

//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;
    });
}

//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();
}
</script>