Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable XR WPT tests #23786

Merged
merged 7 commits into from Jul 17, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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
}
@@ -151,7 +151,7 @@ impl XRSession {
}
}

// Step 9: XXXManishearth unset `active` bool on `frame`
frame.set_active(false);
self.session.borrow_mut().render_animation_frame();
}
}
@@ -288,6 +288,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));
@@ -131,6 +131,8 @@ skip: true
skip: false
[webvr]
skip: false
[webxr]
skip: false
[WebIDL]
skip: false
[websockets]
"testharness"
],
"webxr/xrFrame_getPose.https.html": [
"50e8abf145b98730f4859c5ccd2ded4eb38d57ba",
"313cd11c32005abdfa4686bc857e514ee4a29f75",
"testharness"
],
"webxr/xrFrame_lifetime.https.html": [
@@ -0,0 +1 @@
prefs: ["dom.webxr.enabled:true", "dom.webxr.test:true"]
@@ -0,0 +1,7 @@
[events_referenceSpace_reset.https.html]
[XRSession resetpose from a device properly fires off the right events for non-immersive sessions]
expected: FAIL

[XRSession resetpose from a device properly fires off the right events for immersive sessions]
expected: FAIL

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.