Bug 1529206 [wpt PR 14804] - Enforce active lifetime of XRFrame objects, a=testonly
authorBrandon Jones <bajones@chromium.org>
Wed, 06 Mar 2019 12:31:30 +0000
changeset 464622 1244fe26b18d5d196d341382479f9def243b5f4d
parent 464621 fabf03c3df32ee82b484792597ca20cba816ecf5
child 464623 e61e1c0300f2259a30b40aa357ea522aee712cbc
push id35717
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:45:26 +0000
treeherdermozilla-central@e0861be8d6c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1529206, 14804, 1343065, 906842, 1363836, 633845
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1529206 [wpt PR 14804] - Enforce active lifetime of XRFrame objects, a=testonly Automatic update from web-platform-tests Enforce active lifetime of XRFrame objects Reland of https://chromium-review.googlesource.com/c/chromium/src/+/1343065 Incorporates fixes made by jacde@chromium.org (Thanks!) Deactivates XRFrame objects once the relevant callback returns, which causes future calls to the object methods to throw an exception. Bug: 906842 Change-Id: Ib635f56ed28b728434a08347b9d9fb98d1ecd694 Reviewed-on: https://chromium-review.googlesource.com/c/1363836 Commit-Queue: Brandon Jones <bajones@chromium.org> Reviewed-by: Klaus Weidner <klausw@chromium.org> Cr-Commit-Position: refs/heads/master@{#633845} -- wpt-commits: 91b1effe848fac6e73a203037fc333b0fff3174d wpt-pr: 14804
testing/web-platform/tests/webxr/xrFrame_lifetime.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webxr/xrFrame_lifetime.https.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<body>
+  <script src=/resources/testharness.js></script>
+  <script src=/resources/testharnessreport.js></script>
+  <script src="resources/webxr_util.js"></script>
+  <canvas></canvas>
+
+  <script>
+    let immersiveTestName = "XRFrame methods throw exceptions outside of the " +
+      "requestAnimationFrame callback for immersive sessions";
+    let nonImmersiveTestName = "XRFrame methods throw exceptions outside of the " +
+      "requestAnimationFrame callback for non-immersive sessions";
+
+    let fakeDeviceInitParams = { supportsImmersive:true };
+
+    let immersiveSessionOptions = { mode: 'immersive-vr' };
+    let nonImmersiveSessionOptions = { outputContext: getOutputContext() };
+
+    let testFunction = (testSession, testController, t) => new Promise((resolve) => {
+      let staleFrame = null;
+      let currentReferenceSpace = null;
+
+      function onFrame(time, xrFrame) {
+        t.step(() => {
+          assert_true(xrFrame instanceof XRFrame);
+        });
+
+        staleFrame = xrFrame;
+        step_timeout(afterFrame, 0);
+      }
+
+      function afterFrame() {
+        t.step(() => {
+          // Attempting to call a method on the frame outside the callback that
+          // originally provided it should cause it to throw an exception.
+          assert_throws('InvalidStateError', () => staleFrame.getViewerPose(currentReferenceSpace));
+        });
+
+        // Test does not complete until the this function has executed.
+        resolve();
+      }
+
+      testSession.requestReferenceSpace({ type: 'stationary', subtype: 'eye-level' }).then((referenceSpace) => {
+        currentReferenceSpace = referenceSpace;
+        testSession.requestAnimationFrame(onFrame);
+      });
+    });
+
+    xr_session_promise_test(immersiveTestName, testFunction,
+      fakeDeviceInitParams, immersiveSessionOptions);
+    xr_session_promise_test(nonImmersiveTestName, testFunction,
+      fakeDeviceInitParams, nonImmersiveSessionOptions);
+
+  </script>
+</body>
\ No newline at end of file