diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/vr/test/mochitest/requestPresent.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/vr/test/mochitest/requestPresent.js')
-rw-r--r-- | dom/vr/test/mochitest/requestPresent.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/dom/vr/test/mochitest/requestPresent.js b/dom/vr/test/mochitest/requestPresent.js new file mode 100644 index 0000000000..a2f9dd4d11 --- /dev/null +++ b/dom/vr/test/mochitest/requestPresent.js @@ -0,0 +1,74 @@ +// requestPresent.js +// +// This file provides helpers for testing VRDisplay requestPresent. + +function attachVRDisplay(test) { + assert_equals( + typeof navigator.getVRDisplays, + "function", + "'navigator.getVRDisplays()' must be defined." + ); + return VRSimulationDriver.AttachWebVRDisplay(); +} + +function setupVRDisplay(test) { + assert_equals( + typeof navigator.getVRDisplays, + "function", + "'navigator.getVRDisplays()' must be defined." + ); + return VRSimulationDriver.AttachWebVRDisplay() + .then(() => { + return navigator.getVRDisplays(); + }) + .then(displays => { + assert_equals( + displays.length, + 1, + "displays.length must be one after attach." + ); + vrDisplay = displays[0]; + return validateNewVRDisplay(test, vrDisplay); + }); +} + +// Validate the settings off a freshly created VRDisplay (prior to calling +// requestPresent). +function validateNewVRDisplay(test, display) { + assert_true( + display.capabilities.canPresent, + "display.capabilities.canPresent must always be true for HMDs." + ); + assert_equals( + display.capabilities.maxLayers, + 1, + "display.capabilities.maxLayers must always be 1 when display.capabilities.canPresent is true for current spec revision." + ); + assert_false( + display.isPresenting, + "display.isPresenting must be false before calling requestPresent." + ); + assert_equals( + display.getLayers().length, + 0, + "display.getLayers() should have no layers if not presenting." + ); + var promise = display.exitPresent(); + return promise_rejects(test, null, promise); +} + +// Validate the settings off a VRDisplay after requestPresent promise is +// rejected or after exitPresent is fulfilled. +function validateDisplayNotPresenting(test, display) { + assert_false( + display.isPresenting, + "display.isPresenting must be false if requestPresent is rejected or after exitPresent is fulfilled." + ); + assert_equals( + display.getLayers().length, + 0, + "display.getLayers() should have no layers if requestPresent is rejected or after exitPresent is fulfilled." + ); + var promise = display.exitPresent(); + return promise_rejects(test, null, promise); +} |