@gjsify/webgl 0.3.12 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/lib/esm/conformance/attribs.spec.js +312 -293
  2. package/lib/esm/conformance/buffers.spec.js +217 -200
  3. package/lib/esm/conformance/context.spec.js +295 -295
  4. package/lib/esm/conformance/programs.spec.js +458 -445
  5. package/lib/esm/conformance/rendering-basic.spec.js +134 -128
  6. package/lib/esm/conformance/rendering.spec.js +502 -400
  7. package/lib/esm/conformance/setup.js +42 -31
  8. package/lib/esm/conformance/state.spec.js +360 -343
  9. package/lib/esm/conformance/textures.spec.js +330 -338
  10. package/lib/esm/conformance/uniforms.spec.js +465 -309
  11. package/lib/esm/conformance-test.js +24 -22
  12. package/lib/esm/extensions/ext-blend-minmax.js +16 -16
  13. package/lib/esm/extensions/ext-color-buffer-float.js +10 -11
  14. package/lib/esm/extensions/ext-color-buffer-half-float.js +10 -11
  15. package/lib/esm/extensions/ext-texture-filter-anisotropic.js +16 -16
  16. package/lib/esm/extensions/oes-element-index-unit.js +11 -12
  17. package/lib/esm/extensions/oes-standard-derivatives.js +15 -15
  18. package/lib/esm/extensions/oes-texture-float-linear.js +11 -12
  19. package/lib/esm/extensions/oes-texture-float.js +11 -12
  20. package/lib/esm/extensions/oes-texture-half-float.js +17 -17
  21. package/lib/esm/extensions/stackgl-destroy-context.js +10 -10
  22. package/lib/esm/extensions/stackgl-resize-drawing-buffer.js +10 -10
  23. package/lib/esm/html-canvas-element.js +64 -64
  24. package/lib/esm/index.js +29 -26
  25. package/lib/esm/linkable.js +49 -49
  26. package/lib/esm/test-utils.js +158 -107
  27. package/lib/esm/test.js +8 -4
  28. package/lib/esm/types/index.js +5 -5
  29. package/lib/esm/utils.js +164 -187
  30. package/lib/esm/webgl-active-info.js +10 -9
  31. package/lib/esm/webgl-bridge.js +162 -147
  32. package/lib/esm/webgl-buffer.js +17 -15
  33. package/lib/esm/webgl-context-attributes.js +23 -22
  34. package/lib/esm/webgl-context-base.js +3039 -3351
  35. package/lib/esm/webgl-drawing-buffer-wrapper.js +10 -9
  36. package/lib/esm/webgl-framebuffer.js +108 -106
  37. package/lib/esm/webgl-program.js +25 -23
  38. package/lib/esm/webgl-query.js +15 -13
  39. package/lib/esm/webgl-renderbuffer.js +23 -21
  40. package/lib/esm/webgl-rendering-context.js +173 -187
  41. package/lib/esm/webgl-sampler.js +15 -13
  42. package/lib/esm/webgl-shader-precision-format.js +10 -9
  43. package/lib/esm/webgl-shader.js +23 -21
  44. package/lib/esm/webgl-sync.js +15 -13
  45. package/lib/esm/webgl-texture-unit.js +12 -11
  46. package/lib/esm/webgl-texture.js +21 -19
  47. package/lib/esm/webgl-transform-feedback.js +15 -13
  48. package/lib/esm/webgl-uniform-location.js +14 -13
  49. package/lib/esm/webgl-vertex-array-object.js +20 -18
  50. package/lib/esm/webgl-vertex-attribute.js +149 -145
  51. package/lib/esm/webgl1.spec.js +1039 -650
  52. package/lib/esm/webgl2-rendering-context.js +1210 -1273
  53. package/lib/esm/webgl2.spec.js +1284 -1252
  54. package/package.json +9 -9
  55. package/lib/esm/@types/glsl-tokenizer/index.d.js +0 -0
