diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html')
-rw-r--r-- | testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html b/testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html new file mode 100644 index 0000000000..a68a0f2b51 --- /dev/null +++ b/testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html @@ -0,0 +1,95 @@ +<!DOCTYPE html> +<body> + <script src=/resources/testharness.js></script> + <script src=/resources/testharnessreport.js></script> + <script src="../resources/webxr_util.js"></script> + <script src="../resources/webxr_test_constants.js"></script> + + <script> + let testName = "Test that getReflectionCubeMap returns or throws appropriately without a reflection map."; + + let testFunction = (session, controller, t, sessionObjects) => new Promise((resolve) => { + let halfFloatExt = sessionObjects.gl.getExtension('OES_texture_half_float'); + // The preferredReflectionFormat used below is set to "rgba16f" by default. + // This means half float textures must be supported in order to run this test + if (!halfFloatExt) { + resolve(session.end()); + } else { + let debug = xr_debug.bind(this, 'testFunction'); + let lightProbe1 = null; + let binding1 = new XRWebGLBinding(session, sessionObjects.gl); + + // Request a default lightProbe + session.requestLightProbe({reflectionFormat: session.preferredReflectionFormat }).then((probe) => { + // Stash and end session. + lightProbe1 = probe; + + debug("Querying first pair"); + t.step(() => { + assert_equals( + binding1.getReflectionCubeMap(lightProbe1), + null, + "Active binding and light probe shouldn't throw when requesting cube map"); + }); + + return session.end(); + }).then(() => { + // Need to request a new session. + navigator.xr.test.simulateUserActivation( () => { + navigator.xr.requestSession('immersive-ar', { 'requiredFeatures': ['light-estimation'] }) + .then((newSession) => { + let newBinding = new XRWebGLBinding(newSession, sessionObjects.gl); + newSession.requestLightProbe({ reflectionFormat: newSession.preferredReflectionFormat }).then((newProbe) => { + t.step(() => { + debug("Querying second pair"); + assert_equals( + newBinding.getReflectionCubeMap(newProbe), + null, + "Newly created binding and light probe shouldn't throw"); + + debug("Querying old pair"); + assert_throws_dom( + "InvalidStateError", + () => binding1.getReflectionCubeMap(lightProbe1), + "Binding created with an ended session should throw InvalidStateError"); + debug("Querying mismatched pair"); + assert_throws_dom( + "InvalidStateError", + () => newBinding.getReflectionCubeMap(lightProbe1), + "Querying binding with a probe with a different backing session should throw InvalidStateError"); + }); + debug("losing context"); + + // Trigger a context loss and verify that we are unable to get the reflectionCubeMap. + let lose_context_ext = sessionObjects.gl.getExtension('WEBGL_lose_context'); + + sessionObjects.gl.canvas.addEventListener('webglcontextlost', (ev) => { + ev.preventDefault(); + + t.step(() => { + assert_throws_dom( + "InvalidStateError", + () => newBinding.getReflectionCubeMap(newProbe), + "Querying for reflection cube map on a binding with context loss should throw InvalidStateError"); + }); + + resolve(newSession.end()); + }); + + lose_context_ext.loseContext(); + }); // Request second light probe + }); // Request second session + }); // SimulateUserActivation + }); // .then on session end + } // halfFloatExt + }); // testFunction + + xr_session_promise_test( + testName, + testFunction, + IMMERSIVE_AR_DEVICE, + 'immersive-ar', + {'requiredFeatures': ['light-estimation']}); + + </script> +</body> |