Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / canvas-createImageBitmap-out-of-bounds-src.html
bloba307dd8ad45a63619fc73c6ecd7452afdb8e2122
1 <html>
2 <body>
3 <canvas id="c1" width="250" height="250"></canvas>
4 <canvas id="c2" width="250" height="250"></canvas>
5 <br>
6 <canvas id="c3" width="250" height="250"></canvas>
7 <canvas id="c4" width="250" height="250"></canvas>
8 <script type="text/javascript">
9 if (window.testRunner)
10 testRunner.waitUntilDone();
12 function shouldNotBeCalled() {
13 testFailed("Promise was rejected.");
14 finishJSTest();
17 var canvas1 = document.getElementById('c1');
18 var canvas2 = document.getElementById('c2');
19 var canvas3 = document.getElementById('c3');
20 var canvas4 = document.getElementById('c4');
21 var bgcanvas = document.createElement('canvas');
22 bgcanvas.width = 100;
23 bgcanvas.height = 100;
24 var bgctx = bgcanvas.getContext('2d');
25 bgctx.fillStyle = 'green';
26 bgctx.fillRect(0, 0, bgcanvas.width, bgcanvas.height);
27 var greenSquareURL = bgcanvas.toDataURL();
28 var img = new Image();
29 img.onload = imageLoaded;
30 img.src = greenSquareURL;
31 var ctx1 = canvas1.getContext('2d');
32 var ctx2 = canvas2.getContext('2d');
33 var ctx3 = canvas3.getContext('2d');
34 var ctx4 = canvas4.getContext('2d');
36 function imageLoaded() {
37 createImageBitmap(img).then(imageBitmapCallback(ctx1), shouldNotBeCalled);
38 createImageBitmap(img, -50, -50, 100, 100).then(imageBitmapCallback(ctx2), shouldNotBeCalled);
39 createImageBitmap(img, 50, 50, 100, 100).then(imageBitmapCallback(ctx3), shouldNotBeCalled);
40 createImageBitmap(img, -100, -100, 300, 300).then(imageBitmapCallback(ctx4), shouldNotBeCalled);
43 var pending = 0;
44 function imageBitmapCallback(ctx) {
45 pending++;
46 var ctx = ctx;
47 return function(imageBitmap) {
48 pending--;
49 ctx.drawImage(imageBitmap, -100, -100, 300, 300, -25, -25, 300, 300);
50 ctx.drawImage(imageBitmap, -100, -100, 200, 200, -25, -25, 100, 100);
51 ctx.drawImage(imageBitmap, 0, -100, 100, 200, 75, -25, 100, 100);
52 ctx.drawImage(imageBitmap, 0, -100, 200, 200, 175, -25, 100, 100);
53 ctx.drawImage(imageBitmap, -100, 0, 200, 100, -25, 75, 100, 100);
54 ctx.drawImage(imageBitmap, 0, 0, 200, 100, 175, 75, 100, 100);
55 ctx.drawImage(imageBitmap, -100, 0, 200, 200, -25, 175, 100, 100);
56 ctx.drawImage(imageBitmap, 0, 0, 100, 200, 75, 175, 100, 100);
57 ctx.drawImage(imageBitmap, 0, 0, 200, 200, 175, 175, 100, 100);
58 if (!pending && window.testRunner)
59 testRunner.notifyDone();
63 </script>
64 </body></html>