@@ -1,302 +1,302 @@
1
- import { describe, it, expect, beforeEach, on } from "@gjsify/unit";
2
- import { WebGLRenderingContext as OurWebGLRenderingContext } from "@gjsify/webgl";
3
1
  import { createGLSetup } from "./setup.js";
2
+ import { beforeEach, describe, expect, it, on } from "@gjsify/unit";
3
+ import { WebGLRenderingContext } from "@gjsify/webgl";
4
+
5
+ //#region src/ts/conformance/context.spec.ts
4
6
  const WEBGL_METHODS = [
5
- "getContextAttributes",
6
- "activeTexture",
7
- "attachShader",
8
- "bindAttribLocation",
9
- "bindBuffer",
10
- "bindFramebuffer",
11
- "bindRenderbuffer",
12
- "bindTexture",
13
- "blendColor",
14
- "blendEquation",
15
- "blendEquationSeparate",
16
- "blendFunc",
17
- "blendFuncSeparate",
18
- "bufferData",
19
- "bufferSubData",
20
- "checkFramebufferStatus",
21
- "clear",
22
- "clearColor",
23
- "clearDepth",
24
- "clearStencil",
25
- "colorMask",
26
- "compileShader",
27
- "compressedTexImage2D",
28
- "compressedTexSubImage2D",
29
- "copyTexImage2D",
30
- "copyTexSubImage2D",
31
- "createBuffer",
32
- "createFramebuffer",
33
- "createProgram",
34
- "createRenderbuffer",
35
- "createShader",
36
- "createTexture",
37
- "cullFace",
38
- "deleteBuffer",
39
- "deleteFramebuffer",
40
- "deleteProgram",
41
- "deleteRenderbuffer",
42
- "deleteShader",
43
- "deleteTexture",
44
- "depthFunc",
45
- "depthMask",
46
- "depthRange",
47
- "detachShader",
48
- "disable",
49
- "disableVertexAttribArray",
50
- "drawArrays",
51
- "drawElements",
52
- "enable",
53
- "enableVertexAttribArray",
54
- "finish",
55
- "flush",
56
- "framebufferRenderbuffer",
57
- "framebufferTexture2D",
58
- "frontFace",
59
- "generateMipmap",
60
- "getActiveAttrib",
61
- "getActiveUniform",
62
- "getAttachedShaders",
63
- "getAttribLocation",
64
- "getParameter",
65
- "getBufferParameter",
66
- "getError",
67
- "getExtension",
68
- "getFramebufferAttachmentParameter",
69
- "getProgramParameter",
70
- "getProgramInfoLog",
71
- "getRenderbufferParameter",
72
- "getShaderParameter",
73
- "getShaderInfoLog",
74
- "getShaderPrecisionFormat",
75
- "getShaderSource",
76
- "getSupportedExtensions",
77
- "getTexParameter",
78
- "getUniform",
79
- "getUniformLocation",
80
- "getVertexAttrib",
81
- "getVertexAttribOffset",
82
- "hint",
83
- "isBuffer",
84
- "isContextLost",
85
- "isEnabled",
86
- "isFramebuffer",
87
- "isProgram",
88
- "isRenderbuffer",
89
- "isShader",
90
- "isTexture",
91
- "lineWidth",
92
- "linkProgram",
93
- "pixelStorei",
94
- "polygonOffset",
95
- "readPixels",
96
- "renderbufferStorage",
97
- "sampleCoverage",
98
- "scissor",
99
- "shaderSource",
100
- "stencilFunc",
101
- "stencilFuncSeparate",
102
- "stencilMask",
103
- "stencilMaskSeparate",
104
- "stencilOp",
105
- "stencilOpSeparate",
106
- "texImage2D",
107
- "texParameterf",
108
- "texParameteri",
109
- "texSubImage2D",
110
- "uniform1f",
111
- "uniform1fv",
112
- "uniform1i",
113
- "uniform1iv",
114
- "uniform2f",
115
- "uniform2fv",
116
- "uniform2i",
117
- "uniform2iv",
118
- "uniform3f",
119
- "uniform3fv",
120
- "uniform3i",
121
- "uniform3iv",
122
- "uniform4f",
123
- "uniform4fv",
124
- "uniform4i",
125
- "uniform4iv",
126
- "uniformMatrix2fv",
127
- "uniformMatrix3fv",
128
- "uniformMatrix4fv",
129
- "useProgram",
130
- "validateProgram",
131
- "vertexAttrib1f",
132
- "vertexAttrib1fv",
133
- "vertexAttrib2f",
134
- "vertexAttrib2fv",
135
- "vertexAttrib3f",
136
- "vertexAttrib3fv",
137
- "vertexAttrib4f",
138
- "vertexAttrib4fv",
139
- "vertexAttribPointer",
140
- "viewport"
7
+ "getContextAttributes",
8
+ "activeTexture",
9
+ "attachShader",
10
+ "bindAttribLocation",
11
+ "bindBuffer",
12
+ "bindFramebuffer",
13
+ "bindRenderbuffer",
14
+ "bindTexture",
15
+ "blendColor",
16
+ "blendEquation",
17
+ "blendEquationSeparate",
18
+ "blendFunc",
19
+ "blendFuncSeparate",
20
+ "bufferData",
21
+ "bufferSubData",
22
+ "checkFramebufferStatus",
23
+ "clear",
24
+ "clearColor",
25
+ "clearDepth",
26
+ "clearStencil",
27
+ "colorMask",
28
+ "compileShader",
29
+ "compressedTexImage2D",
30
+ "compressedTexSubImage2D",
31
+ "copyTexImage2D",
32
+ "copyTexSubImage2D",
33
+ "createBuffer",
34
+ "createFramebuffer",
35
+ "createProgram",
36
+ "createRenderbuffer",
37
+ "createShader",
38
+ "createTexture",
39
+ "cullFace",
40
+ "deleteBuffer",
41
+ "deleteFramebuffer",
42
+ "deleteProgram",
43
+ "deleteRenderbuffer",
44
+ "deleteShader",
45
+ "deleteTexture",
46
+ "depthFunc",
47
+ "depthMask",
48
+ "depthRange",
49
+ "detachShader",
50
+ "disable",
51
+ "disableVertexAttribArray",
52
+ "drawArrays",
53
+ "drawElements",
54
+ "enable",
55
+ "enableVertexAttribArray",
56
+ "finish",
57
+ "flush",
58
+ "framebufferRenderbuffer",
59
+ "framebufferTexture2D",
60
+ "frontFace",
61
+ "generateMipmap",
62
+ "getActiveAttrib",
63
+ "getActiveUniform",
64
+ "getAttachedShaders",
65
+ "getAttribLocation",
66
+ "getParameter",
67
+ "getBufferParameter",
68
+ "getError",
69
+ "getExtension",
70
+ "getFramebufferAttachmentParameter",
71
+ "getProgramParameter",
72
+ "getProgramInfoLog",
73
+ "getRenderbufferParameter",
74
+ "getShaderParameter",
75
+ "getShaderInfoLog",
76
+ "getShaderPrecisionFormat",
77
+ "getShaderSource",
78
+ "getSupportedExtensions",
79
+ "getTexParameter",
80
+ "getUniform",
81
+ "getUniformLocation",
82
+ "getVertexAttrib",
83
+ "getVertexAttribOffset",
84
+ "hint",
85
+ "isBuffer",
86
+ "isContextLost",
87
+ "isEnabled",
88
+ "isFramebuffer",
89
+ "isProgram",
90
+ "isRenderbuffer",
91
+ "isShader",
92
+ "isTexture",
93
+ "lineWidth",
94
+ "linkProgram",
95
+ "pixelStorei",
96
+ "polygonOffset",
97
+ "readPixels",
98
+ "renderbufferStorage",
99
+ "sampleCoverage",
100
+ "scissor",
101
+ "shaderSource",
102
+ "stencilFunc",
103
+ "stencilFuncSeparate",
104
+ "stencilMask",
105
+ "stencilMaskSeparate",
106
+ "stencilOp",
107
+ "stencilOpSeparate",
108
+ "texImage2D",
109
+ "texParameterf",
110
+ "texParameteri",
111
+ "texSubImage2D",
112
+ "uniform1f",
113
+ "uniform1fv",
114
+ "uniform1i",
115
+ "uniform1iv",
116
+ "uniform2f",
117
+ "uniform2fv",
118
+ "uniform2i",
119
+ "uniform2iv",
120
+ "uniform3f",
121
+ "uniform3fv",
122
+ "uniform3i",
123
+ "uniform3iv",
124
+ "uniform4f",
125
+ "uniform4fv",
126
+ "uniform4i",
127
+ "uniform4iv",
128
+ "uniformMatrix2fv",
129
+ "uniformMatrix3fv",
130
+ "uniformMatrix4fv",
131
+ "useProgram",
132
+ "validateProgram",
133
+ "vertexAttrib1f",
134
+ "vertexAttrib1fv",
135
+ "vertexAttrib2f",
136
+ "vertexAttrib2fv",
137
+ "vertexAttrib3f",
138
+ "vertexAttrib3fv",
139
+ "vertexAttrib4f",
140
+ "vertexAttrib4fv",
141
+ "vertexAttribPointer",
142
+ "viewport"
141
143
  ];
