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 /testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html')
-rw-r--r-- | testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html b/testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html new file mode 100644 index 0000000000..52f4b087bc --- /dev/null +++ b/testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<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> + + function testUpdateRenderState(xrSession, deviceController, t, { gl, glLayer }) { + return new Promise((resolve, reject) => { + const baseLayer = new XRWebGLLayer(xrSession, gl); + const singleLayer = [ + new XRWebGLLayer(xrSession, gl), + ]; + const multipleLayers = [ + new XRWebGLLayer(xrSession, gl), + new XRWebGLLayer(xrSession, gl) + ]; + const duplicateLayers = [ + baseLayer, + new XRWebGLLayer(xrSession, gl), + baseLayer + ]; + const layersFeatureEnabled = xrSession.enabledFeatures.includes('layers'); + + t.step(() => { + assert_throws_dom('NotSupportedError', () => xrSession.updateRenderState({ baseLayer, layers: singleLayer }), "XRSession should throw an error when updating render state with both a baseLayer and layers set."); + }); + + t.step(() => { + const updateRenderStateMultilayer = () => xrSession.updateRenderState({ layers: multipleLayers }); + if (layersFeatureEnabled) { + try { + updateRenderStateMultilayer(); + } catch (err) { + reject("XRSession should support render state with multiple layers if the layers feature is enabled."); + } + } else { + assert_throws_dom('NotSupportedError', updateRenderStateMultilayer, "XRSession should be able to updateRenderState with multiple layers only if the layers feature is enabled."); + } + }); + + if (layersFeatureEnabled) { + t.step(() => { + assert_throws_js(TypeError, () => xrSession.updateRenderState({ layers: duplicateLayers }), "XRSession should throw a TypeError when updating render state with duplicate layers."); + }); + } + + t.step(() => { + navigator.xr.requestSession('inline', {}).then((otherSession) => { + const otherSessionLayer = [ new XRWebGLLayer(otherSession, gl) ]; + assert_throws_js(TypeError, () => xrSession.updateRenderState({ layers: otherSessionLayer }), "XRSession should throw a TypeError when updating render state with a layer created for a different session."); + resolve(); + }); + }); + }); + } + + xr_session_promise_test("Ensure XRSession throws appropriate errors when updating render state without layers feature enabled", + testUpdateRenderState, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr', {}); + + xr_session_promise_test("Ensure XRSession throws appropriate errors when updating render state with layers feature enabled", + testUpdateRenderState, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr', { requiredFeatures: ['layers'] }); + +</script> |