From 8cc7c5180398ad46f51036aa9876293968553074 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 14 Jan 2020 16:41:18 +0530 Subject: [PATCH] Update xrSession_features_deviceSupport to use new user activations for each session request --- tests/wpt/metadata/MANIFEST.json | 6 ++-- ...sion_features_deviceSupport.https.html.ini | 5 ---- .../webxr/resources/webxr_util.js | 12 ++++++++ ...rSession_features_deviceSupport.https.html | 29 ++++++++----------- .../xrSession_viewer_availability.https.html | 12 ++------ 5 files changed, 29 insertions(+), 35 deletions(-) delete mode 100644 tests/wpt/metadata/webxr/xrSession_features_deviceSupport.https.html.ini diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 9fbf4e053ad..d3622831fda 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -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": [ diff --git a/tests/wpt/metadata/webxr/xrSession_features_deviceSupport.https.html.ini b/tests/wpt/metadata/webxr/xrSession_features_deviceSupport.https.html.ini deleted file mode 100644 index 7bd0c101858..00000000000 --- a/tests/wpt/metadata/webxr/xrSession_features_deviceSupport.https.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[xrSession_features_deviceSupport.https.html] - expected: ERROR - [Immersive XRSession requests with no supported device should reject] - expected: TIMEOUT - diff --git a/tests/wpt/web-platform-tests/webxr/resources/webxr_util.js b/tests/wpt/web-platform-tests/webxr/resources/webxr_util.js index 5f66dc9573d..dbe1585929f 100644 --- a/tests/wpt/web-platform-tests/webxr/resources/webxr_util.js +++ b/tests/wpt/web-platform-tests/webxr/resources/webxr_util.js @@ -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. diff --git a/tests/wpt/web-platform-tests/webxr/xrSession_features_deviceSupport.https.html b/tests/wpt/web-platform-tests/webxr/xrSession_features_deviceSupport.https.html index d8858bd4be6..1ee63bae047 100644 --- a/tests/wpt/web-platform-tests/webxr/xrSession_features_deviceSupport.https.html +++ b/tests/wpt/web-platform-tests/webxr/xrSession_features_deviceSupport.https.html @@ -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); - });; - }); - }); - })); + })) + ); }); diff --git a/tests/wpt/web-platform-tests/webxr/xrSession_viewer_availability.https.html b/tests/wpt/web-platform-tests/webxr/xrSession_viewer_availability.https.html index c509e5f1a2a..f28a07ad8bd 100644 --- a/tests/wpt/web-platform-tests/webxr/xrSession_viewer_availability.https.html +++ b/tests/wpt/web-platform-tests/webxr/xrSession_viewer_availability.https.html @@ -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']