From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- dom/vr/test/mochitest/VRSimulationDriver.js | 95 +++++++++++++ dom/vr/test/mochitest/WebVRHelpers.js | 19 +++ dom/vr/test/mochitest/mochitest.toml | 26 ++++ dom/vr/test/mochitest/requestPresent.js | 74 +++++++++++ dom/vr/test/mochitest/runVRTest.js | 18 +++ .../mochitest/test_vrController_displayId.html | 57 ++++++++ dom/vr/test/mochitest/test_vrDisplay_canvas2d.html | 55 ++++++++ .../test/mochitest/test_vrDisplay_exitPresent.html | 51 +++++++ .../mochitest/test_vrDisplay_getFrameData.html | 148 +++++++++++++++++++++ .../test_vrDisplay_onvrdisplayconnect.html | 43 ++++++ ...Display_onvrdisplaydeactivate_crosscontent.html | 54 ++++++++ .../mochitest/test_vrDisplay_requestPresent.html | 130 ++++++++++++++++++ 12 files changed, 770 insertions(+) create mode 100644 dom/vr/test/mochitest/VRSimulationDriver.js create mode 100644 dom/vr/test/mochitest/WebVRHelpers.js create mode 100644 dom/vr/test/mochitest/mochitest.toml create mode 100644 dom/vr/test/mochitest/requestPresent.js create mode 100644 dom/vr/test/mochitest/runVRTest.js create mode 100644 dom/vr/test/mochitest/test_vrController_displayId.html create mode 100644 dom/vr/test/mochitest/test_vrDisplay_canvas2d.html create mode 100644 dom/vr/test/mochitest/test_vrDisplay_exitPresent.html create mode 100644 dom/vr/test/mochitest/test_vrDisplay_getFrameData.html create mode 100644 dom/vr/test/mochitest/test_vrDisplay_onvrdisplayconnect.html create mode 100644 dom/vr/test/mochitest/test_vrDisplay_onvrdisplaydeactivate_crosscontent.html create mode 100644 dom/vr/test/mochitest/test_vrDisplay_requestPresent.html (limited to 'dom/vr/test/mochitest') diff --git a/dom/vr/test/mochitest/VRSimulationDriver.js b/dom/vr/test/mochitest/VRSimulationDriver.js new file mode 100644 index 0000000000..5b197b88e4 --- /dev/null +++ b/dom/vr/test/mochitest/VRSimulationDriver.js @@ -0,0 +1,95 @@ +var VRServiceTest; +var vrMockDisplay; + +var VRSimulationDriver = (function () { + "use strict"; + + var AttachWebVRDisplay = function () { + if (vrMockDisplay) { + // Avoid creating multiple displays + return Promise.resolve(vrMockDisplay); + } + var promise = VRServiceTest.attachVRDisplay("VRDisplayTest"); + promise.then(function (display) { + assert_true(display != null, "AttachWebVRDisplay should success."); + vrMockDisplay = display; + }); + + return promise; + }; + + var SetVRDisplayPose = function ( + position, + linearVelocity, + linearAcceleration, + orientation, + angularVelocity, + angularAcceleration + ) { + vrMockDisplay.setPose( + position, + linearVelocity, + linearAcceleration, + orientation, + angularVelocity, + angularAcceleration + ); + }; + + var SetEyeResolution = function (width, height) { + vrMockDisplay.setEyeResolution(width, height); + }; + + var SetEyeParameter = function ( + eye, + offsetX, + offsetY, + offsetZ, + upDegree, + rightDegree, + downDegree, + leftDegree + ) { + vrMockDisplay.setEyeParameter( + eye, + offsetX, + offsetY, + offsetZ, + upDegree, + rightDegree, + downDegree, + leftDegree + ); + }; + + var SetMountState = function (isMounted) { + vrMockDisplay.setMountState(isMounted); + }; + + var UpdateVRDisplay = function () { + vrMockDisplay.update(); + }; + + var AttachVRController = function () { + var promise = VRServiceTest.attachVRController("VRControllerTest"); + promise.then(function (controller) { + assert_true(controller != null, "AttachVRController should success."); + }); + + return promise; + }; + + var API = { + AttachWebVRDisplay, + SetVRDisplayPose, + SetEyeResolution, + SetEyeParameter, + SetMountState, + UpdateVRDisplay, + AttachVRController, + + none: false, + }; + + return API; +})(); diff --git a/dom/vr/test/mochitest/WebVRHelpers.js b/dom/vr/test/mochitest/WebVRHelpers.js new file mode 100644 index 0000000000..e19294a236 --- /dev/null +++ b/dom/vr/test/mochitest/WebVRHelpers.js @@ -0,0 +1,19 @@ +var WebVRHelpers = (function () { + "use strict"; + + var RequestPresentOnVRDisplay = function (vrDisplay, vrLayers, callback) { + if (callback) { + callback(); + } + + return vrDisplay.requestPresent(vrLayers); + }; + + var API = { + RequestPresentOnVRDisplay, + + none: false, + }; + + return API; +})(); diff --git a/dom/vr/test/mochitest/mochitest.toml b/dom/vr/test/mochitest/mochitest.toml new file mode 100644 index 0000000000..ce2d4347d3 --- /dev/null +++ b/dom/vr/test/mochitest/mochitest.toml @@ -0,0 +1,26 @@ +[DEFAULT] +skip-if = ["true"] # Dependencies for re-enabling these are tracked by meta bug 1555185 +support-files = [ + "VRSimulationDriver.js", + "requestPresent.js", + "runVRTest.js", + "WebVRHelpers.js", +] + +["test_vrController_displayId.html"] +# Enable Linux after Bug 1310655 # TIMED_OUT for Android. + +["test_vrDisplay_canvas2d.html"] +# skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655 + +["test_vrDisplay_exitPresent.html"] +# skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655 + +["test_vrDisplay_getFrameData.html"] +# Enable Linux after Bug 1310655, enable Android after Bug 1348246 + +["test_vrDisplay_onvrdisplayconnect.html"] + +["test_vrDisplay_onvrdisplaydeactivate_crosscontent.html"] + +["test_vrDisplay_requestPresent.html"] 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); +} diff --git a/dom/vr/test/mochitest/runVRTest.js b/dom/vr/test/mochitest/runVRTest.js new file mode 100644 index 0000000000..c15003a6c3 --- /dev/null +++ b/dom/vr/test/mochitest/runVRTest.js @@ -0,0 +1,18 @@ +function runVRTest(callback) { + SpecialPowers.pushPrefEnv( + { + set: [ + ["dom.vr.enabled", true], + ["dom.vr.puppet.enabled", true], + ["dom.vr.require-gesture", false], + ["dom.vr.test.enabled", true], + ["dom.vr.display.enumerate.interval", 0], + ["dom.vr.controller.enumerate.interval", 0], + ], + }, + () => { + VRServiceTest = navigator.requestVRServiceTest(); + callback(); + } + ); +} diff --git a/dom/vr/test/mochitest/test_vrController_displayId.html b/dom/vr/test/mochitest/test_vrController_displayId.html new file mode 100644 index 0000000000..e69e3920d2 --- /dev/null +++ b/dom/vr/test/mochitest/test_vrController_displayId.html @@ -0,0 +1,57 @@ + + + + VRController DisplayId + + + + + + + + + + + diff --git a/dom/vr/test/mochitest/test_vrDisplay_canvas2d.html b/dom/vr/test/mochitest/test_vrDisplay_canvas2d.html new file mode 100644 index 0000000000..4d20e21352 --- /dev/null +++ b/dom/vr/test/mochitest/test_vrDisplay_canvas2d.html @@ -0,0 +1,55 @@ + + + + VRDisplay Canvas2D + + + + + + + + + + + diff --git a/dom/vr/test/mochitest/test_vrDisplay_exitPresent.html b/dom/vr/test/mochitest/test_vrDisplay_exitPresent.html new file mode 100644 index 0000000000..dc2c700723 --- /dev/null +++ b/dom/vr/test/mochitest/test_vrDisplay_exitPresent.html @@ -0,0 +1,51 @@ + + + + VRDisplay ExitPresent + + + + + + + + + + + + + + diff --git a/dom/vr/test/mochitest/test_vrDisplay_getFrameData.html b/dom/vr/test/mochitest/test_vrDisplay_getFrameData.html new file mode 100644 index 0000000000..c8a986ae8e --- /dev/null +++ b/dom/vr/test/mochitest/test_vrDisplay_getFrameData.html @@ -0,0 +1,148 @@ + + + + VRDisplay GetFrameData + + + + + + + + + + + + + diff --git a/dom/vr/test/mochitest/test_vrDisplay_onvrdisplayconnect.html b/dom/vr/test/mochitest/test_vrDisplay_onvrdisplayconnect.html new file mode 100644 index 0000000000..e1912c7c41 --- /dev/null +++ b/dom/vr/test/mochitest/test_vrDisplay_onvrdisplayconnect.html @@ -0,0 +1,43 @@ + + + VRDisplay onvrdisplayconnect test + + + + + + + + + + + + + + diff --git a/dom/vr/test/mochitest/test_vrDisplay_onvrdisplaydeactivate_crosscontent.html b/dom/vr/test/mochitest/test_vrDisplay_onvrdisplaydeactivate_crosscontent.html new file mode 100644 index 0000000000..6c58e5efd1 --- /dev/null +++ b/dom/vr/test/mochitest/test_vrDisplay_onvrdisplaydeactivate_crosscontent.html @@ -0,0 +1,54 @@ + + + VRDisplay onvrdisplaydeactivate Crosscontent test + + + + + + + + + + + + + + + diff --git a/dom/vr/test/mochitest/test_vrDisplay_requestPresent.html b/dom/vr/test/mochitest/test_vrDisplay_requestPresent.html new file mode 100644 index 0000000000..4d021b6e0f --- /dev/null +++ b/dom/vr/test/mochitest/test_vrDisplay_requestPresent.html @@ -0,0 +1,130 @@ + + + + VRDisplay RequestPresent + + + + + + + + + + +
+ + + -- cgit v1.2.3