Home | History | Annotate | Download | only in gpu
      1 <html>
      2 <head>
      3 <script type="text/javascript"
      4         src="../../../../third_party/webgl_conformance/resources/webgl-test-harness.js">
      5 </script>
      6 <script>
      7 // We parse the test list offline and run the harness multiple times with each
      8 // test. Therefore, the version and options do not matter for the browsertests.
      9 // However, we still need to pass in a valid options for the harness to run.
     10 var CONFORMANCE_TEST_VERSION = "1.0.1 (beta)";
     11 var OPTIONS = {
     12   version: CONFORMANCE_TEST_VERSION
     13 };
     14 
     15 var BASE_URL = "../../../../third_party/webgl_conformance/";
     16 var gl = null;
     17 var messages = [];
     18 var numFailures = 0;
     19 
     20 function start(start_url) {
     21   // Report function called by each conformance test.
     22   function report(type, msg, success) {
     23     var reportType = WebGLTestHarnessModule.TestHarness.reportType;
     24     switch (type) {
     25       case reportType.START_PAGE:
     26         // Accept every page loaded.
     27         messages = [];
     28         numFailures = 0;
     29         return true;
     30       case reportType.TEST_RESULT:
     31         if (!success) {
     32           ++numFailures;
     33           messages.push("FAILURE: " + msg);
     34         }
     35         break;
     36       case reportType.FINISH_PAGE:
     37         if (success === undefined) {
     38           ++numFailures;
     39           messages.push("TIMEOUT: " +
     40               window.webglTestHarness.timeoutDelay + " ms");
     41         }
     42       case reportType.FINISHED_ALL_TESTS:
     43         if (numFailures > 0) {
     44           var ext = gl.getExtension("WEBGL_debug_renderer_info");
     45           if (ext) {
     46             messages.push("GL_VENDOR: " +
     47                 gl.getParameter(ext.UNMASKED_VENDOR_WEBGL));
     48             messages.push("GL_RENDERER: " +
     49                 gl.getParameter(ext.UNMASKED_RENDERER_WEBGL));
     50           }
     51         } else {
     52           messages.push("SUCCESS");
     53         }
     54         domAutomationController.setAutomationId(1);
     55         domAutomationController.send(messages.join("\n"));
     56         break;
     57     }
     58   }
     59 
     60   function create3DContext() {
     61     var canvas = document.createElement("canvas");
     62     var context = null;
     63     try {
     64       context = canvas.getContext("webgl");
     65     } catch(e) {
     66     }
     67     if (!context) {
     68       try {
     69         context = canvas.getContext("experimental-webgl");
     70       } catch(e) {
     71       }
     72     }
     73     return context;
     74   }
     75 
     76   // Assert the WebGL context exists.
     77   gl = create3DContext();
     78   if (!gl) {
     79     domAutomationController.setAutomationId(1);
     80     domAutomationController.send("FAILURE: unable to fetch WebGL context");
     81     return;
     82   }
     83 
     84   var iframe = document.getElementById("testframe");
     85   var testHarness = new WebGLTestHarnessModule.TestHarness(
     86       iframe,
     87       BASE_URL + start_url,
     88       report,
     89       OPTIONS);
     90 
     91   window.webglTestHarness = testHarness;
     92   window.webglTestHarness.runTests();
     93 }
     94 </script>
     95 </head>
     96 <body>
     97 <iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe>
     98 </body>
     99 </html>
    100