Update xrSession_features_deviceSupport to use new user activations for each session request

This commit is contained in:
Manish Goregaokar 2020-01-14 16:41:18 +05:30
parent 535e05f7b2
commit 8cc7c51803
5 changed files with 29 additions and 35 deletions

View file

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

View file

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

View file

@ -101,6 +101,18 @@ function xr_session_promise_test(
properties); 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 // This functions calls a callback with each API object as specified
// by https://immersive-web.github.io/webxr/spec/latest/, allowing // by https://immersive-web.github.io/webxr/spec/latest/, allowing
// checks to be made on all ojects. // checks to be made on all ojects.

View file

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

View file

@ -24,14 +24,6 @@
.then(session => session.end())); .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', { return session_resolves('inline', {
// RequestSession with 'viewer' as a required featre should succeed, even // RequestSession with 'viewer' as a required featre should succeed, even
// without user activation. // without user activation.
@ -62,14 +54,14 @@
optionalFeatures: ['local'] optionalFeatures: ['local']
}); });
}) })
.then(() => simulate_user_activation(() => { .then(() => promise_simulate_user_activation(() => {
// RequestSession with unsupported optional features should succeed. // RequestSession with unsupported optional features should succeed.
return session_resolves('inline', { return session_resolves('inline', {
requiredFeatures: ['viewer'], requiredFeatures: ['viewer'],
optionalFeatures: ['local'] optionalFeatures: ['local']
}) })
})) }))
.then(() => simulate_user_activation(() => { .then(() => promise_simulate_user_activation(() => {
// Request with unsupported required features should reject. // Request with unsupported required features should reject.
return session_rejects("NotSupportedError", 'inline', { return session_rejects("NotSupportedError", 'inline', {
requiredFeatures: ['local'] requiredFeatures: ['local']