Bug 1529206 [wpt PR 14804] - Enforce active lifetime of XRFrame objects, a=testonly
☠☠ backed out by 66b1aba3fb43 ☠ ☠
authorBrandon Jones <bajones@chromium.org>
Wed, 06 Mar 2019 12:31:30 +0000
changeset 522240 37d25235012d48b5b9fc84498be314023635cc12
parent 522239 373ccecf93ea65ef818925ea6ae6bd04ecff5b18
child 522241 719455274599350ee611a03e27ca26f22299d7b5
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [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