Skip to content

Commit

Permalink
Fix partial support test
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Jun 8, 2018
1 parent ab798e9 commit 23128d0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test/TestUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@ export function assertThrows(func, extraArgCatcher) {
/** @type {boolean|undefined} */
let __webGLSupportPresent = undefined;
/** @type {boolean|undefined} */
let _partialWebGLSupportPresent = undefined;
let __onlyPartialWebGLSupportPresent = undefined;
function isWebGLSupportPresent() {
if (__webGLSupportPresent === undefined) {
__webGLSupportPresent = false;
if (window.WebGLRenderingContext !== undefined) {
let canvas = document.createElement('canvas');
let ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
if (ctx instanceof WebGLRenderingContext) {
_partialWebGLSupportPresent = true;
__webGLSupportPresent = true;

let shader = ctx.createShader(WebGLRenderingContext.VERTEX_SHADER);
ctx.shaderSource(shader, `
Expand All @@ -322,9 +322,8 @@ function isWebGLSupportPresent() {

// 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;
}
__onlyPartialWebGLSupportPresent = (
ctx.getShaderInfoLog(shader).indexOf("extension `GL_ARB_gpu_shader5' unsupported") !== -1);
}
}
}
Expand All @@ -334,8 +333,8 @@ function isWebGLSupportPresent() {
/**
* @returns {!boolean|undefined}
*/
function isPartialWebGLSupportPresent() {
return !isWebGLSupportPresent() && _partialWebGLSupportPresent;
function isOnlyPartialWebGLSupportPresent() {
return !isWebGLSupportPresent() && __onlyPartialWebGLSupportPresent;
}

let promiseImageDataFromSrc = src => {
Expand Down Expand Up @@ -420,7 +419,7 @@ export class Suite {
status.log.push(msg);
assertThat(undefined); // Cancel 'no assertion' warning.
return;
} else if (isPartialWebGLSupportPresent()) {
} else if (isOnlyPartialWebGLSupportPresent()) {
status.warn_only = true;
status.warn_message = `Ignoring ${this.name}.${caseName} failure due to lack of WebGL support.`;
}
Expand Down

0 comments on commit 23128d0

Please sign in to comment.