Skip to content

Commit

Permalink
Update xrSession_features_deviceSupport to use new user activations f…
Browse files Browse the repository at this point in the history
…or each session request
  • Loading branch information
Manishearth committed Jan 22, 2020
1 parent 535e05f commit 8cc7c51
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 35 deletions.
6 changes: 3 additions & 3 deletions tests/wpt/metadata/MANIFEST.json
Expand Up @@ -735150,7 +735150,7 @@
"support"
],
"webxr/resources/webxr_util.js": [
"5f66dc9573d37630d588265f20e5b57a8175766f",
"dbe1585929f50089bb3e26a981b9c12b30e9fa1f",
"support"
],
"webxr/webGLCanvasContext_create_xrcompatible.https.html": [
Expand Down Expand Up @@ -735302,7 +735302,7 @@
"testharness"
],
"webxr/xrSession_features_deviceSupport.https.html": [
"d8858bd4be689bf8e4f3a3795e13fad2a2057019",
"1ee63bae047bd196233f5e4253baec94b6a576a9",
"testharness"
],
"webxr/xrSession_input_events_end.https.html": [
Expand Down Expand Up @@ -735342,7 +735342,7 @@
"testharness"
],
"webxr/xrSession_viewer_availability.https.html": [
"c509e5f1a2a992b9329fd55e591e37fcea2b6e91",
"f28a07ad8bd0f8529b791048840bf60495186a7e",
"testharness"
],
"webxr/xrSession_viewer_referenceSpace.https.html": [
Expand Down

This file was deleted.

12 changes: 12 additions & 0 deletions tests/wpt/web-platform-tests/webxr/resources/webxr_util.js
Expand Up @@ -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.
Expand Down
Expand Up @@ -21,6 +21,7 @@
"local-floor"]
};


xr_promise_test(testName,
(t) => {
function session_resolves(sessionMode, sessionInit) {
Expand All @@ -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>
Expand Down
Expand Up @@ -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.
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 8cc7c51

Please sign in to comment.