summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-video.html
blob: 293dd46008498d45b931f861e1b5f0c62f9f937b (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
43
44
<html>
<head>
  <title>Ensure correct behavior of createPattern with video elements.</title>
  <style type="text/css">
  video {
    display: none;
  }
  </style>
</head>
<body>
  <canvas id="canvas"></canvas>
  <video id="video">
    <source src="resources/canvas_video.mp4"  type='video/mp4' />
    <source src="resources/canvas_video.webm" type='video/webm' />
    <source src="resources/canvas_video.ogv"  type='video/ogg' />
  </video>
  <script>
  if (window.testRunner) {
    testRunner.dumpAsTextWithPixelResults();
    testRunner.waitUntilDone();
  }

  var length = 150;
  var canvas = document.getElementById("canvas");
  canvas.setAttribute("width", length);
  canvas.setAttribute("height", length);
  var ctx = canvas.getContext("2d");

  var video = document.getElementById("video");
  video.addEventListener("playing", drawImageToCanvas, true);
  video.play();

  function drawImageToCanvas() {
    video.removeEventListener("playing", drawImageToCanvas, true);
    ctx.fillStyle = "blue";
    ctx.fillRect(0, 0, length, length);
    ctx.fillStyle = ctx.createPattern(video, "no-repeat");
    ctx.fillRect(0, 0, length, length);
    if (window.testRunner)
      testRunner.notifyDone();
  }
  </script>
</body>
</html>