Auto merge of #25504 - Manishearth:features, r=asajeffrey

Support features in webxr

Based on https://github.com/servo/webxr/pull/119

Todo:
 - [x] gate reference space creation on feature presence
 - [x] Fix the `features_deviceSupport` test to correctly use simulateUserActivation

Fixes #24196, #24270
r? @jdm @asajeffrey
This commit is contained in:
bors-servo 2020-01-21 23:19:40 -05:00 committed by GitHub
commit ee3fb92e53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 222 additions and 93 deletions

View file

@ -735150,7 +735150,7 @@
"support"
],
"webxr/resources/webxr_util.js": [
"5f66dc9573d37630d588265f20e5b57a8175766f",
"dbe1585929f50089bb3e26a981b9c12b30e9fa1f",
"support"
],
"webxr/webGLCanvasContext_create_xrcompatible.https.html": [
@ -735302,7 +735302,7 @@
"testharness"
],
"webxr/xrSession_features_deviceSupport.https.html": [
"d8858bd4be689bf8e4f3a3795e13fad2a2057019",
"1ee63bae047bd196233f5e4253baec94b6a576a9",
"testharness"
],
"webxr/xrSession_input_events_end.https.html": [
@ -735342,7 +735342,7 @@
"testharness"
],
"webxr/xrSession_viewer_availability.https.html": [
"c509e5f1a2a992b9329fd55e591e37fcea2b6e91",
"f28a07ad8bd0f8529b791048840bf60495186a7e",
"testharness"
],
"webxr/xrSession_viewer_referenceSpace.https.html": [

View file

@ -1,5 +0,0 @@
[events_input_source_recreation.https.html]
expected: ERROR
[Input sources are re-created when handedness or target ray mode changes]
expected: FAIL

View file

@ -1,5 +0,0 @@
[getInputPose_handedness.https.html]
expected: ERROR
[XRInputSources properly communicate their handedness]
expected: TIMEOUT

View file

@ -95,9 +95,6 @@
[XRReferenceSpaceEvent interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[XRInputSource interface: attribute profiles]
expected: FAIL
[XR interface: operation requestSession(XRSessionMode, XRSessionInit)]
expected: FAIL

View file

@ -1,4 +0,0 @@
[xrDevice_requestSession_immersive_unsupported.https.html]
[Requesting an immersive session when unsupported rejects]
expected: FAIL

View file

@ -1,4 +0,0 @@
[xrInputSource_profiles.https.html]
[WebXR InputSource's profiles list can be set]
expected: FAIL

View file

@ -1,4 +0,0 @@
[xrSession_features_deviceSupport.https.html]
[Immersive XRSession requests with no supported device should reject]
expected: FAIL

View file

@ -1,5 +1,5 @@
[xrSession_input_events_end.https.html]
expected: TIMEOUT
[Calling end during an input callback stops processing at the right time]
expected: TIMEOUT
expected: FAIL

View file

@ -1,7 +0,0 @@
[xrSession_requestReferenceSpace_features.https.html]
[Immersive session rejects local-floor space if not requested]
expected: FAIL
[Non-immersive session rejects local space if not requested]
expected: FAIL

View file

@ -1,5 +0,0 @@
[xrSession_sameObject.https.html]
expected: ERROR
[XRSession attributes meet [SameObject\] requirement]
expected: TIMEOUT

View file

@ -101,6 +101,18 @@ function xr_session_promise_test(
properties);
}
// This function wraps the provided function in a
// simulateUserActivation() call, and resolves the promise with the
// result of func(), or an error if one is thrown
function promise_simulate_user_activation(func) {
return new Promise((resolve, reject) => {
navigator.xr.test.simulateUserActivation(() => {
try { let a = func(); resolve(a); } catch(e) { reject(e); }
});
});
}
// This functions calls a callback with each API object as specified
// by https://immersive-web.github.io/webxr/spec/latest/, allowing
// checks to be made on all ojects.

View file

@ -21,6 +21,7 @@
"local-floor"]
};
xr_promise_test(testName,
(t) => {
function session_resolves(sessionMode, sessionInit) {
@ -31,34 +32,28 @@
}
return navigator.xr.test.simulateDeviceConnection(fakeDeviceInitParams)
.then((controller) => new Promise((resolve, reject) => {
navigator.xr.test.simulateUserActivation(() => {
.then((controller) =>
promise_simulate_user_activation(() => {
// Attempting to request required features that aren't supported by
// the device should reject.
promise_rejects(t, "NotSupportedError",
return promise_rejects(t, "NotSupportedError",
navigator.xr.requestSession("immersive-vr", {
requiredFeatures: ['bounded-floor']
}))
.then(() => {
}).then(() => promise_simulate_user_activation(() => {
// Attempting to request with an unsupported feature as optional
// should succeed
return session_resolves("immersive-vr", {
optionalFeatures: ['bounded-floor']
});
})).then(() => promise_simulate_user_activation(() => {
// Attempting to request with supported features only should succeed.
return session_resolves("immersive-vr", {
requiredFeatures: ['local', 'local-floor']
})
.then(() => {
// Attempting to request with supported features only should succeed.
return session_resolves("immersive-vr", {
requiredFeatures: ['local', 'local-floor']
})
.then(() => {
resolve();
}).catch((err) => {
reject(err);
});;
});
});
}));
}))
);
});
</script>

View file

@ -24,14 +24,6 @@
.then(session => session.end()));
}
function simulate_user_activation(func) {
return new Promise((resolve, reject) => {
navigator.xr.test.simulateUserActivation(() => {
try { resolve(func()); } catch(e) { reject(e); }
});
});
}
return session_resolves('inline', {
// RequestSession with 'viewer' as a required featre should succeed, even
// without user activation.
@ -62,14 +54,14 @@
optionalFeatures: ['local']
});
})
.then(() => simulate_user_activation(() => {
.then(() => promise_simulate_user_activation(() => {
// RequestSession with unsupported optional features should succeed.
return session_resolves('inline', {
requiredFeatures: ['viewer'],
optionalFeatures: ['local']
})
}))
.then(() => simulate_user_activation(() => {
.then(() => promise_simulate_user_activation(() => {
// Request with unsupported required features should reject.
return session_rejects("NotSupportedError", 'inline', {
requiredFeatures: ['local']