summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/canvas-composite-fill-repaint.html
blob: 81aba35cdfcb8d4febfbb55427c1cc6718333e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!doctype html>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<body onload="runAfterLayoutAndPaint(repaintTest);">
  <canvas id="canvas-source-in" width="100" height="100"></canvas>
  <canvas id="canvas-copy" width="100" height="100"></canvas>
  <script>
  var compositeTypes = ['source-in','copy'];

  if (window.testRunner) {
    testRunner.dumpAsTextWithPixelResults();
    testRunner.waitUntilDone();
  }

  for (i = 0; i < compositeTypes.length; i++) {
    var canvas = document.getElementById('canvas-' + compositeTypes[i]);
    var ctx = canvas.getContext('2d');
    ctx.fillStyle = '#0f0';
    ctx.fillRect(0, 0, 100, 100);
  }

  function repaintTest()
  {
    for (i = 0; i < compositeTypes.length; i++) {
      var canvas = document.getElementById('canvas-' + compositeTypes[i]);
      var ctx = canvas.getContext('2d');
      ctx.globalCompositeOperation = compositeTypes[i];
      ctx.fillStyle = '#00f';
      ctx.fillRect(40, 40, 20, 20);
    }
    if (window.testRunner)
      testRunner.notifyDone();
  }
  </script>
</body>