diff --git a/test/TestUtil.js b/test/TestUtil.js index 2e24b362..404e0054 100644 --- a/test/TestUtil.js +++ b/test/TestUtil.js @@ -303,18 +303,30 @@ export function assertThrows(func, extraArgCatcher) { let __webGLSupportPresent = undefined; function isWebGLSupportPresent() { if (__webGLSupportPresent === undefined) { - if (window.WebGLRenderingContext === undefined) { - __webGLSupportPresent = false; - } else { + __webGLSupportPresent = false; + if (window.WebGLRenderingContext !== undefined) { let canvas = document.createElement('canvas'); - let context = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); - __webGLSupportPresent = context instanceof WebGLRenderingContext; + let ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + if (ctx instanceof WebGLRenderingContext) { + let shader = ctx.createShader(WebGLRenderingContext.VERTEX_SHADER); + ctx.shaderSource(shader, ` + precision highp float; + precision highp int; + attribute vec2 position; + void main() {gl_Position = vec4(position, 0, 1);}`); + ctx.compileShader(shader); + + // HACK: tests on travis-ci give this warning when compiling shaders, and then give + // bad test results. Checking for it is a workaround to make the build pass. + if (ctx.getShaderInfoLog(shader).indexOf("extension `GL_ARB_gpu_shader5' unsupported") === -1) { + __webGLSupportPresent = true; + } + } } } return __webGLSupportPresent; } - let promiseImageDataFromSrc = src => { let img = document.createElement('img'); img.src = src;