Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});