Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from jbghoul/webgl-kernel-experimental
Browse files Browse the repository at this point in the history
Webgl kernel experimental
  • Loading branch information
jbghoul authored Sep 19, 2022
2 parents 427747a + 22e9967 commit d4f85b5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/backend/web-gl/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class WebGLKernel extends GLKernel {
testCanvas = new OffscreenCanvas(0, 0);
}
if (!testCanvas) return;
testContext = testCanvas.getContext('webgl') || testCanvas.getContext('experimental-webgl');
testContext = testCanvas.getContext('webgl');
if (!testContext && !(testCanvas instanceof OffscreenCanvas)) testContext = testCanvas.getContext('experimental-webgl');
if (!testContext || !testContext.getExtension) return;
testExtensions = {
OES_texture_float: testContext.getExtension('OES_texture_float'),
Expand Down
29 changes: 29 additions & 0 deletions test/issues/778-webgl-kernel-experimental.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { assert, test, module: describe } = require('qunit');
const { GPU } = require('../../src');

const old = {};
describe('issue #778 - WebGL kernel feature checks may throw an error', {
before: () => {
old.document = global.document;
old.OffscreenCanvas = global.OffscreenCanvas;

global.document = undefined;
// Mocking OffscreenCanvas
global.OffscreenCanvas = class OffscreenCanvas {
constructor() {}

getContext(context) {
if (context === "webgl") return;
if (context === 'experimental-webgl') throw new TypeError("Failed to execute 'getContext' on 'OffscreenCanvas': The provided value 'experimental-webgl' is not a valid enum value of type OffscreenRenderingContextType.")
}
}
},
after: () => {
global.document = old.document;
global.OffscreenCanvas = old.OffscreenCanvas;
}
});

test('Check that WebGL is not supported', () => {
assert.notOk(GPU.isWebGLSupported);
});

0 comments on commit d4f85b5

Please sign in to comment.