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

content / test / data / gpu / webgl_extension_test.html [blame]

<!DOCTYPE html>
<html>
  <script>
    function checkExtension(name, context_type) {
      var canvas = document.createElement("canvas");
      document.body.appendChild(canvas);

      var gl_context = canvas.getContext(context_type || "webgl");

      // If we don't have a GL context, give up now
      if (!gl_context) {
        webglTestHarness.reportResults(name, false, "Unable to initialize " + context_type + " context.");
      } else {
        var gl_extension = gl_context.getExtension(name);
        if (gl_extension) {
          webglTestHarness.reportResults(name, true, name + " was available");
        } else {
          webglTestHarness.reportResults(name, false, name + " was not available");
        }
      }

      webglTestHarness.notifyFinished(name);
    }

    function checkSupportedExtensions(expected_extensions, context_type) {
      var canvas = document.createElement("canvas");
      document.body.appendChild(canvas);

      var gl_context = canvas.getContext(context_type || "webgl");

      // If we don't have a GL context, give up now
      if (!gl_context) {
        webglTestHarness.reportResults(name, false, "Unable to initialize " + context_type + " context.");
      } else {
        var missing_list = [];
        var extension_list = gl_context.getSupportedExtensions();
        for (var i in extension_list) {
          var extension = extension_list[i];
          if (extension.indexOf("WEBKIT_") == 0)
            continue; // Skip WEBKIT_ prefixed extensions since they all have unprefixed variants at this point.
          var expected_index = expected_extensions.indexOf(extension);
          if (expected_index == -1) {
            missing_list.push(extension);
          }
        }

        if (missing_list.length == 0) {
          webglTestHarness.reportResults(name, true, "All " + context_type + " extensions are being tested.");
        } else {
          var error_string = "The following " + context_type + " extensions are not being tested and should be added to GetExtensionList() in content/test/gpu/gpu_tests/webgl1_conformance_integration_test.py or webgl2_conformance_integration_test.py:";
          for (var i in missing_list) {
            error_string += "\n\t" + missing_list[i];
          }
          webglTestHarness.reportResults(name, false, error_string);
        }
      }

      webglTestHarness.notifyFinished(name);
    }

    window.checkExtension = checkExtension;
    window.checkSupportedExtensions = checkSupportedExtensions;
  </script>
  <body></body>
</html>