From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/vr/test/crashtests/crashtests.list | 1 + .../crashtests/enumerate_vr_on_dying_window.html | 14 ++ dom/vr/test/mochitest/VRSimulationDriver.js | 95 ++++++++++++ dom/vr/test/mochitest/WebVRHelpers.js | 19 +++ dom/vr/test/mochitest/mochitest.ini | 31 ++++ 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 ++++++++++++++++ dom/vr/test/reftest/VRSimulationDriver.js | 60 ++++++++ dom/vr/test/reftest/change_size.html | 168 +++++++++++++++++++++ dom/vr/test/reftest/change_size.png | Bin 0 -> 1439 bytes dom/vr/test/reftest/draw_rect.html | 136 +++++++++++++++++ dom/vr/test/reftest/draw_rect.png | Bin 0 -> 1747 bytes dom/vr/test/reftest/reftest.list | 10 ++ dom/vr/test/reftest/webgl-util.js | 61 ++++++++ dom/vr/test/reftest/wrapper.html | 26 ++++ 22 files changed, 1251 insertions(+) create mode 100644 dom/vr/test/crashtests/crashtests.list create mode 100644 dom/vr/test/crashtests/enumerate_vr_on_dying_window.html 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.ini 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 create mode 100644 dom/vr/test/reftest/VRSimulationDriver.js create mode 100644 dom/vr/test/reftest/change_size.html create mode 100644 dom/vr/test/reftest/change_size.png create mode 100644 dom/vr/test/reftest/draw_rect.html create mode 100644 dom/vr/test/reftest/draw_rect.png create mode 100644 dom/vr/test/reftest/reftest.list create mode 100644 dom/vr/test/reftest/webgl-util.js create mode 100644 dom/vr/test/reftest/wrapper.html (limited to 'dom/vr/test') diff --git a/dom/vr/test/crashtests/crashtests.list b/dom/vr/test/crashtests/crashtests.list new file mode 100644 index 0000000000..8e40e0ccce --- /dev/null +++ b/dom/vr/test/crashtests/crashtests.list @@ -0,0 +1 @@ +pref(dom.vr.enabled,true) pref(dom.vr.always_support_vr,true) load enumerate_vr_on_dying_window.html diff --git a/dom/vr/test/crashtests/enumerate_vr_on_dying_window.html b/dom/vr/test/crashtests/enumerate_vr_on_dying_window.html new file mode 100644 index 0000000000..2906faa79c --- /dev/null +++ b/dom/vr/test/crashtests/enumerate_vr_on_dying_window.html @@ -0,0 +1,14 @@ + + + + + + + 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.ini b/dom/vr/test/mochitest/mochitest.ini new file mode 100644 index 0000000000..87a4174a21 --- /dev/null +++ b/dom/vr/test/mochitest/mochitest.ini @@ -0,0 +1,31 @@ +# Please confirm there is no other VR display connected. Otherwise, VRPuppetDisplay can't be attached. +[DEFAULT] +support-files = + VRSimulationDriver.js + requestPresent.js + runVRTest.js + WebVRHelpers.js +[test_vrController_displayId.html] +# Enable Linux after Bug 1310655 # TIMED_OUT for Android. +# skip-if = (os != "win" && release_or_beta) || (os == "android") +# Dependencies for re-enabling these are tracked by meta bug 1555185. +skip-if = true +[test_vrDisplay_canvas2d.html] +# skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655 +# Dependencies for re-enabling these are tracked by meta bug 1555185. +skip-if = true +[test_vrDisplay_exitPresent.html] +# skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655 +# Dependencies for re-enabling these are tracked by meta bug 1555185. +skip-if = true +[test_vrDisplay_getFrameData.html] +# Enable Linux after Bug 1310655, enable Android after Bug 1348246 +# skip-if = (os != "win" && release_or_beta) || (os == "android") +# Dependencies for re-enabling these are tracked by meta bug 1555185. +skip-if = true +[test_vrDisplay_onvrdisplayconnect.html] +skip-if = true +[test_vrDisplay_onvrdisplaydeactivate_crosscontent.html] +skip-if = true +[test_vrDisplay_requestPresent.html] +skip-if = true 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 + + + + + + + + + + +
+ + + diff --git a/dom/vr/test/reftest/VRSimulationDriver.js b/dom/vr/test/reftest/VRSimulationDriver.js new file mode 100644 index 0000000000..971cdb8626 --- /dev/null +++ b/dom/vr/test/reftest/VRSimulationDriver.js @@ -0,0 +1,60 @@ + +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) { + 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 API = { + AttachWebVRDisplay: AttachWebVRDisplay, + SetVRDisplayPose: SetVRDisplayPose, + SetEyeResolution: SetEyeResolution, + SetEyeParameter: SetEyeParameter, + SetMountState: SetMountState, + UpdateVRDisplay: UpdateVRDisplay, + + none: false +}; + +return API; + +}()); \ No newline at end of file diff --git a/dom/vr/test/reftest/change_size.html b/dom/vr/test/reftest/change_size.html new file mode 100644 index 0000000000..87d59f6a3c --- /dev/null +++ b/dom/vr/test/reftest/change_size.html @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + +
+ + + diff --git a/dom/vr/test/reftest/change_size.png b/dom/vr/test/reftest/change_size.png new file mode 100644 index 0000000000..fe03114b20 Binary files /dev/null and b/dom/vr/test/reftest/change_size.png differ diff --git a/dom/vr/test/reftest/draw_rect.html b/dom/vr/test/reftest/draw_rect.html new file mode 100644 index 0000000000..acb8580c1b --- /dev/null +++ b/dom/vr/test/reftest/draw_rect.html @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + +
+ + + diff --git a/dom/vr/test/reftest/draw_rect.png b/dom/vr/test/reftest/draw_rect.png new file mode 100644 index 0000000000..0f4d24a0d1 Binary files /dev/null and b/dom/vr/test/reftest/draw_rect.png differ diff --git a/dom/vr/test/reftest/reftest.list b/dom/vr/test/reftest/reftest.list new file mode 100644 index 0000000000..c1ca292c71 --- /dev/null +++ b/dom/vr/test/reftest/reftest.list @@ -0,0 +1,10 @@ +# WebVR Reftests +# Please confirm there is no other VR display connected. Otherwise, VRPuppetDisplay can't be attached. +defaults pref(dom.vr.enabled,true) pref(dom.vr.puppet.enabled,true) pref(dom.vr.test.enabled,true) pref(dom.vr.require-gesture,false) pref(dom.vr.puppet.submitframe,1) pref(dom.vr.display.rafMaxDuration,200) pref(dom.vr.display.enumerate.interval,0) pref(dom.vr.controller.enumerate.interval,0) +# WebVR Tests have been disabled as refactoring of gfxVRPuppet is landing. Dependencies for re-enabling these are tracked by meta bug 1555185. +# VR SubmitFrame is only implemented for D3D11.1 and MacOSX now. +# Our Windows 7 test machines don't support D3D11.1, so we run these tests on Windows 8+ only. +# skip-if((!winWidget&&release_or_beta)||Android||gtkWidget||!layersGPUAccelerated) == draw_rect.html wrapper.html?draw_rect.png +# On MacOSX platform, getting different color interpolation result. +# For lower resolution Mac hardware, we need to adjust it to fuzzy-if(cocoaWidget,0-1,0-1200). +# fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)||cocoaWidget,0-1,0-600) skip-if((!winWidget&&release_or_beta)||Android||gtkWidget||!layersGPUAccelerated) == change_size.html wrapper.html?change_size.png diff --git a/dom/vr/test/reftest/webgl-util.js b/dom/vr/test/reftest/webgl-util.js new file mode 100644 index 0000000000..42f1c5ccd5 --- /dev/null +++ b/dom/vr/test/reftest/webgl-util.js @@ -0,0 +1,61 @@ +WebGLUtil = (function() { + // --------------------------------------------------------------------------- + // WebGL helpers + + // Returns a valid shader, or null on errors. + function createShaderById(gl, id) { + var elem = document.getElementById(id); + if (!elem) { + throw new Error( + "Failed to create shader from non-existent id '" + id + "'." + ); + } + + var src = elem.innerHTML.trim(); + + var shader; + if (elem.type == "x-shader/x-fragment") { + shader = gl.createShader(gl.FRAGMENT_SHADER); + } else if (elem.type == "x-shader/x-vertex") { + shader = gl.createShader(gl.VERTEX_SHADER); + } else { + throw new Error( + "Bad MIME type for shader '" + id + "': " + elem.type + "." + ); + } + + gl.shaderSource(shader, src); + gl.compileShader(shader); + + return shader; + } + + function createProgramByIds(gl, vsId, fsId) { + var vs = createShaderById(gl, vsId); + var fs = createShaderById(gl, fsId); + if (!vs || !fs) { + return null; + } + + var prog = gl.createProgram(); + gl.attachShader(prog, vs); + gl.attachShader(prog, fs); + gl.linkProgram(prog); + + if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) { + var str = "Shader program linking failed:"; + str += "\nShader program info log:\n" + gl.getProgramInfoLog(prog); + str += "\n\nVert shader log:\n" + gl.getShaderInfoLog(vs); + str += "\n\nFrag shader log:\n" + gl.getShaderInfoLog(fs); + console.error(str); + return null; + } + + return prog; + } + + return { + createShaderById, + createProgramByIds, + }; +})(); diff --git a/dom/vr/test/reftest/wrapper.html b/dom/vr/test/reftest/wrapper.html new file mode 100644 index 0000000000..40d0de6e42 --- /dev/null +++ b/dom/vr/test/reftest/wrapper.html @@ -0,0 +1,26 @@ + + + +Image reftest wrapper + + + + + + + + -- cgit v1.2.3