Home | History | Annotate | Download | only in ManualTests
      1 <html>
      2 <body>
      3 This is a test of our ability to convert a canvas to a data url and use it as a cursor. We pass if the cursor animates smoothly and without flickering.<br>
      4 See https://bugs.webkit.org/show_bug.cgi?id=64321.
      5 <canvas id="c" width="40" height="40"></canvas>
      6 <script type="text/javascript">
      7 var icon = new Image;
      8 icon.src = 'resources/drag-image.png'
      9 
     10 function drawArrow(angle) {
     11     var canvas = document.getElementById('c');
     12     canvas.width = canvas.width // reset canvas
     13     var ctx = canvas.getContext('2d');
     14 
     15     ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2);
     16     ctx.rotate(angle);
     17     ctx.drawImage(icon, -icon.width / 2, -icon.height / 2);
     18 
     19     var x = 20;//Math.floor(Math.cos(angle) * icon.width / 2) + icon.width / 2;
     20     var y = 20;//Math.floor(Math.sin(angle) * icon.width / 2) + icon.width / 2;
     21 
     22     var data = canvas.toDataURL();
     23     if (data)
     24         document.body.style.cursor = 'url('+data+') ' + x + ' ' + y + ', pointer';
     25     else
     26         console.log('failure');
     27 }
     28 
     29 (function() {
     30     var angle = 0;
     31     var run = function() {
     32         angle += Math.PI / 16;
     33         drawArrow(angle);
     34         setTimeout(run, 100);
     35     };
     36     run();
     37 })();
     38     drawArrow();
     39 </script>
     40 </body>
     41 </html>
     42