142
144
  const WEBGL_CONSTANTS = [
143
- ["DEPTH_BUFFER_BIT", 256],
144
- ["STENCIL_BUFFER_BIT", 1024],
145
- ["COLOR_BUFFER_BIT", 16384],
146
- ["POINTS", 0],
147
- ["LINES", 1],
148
- ["LINE_LOOP", 2],
149
- ["LINE_STRIP", 3],
150
- ["TRIANGLES", 4],
151
- ["TRIANGLE_STRIP", 5],
152
- ["TRIANGLE_FAN", 6],
153
- ["ZERO", 0],
154
- ["ONE", 1],
155
- ["SRC_COLOR", 768],
156
- ["SRC_ALPHA", 770],
157
- ["FUNC_ADD", 32774],
158
- ["ARRAY_BUFFER", 34962],
159
- ["ELEMENT_ARRAY_BUFFER", 34963],
160
- ["STREAM_DRAW", 35040],
161
- ["STATIC_DRAW", 35044],
162
- ["DYNAMIC_DRAW", 35048],
163
- ["FRAGMENT_SHADER", 35632],
164
- ["VERTEX_SHADER", 35633],
165
- ["COMPILE_STATUS", 35713],
166
- ["LINK_STATUS", 35714],
167
- ["VALIDATE_STATUS", 35715],
168
- ["FLOAT", 5126],
169
- ["FLOAT_VEC2", 35664],
170
- ["FLOAT_VEC3", 35665],
171
- ["FLOAT_VEC4", 35666],
172
- ["FLOAT_MAT2", 35674],
173
- ["FLOAT_MAT3", 35675],
174
- ["FLOAT_MAT4", 35676],
175
- ["INT", 5124],
176
- ["TEXTURE_2D", 3553],
177
- ["TEXTURE_CUBE_MAP", 34067],
178
- ["RGBA", 6408],
179
- ["RGB", 6407],
180
- ["UNSIGNED_BYTE", 5121],
181
- ["UNSIGNED_SHORT", 5123],
182
- ["UNSIGNED_INT", 5125],
183
- ["FRAMEBUFFER", 36160],
184
- ["RENDERBUFFER", 36161],
185
- ["DEPTH_COMPONENT16", 33189],
186
- ["DEPTH_ATTACHMENT", 36096],
187
- ["COLOR_ATTACHMENT0", 36064],
188
- ["FRAMEBUFFER_COMPLETE", 36053],
189
- ["NO_ERROR", 0],
190
- ["INVALID_ENUM", 1280],
191
- ["INVALID_VALUE", 1281],
192
- ["INVALID_OPERATION", 1282],
193
- ["OUT_OF_MEMORY", 1285]
145
+ ["DEPTH_BUFFER_BIT", 256],
146
+ ["STENCIL_BUFFER_BIT", 1024],
147
+ ["COLOR_BUFFER_BIT", 16384],
148
+ ["POINTS", 0],
149
+ ["LINES", 1],
150
+ ["LINE_LOOP", 2],
151
+ ["LINE_STRIP", 3],
152
+ ["TRIANGLES", 4],
153
+ ["TRIANGLE_STRIP", 5],
154
+ ["TRIANGLE_FAN", 6],
155
+ ["ZERO", 0],
156
+ ["ONE", 1],
157
+ ["SRC_COLOR", 768],
158
+ ["SRC_ALPHA", 770],
159
+ ["FUNC_ADD", 32774],
160
+ ["ARRAY_BUFFER", 34962],
161
+ ["ELEMENT_ARRAY_BUFFER", 34963],
162
+ ["STREAM_DRAW", 35040],
163
+ ["STATIC_DRAW", 35044],
164
+ ["DYNAMIC_DRAW", 35048],
165
+ ["FRAGMENT_SHADER", 35632],
166
+ ["VERTEX_SHADER", 35633],
167
+ ["COMPILE_STATUS", 35713],
168
+ ["LINK_STATUS", 35714],
169
+ ["VALIDATE_STATUS", 35715],
170
+ ["FLOAT", 5126],
171
+ ["FLOAT_VEC2", 35664],
172
+ ["FLOAT_VEC3", 35665],
173
+ ["FLOAT_VEC4", 35666],
174
+ ["FLOAT_MAT2", 35674],
175
+ ["FLOAT_MAT3", 35675],
176
+ ["FLOAT_MAT4", 35676],
177
+ ["INT", 5124],
178
+ ["TEXTURE_2D", 3553],
179
+ ["TEXTURE_CUBE_MAP", 34067],
180
+ ["RGBA", 6408],
181
+ ["RGB", 6407],
182
+ ["UNSIGNED_BYTE", 5121],
183
+ ["UNSIGNED_SHORT", 5123],
184
+ ["UNSIGNED_INT", 5125],
185
+ ["FRAMEBUFFER", 36160],
186
+ ["RENDERBUFFER", 36161],
187
+ ["DEPTH_COMPONENT16", 33189],
188
+ ["DEPTH_ATTACHMENT", 36096],
189
+ ["COLOR_ATTACHMENT0", 36064],
190
+ ["FRAMEBUFFER_COMPLETE", 36053],
191
+ ["NO_ERROR", 0],
192
+ ["INVALID_ENUM", 1280],
193
+ ["INVALID_VALUE", 1281],
194
+ ["INVALID_OPERATION", 1282],
195
+ ["OUT_OF_MEMORY", 1285]
194
196
  ];
