summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/compositing/canvas-with-object-fit-contain-in-composited-layer.html
blob: 364fd98206a07a6025c4d3a10591791a83a0ff3b (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
<!DOCTYPE html>
<style>
canvas {
  background-color: gray;
  width: 200px;
  height: 200px;
  object-fit: contain;
}
</style>
<p>Test passes if a green square inside an orange rectanlge is shown up without a distortion.
<div>
  <canvas width="200" height="400"></canvas>
</div>
<script>
function paintCanvas(canvas)
{
  var ctx = canvas.getContext('2d');
  ctx.fillStyle = 'orange';
  ctx.fillRect(0, 0, canvas.width, canvas.height);

  ctx.fillStyle = 'green';
  var squarWidth = canvas.width / 2;
  ctx.fillRect(50, 150, squarWidth, squarWidth);
}

paintCanvas(document.querySelector('canvas'));
</script>