summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/gpu/webgl_conformance.html
blob: a173db874c9883a19b60be550d8acf35c0fd7179 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<head>
<script type="text/javascript"
        src="../../../../third_party/webgl_conformance/resources/webgl-test-harness.js">
</script>
<script>
var BASE_URL = "../../../../third_party/webgl_conformance/";
var gl = null;
var message;

function start(start_url) {
  // Report function called by each conformance test.
  function report(type, msg, success) {
    var reportType = WebGLTestHarnessModule.TestHarness.reportType;
    switch (type) {
      case reportType.START_PAGE:
        // Accept every page loaded.
        return true;
      case reportType.TEST_RESULT:
        if (!success)
          message = "FAILURE: " + msg;
        else
          message = "SUCCESS";
        break;
      case reportType.FINISH_PAGE:
        if (!success)
          message = "TIMEOUT (" + window.webglTestHarness.timeoutDelay + " ms)";
      case reportType.FINISHED_ALL_TESTS:
        if (message.substr(0, 7) != "SUCCESS") {
          var ext = gl.getExtension("WEBGL_debug_renderer_info");
          if (ext) {
            message += "\nGL_VENDOR:   " +
                gl.getParameter(ext.UNMASKED_VENDOR_WEBGL) + "\n";
            message += "GL_RENDERER: " +
                gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
          }
        }
        domAutomationController.setAutomationId(1);
        domAutomationController.send(message);
        break;
    }
  }

  function create3DContext() {
    var canvas = document.createElement("canvas");
    var context = null;
    try {
      context = canvas.getContext("webgl");
    } catch(e) {
    }
    if (!context) {
      try {
        context = canvas.getContext("experimental-webgl");
      } catch(e) {
      }
    }
    return context;
  }

  message = "";

  // Assert the WebGL context exists.
  gl = create3DContext();
  if (!gl) {
    message = "FAILURE: unable to fetch WebGL context";
    domAutomationController.setAutomationId(1);
    domAutomationController.send(message);
    return;
  }

  var iframe = document.getElementById("testframe");
  var testHarness = new WebGLTestHarnessModule.TestHarness(
      iframe,
      BASE_URL + start_url,
      report);
  window.webglTestHarness = testHarness;
  window.webglTestHarness.runTests();
}
</script>
</head>
<body>
<iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe>
</body>
</html>