summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/canvas/synchronous-create-pattern.html
blob: 7e6c6f5ac3bd75e8be8106a5944c1d043cc316bd (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
35
36
37
38
39
40
41
42
<!DOCTYPE HTML>
<html>
<script>
var canvas, context, pattern, image;

function runTest() {
  if (window.testRunner)
    testRunner.waitUntilDone();

  canvas = document.getElementById('canvas');
  context = canvas.getContext('2d');

  // Initialize the canvas with orange.
  context.fillStyle = '#FFA500';
  context.fillRect(0, 0, 100, 100);

  image = document.createElement('img');
  image.setAttribute('src', 'resources/35ms-green-flash-at-35ms.svg');
  image.onload = function() {
    setTimeout(function() { createPattern(); }, 50);
    setTimeout(function() { drawPatternAndFinish(); }, 100);
  }
}

function createPattern() {
  pattern = context.createPattern(image, 'repeat');
}

function drawPatternAndFinish() {
  context.fillStyle = pattern;
  context.fillRect(0, 0, 200, 200);
  if (window.testRunner)
    testRunner.notifyDone();
}
</script>
<body onload='runTest()'>
  Test for crbug.com/279445: createPattern should synchronously snapshot an animating image.<br/>
  This test passes if there is a green square below.<br/>
  <canvas id='canvas' width='100' height='100'></canvas>
</body>
</html>