diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/webgl-conf/checkout/js/tests/context-methods.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/js/tests/context-methods.js')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/js/tests/context-methods.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/js/tests/context-methods.js b/dom/canvas/test/webgl-conf/checkout/js/tests/context-methods.js new file mode 100644 index 0000000000..f6476463d2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/js/tests/context-methods.js @@ -0,0 +1,52 @@ +"use strict"; + +// Properties to be ignored because they were added in versions of the +// spec that are backward-compatible with this version +const IGNORED_METHODS = [ + // There is no official spec for the commit API yet, the proposal link is: + // https://wiki.whatwg.org/wiki/OffscreenCanvas + "commit", + + // For WebXR integration: + "makeXRCompatible", +]; + +function assertFunction(v, f) { + try { + if (typeof v[f] != "function") { + testFailed(`Property either does not exist or is not a function: ${f}`); + return false; + } else { + return true; + } + } catch(e) { + testFailed(`Trying to access the property '${f}' threw an error: ${e.toString()}`); + } +} + +function testContextMethods(gl, requiredContextMethods) { + const acceptableMethods = [].concat(requiredContextMethods, IGNORED_METHODS); + + let passed = true; + requiredContextMethods.forEach(method => { + const r = assertFunction(gl, method); + passed = passed && r; + }); + if (passed) { + testPassed("All WebGL methods found."); + } + let extended = false; + for (let propertyName of Object.getOwnPropertyNames(gl)) { + if (typeof gl[propertyName] == "function" && !acceptableMethods.includes(propertyName)) { + if (!extended) { + extended = true; + testFailed("Also found the following extra methods:"); + } + testFailed(propertyName); + } + } + + if (!extended) { + testPassed("No extra methods found on WebGL context."); + } +} |