Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Wrap try/catch around canvas getContext webgl
Browse files Browse the repository at this point in the history
- Firefox throws exceptions for unsupported graphics cards, which causes the tests to fail
  • Loading branch information
dfreedm committed Oct 21, 2013
1 parent 7c0d44b commit 09fc586
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions test/js/HTMLCanvasElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ suite('HTMLCanvasElement', function() {
return;

var canvas = document.createElement('canvas');
var context = canvas.getContext('webgl');
// Chrome returns null if the graphics drivers are not good enough.
var context = null;
// Firefox throws exception if graphics card is not supported
try {
context = canvas.getContext('webgl');
}
catch(ex) {
}
// Chrome returns null if the graphics card is not supported
assert.isTrue(context === null || context instanceof WebGLRenderingContext);

if (context != null)
Expand Down Expand Up @@ -60,7 +66,12 @@ suite('HTMLCanvasElement', function() {

test('WebGL texImage2D', function(done) {
var canvas = document.createElement('canvas');
var gl = canvas.getContext('webgl');
var gl = null;
// Firefox throws exception if graphics card is not supported
try {
gl = canvas.getContext('webgl');
} catch (ex) {
}
// IE10 does not have WebGL.
// Chrome returns null if the graphics card is not supported
if (!gl) {
Expand All @@ -80,7 +91,12 @@ suite('HTMLCanvasElement', function() {

test('WebGL texSubImage2D', function(done) {
var canvas = document.createElement('canvas');
var gl = canvas.getContext('webgl');
var gl = null;
// Firefox throws exception if graphics card is not supported
try {
gl = canvas.getContext('webgl');
} catch(ex) {
}
// IE10 does not have WebGL.
// Chrome returns null if the graphics card is not supported
if (!gl) {
Expand Down

0 comments on commit 09fc586

Please sign in to comment.