Reuse buffer allocation if canvas size does not change
[WebKit-https.git] / LayoutTests / fast / canvas / canvas-resize-after-paint-without-layout.html
1 <!DOCTYPE html>
2 <!-- Check that resizing a (potentially accelerated) canvas properly clears its
3      contents even if the layout size of the canvas does not change. Expected
4      output is a blank canvas.
5      https://bugs.webkit.org/show_bug.cgi?id=80871 -->
6 <html>
7   <head>
8     <style>
9       #canvas {
10         outline: solid 1px black;
11         width: 300px;
12         height: 300px;
13       }
14     </style>
15     <script src="resources/repaint.js"></script>
16     <script>
17       if (window.layoutTestController)
18         layoutTestController.dumpAsText(true);
19
20       function runTest() {
21         var canvas = document.getElementById('canvas');
22         var ctx = canvas.getContext('2d');
23         ctx.fillStyle = 'red';
24         ctx.fillRect(0, 0, 300, 300);
25         runRepaintTest();
26       }
27
28       function repaintTest() {
29         var canvas = document.getElementById('canvas');
30         // This changes the resolution of the canvas but keeps its layout size constant.
31         canvas.width = canvas.width / 2;
32       }
33     </script>
34   </head>
35   <body onload="runTest();">
36     <canvas id="canvas" width="300" height="300"/>
37   </body>
38 </html>