forked from KhronosGroup/WebGL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow makeXRCompatible as an optional method (KhronosGroup#3198)
* Allow makeXRCompatible as an optional method The WebXR device specification mixes in a new function makeXRCompatible. The methods.html and methods-2.html tests should allow for the possibility of the method existing. While here, update the code to more modern JavaScript. * Factor out shared context-methods.js, backport to 2.0.0/1.0.3. Co-authored-by: Jeff Gilbert <[email protected]>
- Loading branch information
Showing
8 changed files
with
174 additions
and
215 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
conformance-suites/1.0.3/conformance/context/context-methods.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.