195
197
  var context_spec_default = async () => {
196
- await on("Display", async () => {
197
- const setup = createGLSetup();
198
- if (!setup) {
199
- console.warn("WebGL context not available \u2014 skipping conformance/context tests");
200
- return;
201
- }
202
- const { gl, glArea, win } = setup;
203
- glArea.make_current();
204
- await describe("conformance/context/methods: all WebGL methods present", async () => {
205
- beforeEach(async () => {
206
- glArea.make_current();
207
- });
208
- await it("all standard WebGL methods are functions on the context", async () => {
209
- const missing = [];
210
- for (const method of WEBGL_METHODS) {
211
- if (typeof gl[method] !== "function") {
212
- missing.push(method);
213
- }
214
- }
215
- if (missing.length > 0) {
216
- throw new Error(`Missing WebGL methods: ${missing.join(", ")}`);
217
- }
218
- });
219
- });
220
- await describe("conformance/context/constants-and-properties: constant values", async () => {
221
- beforeEach(async () => {
222
- glArea.make_current();
223
- });
224
- await it("all sampled WebGL constants have the correct numeric value", async () => {
225
- const wrong = [];
226
- for (const [name, expected] of WEBGL_CONSTANTS) {
227
- const actual = gl[name];
228
- if (actual !== expected) {
229
- wrong.push(`${name}: expected ${expected}, got ${actual}`);
230
- }
231
- }
232
- if (wrong.length > 0) {
233
- throw new Error(`Wrong constant values:
234
- ${wrong.join("\n")}`);
235
- }
236
- });
237
- await it("WebGLRenderingContext class constant values match instance constants", async () => {
238
- const wrong = [];
239
- for (const [name, expected] of WEBGL_CONSTANTS) {
240
- const classVal = OurWebGLRenderingContext[name];
241
- if (classVal !== void 0 && classVal !== expected) {
242
- wrong.push(`${name}: expected ${expected}, got ${classVal}`);
243
- }
244
- }
245
- if (wrong.length > 0) {
246
- throw new Error(`Wrong class constant values:
247
- ${wrong.join("\n")}`);
248
- }
249
- });
250
- });
251
- await describe("conformance/context/context-type-test", async () => {
252
- beforeEach(async () => {
253
- glArea.make_current();
254
- });
255
- await it("WebGLRenderingContext should exist in globalThis", async () => {
256
- expect(typeof globalThis.WebGLRenderingContext !== "undefined").toBeTruthy();
257
- });
258
- await it("gl should be an instance of WebGLRenderingContext", async () => {
259
- expect(gl instanceof OurWebGLRenderingContext).toBeTruthy();
260
- });
261
- await it("getContextAttributes returns an object", async () => {
262
- const attrs = gl.getContextAttributes();
263
- expect(attrs).not.toBeNull();
264
- expect(typeof attrs).toBe("object");
265
- });
266
- await it("isContextLost returns false initially", async () => {
267
- expect(gl.isContextLost()).toBe(false);
268
- });
269
- await it("canvas property points to the HTMLCanvasElement", async () => {
270
- expect(gl.canvas).not.toBeNull();
271
- expect(typeof gl.canvas.getContext).toBe("function");
272
- });
273
- await it("drawingBufferWidth and drawingBufferHeight are positive integers", async () => {
274
- expect(gl.drawingBufferWidth).toBeGreaterThan(0);
275
- expect(gl.drawingBufferHeight).toBeGreaterThan(0);
276
- expect(Number.isInteger(gl.drawingBufferWidth)).toBeTruthy();
277
- expect(Number.isInteger(gl.drawingBufferHeight)).toBeTruthy();
278
- });
279
- await it("getSupportedExtensions returns an array of strings", async () => {
280
- const exts = gl.getSupportedExtensions();
281
- expect(Array.isArray(exts)).toBeTruthy();
282
- for (const ext of exts) {
283
- expect(typeof ext).toBe("string");
284
- }
285
- });
286
- await it("getParameter(VENDOR) and getParameter(RENDERER) return strings", async () => {
287
- const vendor = gl.getParameter(gl.VENDOR);
288
- const renderer = gl.getParameter(gl.RENDERER);
289
- const version = gl.getParameter(gl.VERSION);
290
- const shadingLang = gl.getParameter(gl.SHADING_LANGUAGE_VERSION);
291
- expect(typeof vendor).toBe("string");
292
- expect(typeof renderer).toBe("string");
293
- expect(typeof version).toBe("string");
294
- expect(typeof shadingLang).toBe("string");
295
- });
296
- });
297
- win.destroy();
298
- });
299
- };
300
- export {
301
- context_spec_default as default
198
+ await on("Display", async () => {
199
+ const setup = createGLSetup();
200
+ if (!setup) {
201
+ console.warn("WebGL context not available skipping conformance/context tests");
202
+ return;
203
+ }
204
+ const { gl, glArea, win } = setup;
205
+ glArea.make_current();
206
+ await describe("conformance/context/methods: all WebGL methods present", async () => {
207
+ beforeEach(async () => {
208
+ glArea.make_current();
209
+ });
210
+ await it("all standard WebGL methods are functions on the context", async () => {
211
+ const missing = [];
212
+ for (const method of WEBGL_METHODS) {
213
+ if (typeof gl[method] !== "function") {
214
+ missing.push(method);
215
+ }
216
+ }
217
+ if (missing.length > 0) {
218
+ throw new Error(`Missing WebGL methods: ${missing.join(", ")}`);
219
+ }
220
+ });
221
+ });
222
+ await describe("conformance/context/constants-and-properties: constant values", async () => {
223
+ beforeEach(async () => {
224
+ glArea.make_current();
225
+ });
226
+ await it("all sampled WebGL constants have the correct numeric value", async () => {
227
+ const wrong = [];
228
+ for (const [name, expected] of WEBGL_CONSTANTS) {
229
+ const actual = gl[name];
230
+ if (actual !== expected) {
231
+ wrong.push(`${name}: expected ${expected}, got ${actual}`);
232
+ }
233
+ }
234
+ if (wrong.length > 0) {
235
+ throw new Error(`Wrong constant values:\n${wrong.join("\n")}`);
236
+ }
237
+ });
238
+ await it("WebGLRenderingContext class constant values match instance constants", async () => {
239
+ const wrong = [];
240
+ for (const [name, expected] of WEBGL_CONSTANTS) {
241
+ const classVal = WebGLRenderingContext[name];
242
+ if (classVal !== undefined && classVal !== expected) {
243
+ wrong.push(`${name}: expected ${expected}, got ${classVal}`);
244
+ }
245
+ }
246
+ if (wrong.length > 0) {
247
+ throw new Error(`Wrong class constant values:\n${wrong.join("\n")}`);
248
+ }
249
+ });
250
+ });
251
+ await describe("conformance/context/context-type-test", async () => {
252
+ beforeEach(async () => {
253
+ glArea.make_current();
254
+ });
255
+ await it("WebGLRenderingContext should exist in globalThis", async () => {
256
+ expect(typeof globalThis.WebGLRenderingContext !== "undefined").toBeTruthy();
257
+ });
258
+ await it("gl should be an instance of WebGLRenderingContext", async () => {
259
+ expect(gl instanceof WebGLRenderingContext).toBeTruthy();
260
+ });
261
+ await it("getContextAttributes returns an object", async () => {
262
+ const attrs = gl.getContextAttributes();
263
+ expect(attrs).not.toBeNull();
264
+ expect(typeof attrs).toBe("object");
265
+ });
266
+ await it("isContextLost returns false initially", async () => {
267
+ expect(gl.isContextLost()).toBe(false);
268
+ });
269
+ await it("canvas property points to the HTMLCanvasElement", async () => {
270
+ expect(gl.canvas).not.toBeNull();
271
+ expect(typeof gl.canvas.getContext).toBe("function");
272
+ });
273
+ await it("drawingBufferWidth and drawingBufferHeight are positive integers", async () => {
274
+ expect(gl.drawingBufferWidth).toBeGreaterThan(0);
275
+ expect(gl.drawingBufferHeight).toBeGreaterThan(0);
276
+ expect(Number.isInteger(gl.drawingBufferWidth)).toBeTruthy();
277
+ expect(Number.isInteger(gl.drawingBufferHeight)).toBeTruthy();
278
+ });
279
+ await it("getSupportedExtensions returns an array of strings", async () => {
280
+ const exts = gl.getSupportedExtensions();
281
+ expect(Array.isArray(exts)).toBeTruthy();
282
+ for (const ext of exts) {
283
+ expect(typeof ext).toBe("string");
284
+ }
285
+ });
286
+ await it("getParameter(VENDOR) and getParameter(RENDERER) return strings", async () => {
287
+ const vendor = gl.getParameter(gl.VENDOR);
288
+ const renderer = gl.getParameter(gl.RENDERER);
289
+ const version = gl.getParameter(gl.VERSION);
290
+ const shadingLang = gl.getParameter(gl.SHADING_LANGUAGE_VERSION);
291
+ expect(typeof vendor).toBe("string");
292
+ expect(typeof renderer).toBe("string");
293
+ expect(typeof version).toBe("string");
294
+ expect(typeof shadingLang).toBe("string");
295
+ });
296
+ });
297
+ win.destroy();
298
+ });
302
299
  };
300
+
301
+ //#endregion
302
+ export { context_spec_default as default };