summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/webgl/webgl-viewport-parameters-preserved.html
blob: 90b48df8fa5822bbabc5601445f1b069db5e6f6f (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Checks that painting WebGL contents doesn't pollute the context's viewport state.");

var wtu = WebGLTestUtils;

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

var canvas;
var context;

function draw() {
  var viewport = context.getParameter(context.VIEWPORT);

  if (!areArraysEqual(viewport, [20, 20, 10, 10])) {
    testFailed(viewport + " should be [20, 20, 10, 10]. Was " + viewport);
  } else {
    testPassed("Viewport not corrupted.");
  }

  if (window.testRunner)
    testRunner.notifyDone();
}

window.onload = function()
{
  if (window.initNonKhronosFramework) {
    window.initNonKhronosFramework(false);
  }

  canvas = document.getElementById("webgl-canvas");
  canvas.width = 50; canvas.height = 50;
  context = create3DContext(canvas);

  context.viewport(20, 20, 10, 10);

  context.clearColor(255, 0, 0, 255);
  context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT);

  // We need to ensure that the compositor has run before the drawing
  // takes place. Setting a timeout of zero causes the compositor to run before
  // the draw call. Using requestAnimationFrame caused the test to time-out.
  setTimeout(draw, 0);
}
</script>
<canvas id="webgl-canvas" width="32px" height="32px"></canvas>
</body>
</html>