mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #23786 - Manishearth:xr-wpt, r=asajeffrey
Enable XR WPT tests This enables the tests. Most still fail, I plan to go through the failures more soon. xrFrame_getPose's failure seems to indicate we have broken matrix math. I'm not sure what, the bug seems to not come from a simple matrix inversion/ordering mishap. This does add empty stubs for session ending since the test infra relies on these existing for almost every test (https://github.com/servo/servo/issues/23788). We will need to add support for this from the webxr repo side. We also need to add support for user activation (https://github.com/servo/servo/issues/23787). r? @asajeffrey <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23786) <!-- Reviewable:end -->
This commit is contained in:
commit
b6cc0f60a9
44 changed files with 460 additions and 24 deletions
|
@ -6,8 +6,8 @@
|
|||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XR: EventTarget {
|
||||
// Methods
|
||||
Promise<void> supportsSessionMode(XRSessionMode mode);
|
||||
Promise<XRSession> requestSession(optional XRSessionCreationOptions parameters = {});
|
||||
Promise<void> supportsSession(XRSessionMode mode);
|
||||
Promise<XRSession> requestSession(XRSessionMode mode, optional XRSessionInit parameters = {});
|
||||
|
||||
// Events
|
||||
// attribute EventHandler ondevicechange;
|
||||
|
@ -24,9 +24,9 @@ enum XRSessionMode {
|
|||
"immersive-ar"
|
||||
};
|
||||
|
||||
dictionary XRSessionCreationOptions {
|
||||
XRSessionMode mode = "inline";
|
||||
// XRPresentationContext outputContext;
|
||||
dictionary XRSessionInit {
|
||||
sequence<DOMString> requiredFeatures;
|
||||
sequence<DOMString> optionalFeatures;
|
||||
};
|
||||
|
||||
partial interface XR {
|
||||
|
|
|
@ -33,7 +33,7 @@ interface XRSession : EventTarget {
|
|||
long requestAnimationFrame(XRFrameRequestCallback callback);
|
||||
void cancelAnimationFrame(long handle);
|
||||
|
||||
// Promise<void> end();
|
||||
Promise<void> end();
|
||||
|
||||
// // Events
|
||||
// attribute EventHandler onblur;
|
||||
|
|
|
@ -13,10 +13,10 @@ interface XRTest {
|
|||
// // Simulates a user activation (aka user gesture) for the current scope.
|
||||
// // The activation is only guaranteed to be valid in the provided function and only applies to WebXR
|
||||
// // Device API methods.
|
||||
// void simulateUserActivation(Function);
|
||||
void simulateUserActivation(Function f);
|
||||
|
||||
// // Disconnect all fake devices
|
||||
// Promise<void> disconnectAllDevices();
|
||||
Promise<void> disconnectAllDevices();
|
||||
};
|
||||
|
||||
dictionary FakeXRDeviceInit {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
enum XREye {
|
||||
"left",
|
||||
"right",
|
||||
"unknown",
|
||||
"none",
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::compartments::InCompartment;
|
|||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionCreationOptions;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionInit;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding::{XRMethods, XRSessionMode};
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
|
@ -96,7 +96,7 @@ impl Into<SessionMode> for XRSessionMode {
|
|||
|
||||
impl XRMethods for XR {
|
||||
/// https://immersive-web.github.io/webxr/#dom-xr-supportssessionmode
|
||||
fn SupportsSessionMode(&self, mode: XRSessionMode, comp: InCompartment) -> Rc<Promise> {
|
||||
fn SupportsSession(&self, mode: XRSessionMode) -> Rc<Promise> {
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct SupportsSession {
|
||||
sender: IpcSender<bool>,
|
||||
|
@ -110,7 +110,7 @@ impl XRMethods for XR {
|
|||
}
|
||||
|
||||
// XXXManishearth this should select an XR device first
|
||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||
let promise = Promise::new(&self.global());
|
||||
let mut trusted = Some(TrustedPromise::new(promise.clone()));
|
||||
let global = self.global();
|
||||
let window = global.as_window();
|
||||
|
@ -152,7 +152,8 @@ impl XRMethods for XR {
|
|||
/// https://immersive-web.github.io/webxr/#dom-xr-requestsession
|
||||
fn RequestSession(
|
||||
&self,
|
||||
options: &XRSessionCreationOptions,
|
||||
mode: XRSessionMode,
|
||||
_: &XRSessionInit,
|
||||
comp: InCompartment,
|
||||
) -> Rc<Promise> {
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
|
@ -167,7 +168,7 @@ impl XRMethods for XR {
|
|||
}
|
||||
}
|
||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||
if options.mode != XRSessionMode::Immersive_vr {
|
||||
if mode != XRSessionMode::Immersive_vr {
|
||||
promise.reject_error(Error::NotSupported);
|
||||
return promise;
|
||||
}
|
||||
|
@ -210,7 +211,7 @@ impl XRMethods for XR {
|
|||
);
|
||||
window
|
||||
.webxr_registry()
|
||||
.request_session(options.mode.into(), RequestSession { sender });
|
||||
.request_session(mode.into(), RequestSession { sender });
|
||||
|
||||
promise
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ impl XRSession {
|
|||
}
|
||||
}
|
||||
|
||||
// Step 9: XXXManishearth unset `active` bool on `frame`
|
||||
frame.set_active(false);
|
||||
self.session.borrow_mut().render_animation_frame();
|
||||
|
||||
// If the canvas element is attached to the DOM, it is now dirty,
|
||||
|
@ -302,6 +302,14 @@ impl XRSessionMethods for XRSession {
|
|||
.map(|x| DomRoot::from_ref(&**x))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-end
|
||||
fn End(&self) -> Rc<Promise> {
|
||||
// XXXManishearth implement device disconnection and session ending
|
||||
let p = Promise::new(&self.global());
|
||||
p.resolve_native(&());
|
||||
p
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||
use crate::dom::bindings::codegen::Bindings::XRTestBinding::{
|
||||
self, FakeXRDeviceInit, XRTestMethods,
|
||||
};
|
||||
|
@ -162,4 +164,18 @@ impl XRTestMethods for XRTest {
|
|||
|
||||
p
|
||||
}
|
||||
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn SimulateUserActivation(&self, f: Rc<Function>) {
|
||||
// XXXManishearth actually check for activation in XRSession
|
||||
let _ = f.Call__(vec![], ExceptionHandling::Rethrow);
|
||||
}
|
||||
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn DisconnectAllDevices(&self) -> Rc<Promise> {
|
||||
// XXXManishearth implement device disconnection and session ending
|
||||
let p = Promise::new(&self.global());
|
||||
p.resolve_native(&());
|
||||
p
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ impl XRViewerPose {
|
|||
rooted_vec!(let mut views);
|
||||
session.with_session(|s| match s.views() {
|
||||
Views::Mono(view) => {
|
||||
views.push(XRView::new(global, session, &view, XREye::Unknown, &pose))
|
||||
views.push(XRView::new(global, session, &view, XREye::None, &pose))
|
||||
},
|
||||
Views::Stereo(left, right) => {
|
||||
views.push(XRView::new(global, session, &left, XREye::Left, &pose));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue