Bug 1573257 [wpt PR 18338] - Recreate XRInputSource when profiles change., a=testonly
authorJacob DeWitt <jacde@chromium.org>
Wed, 14 Aug 2019 10:57:34 +0000
changeset 488125 bae1cdaf20c87243d9da5bd5c633ad9175aa59bd
parent 488124 e4abe7c75be52ed20c1727eda0fdc6d0c7dd2676
child 488126 7982193408a52625ab69541709d2bca93d9e6d64
push id36435
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:46:49 +0000
treeherdermozilla-central@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1573257, 18338, 989244, 1744663, 686103
milestone70.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 1573257 [wpt PR 18338] - Recreate XRInputSource when profiles change., a=testonly Automatic update from web-platform-tests Recreate XRInputSource when profiles change. Based on discussion at https://github.com/immersive-web/webxr/issues/783 , we are confident this will become a requirement in the WebXR spec. Also update the OpenVR render loop to re-send the input source description when the profiles array is updated. Bug: 989244 Change-Id: I77bb2b15d894fe41c532235b062163bdc87a4ea2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1744663 Reviewed-by: Brian Sheedy <bsheedy@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Commit-Queue: Jacob DeWitt <jacde@chromium.org> Cr-Commit-Position: refs/heads/master@{#686103} -- wpt-commits: f6819af5e6f4fa46c3c325faf2cfb060b2ac7914 wpt-pr: 18338
testing/web-platform/tests/webxr/events_input_source_recreation.https.html
--- a/testing/web-platform/tests/webxr/events_input_source_recreation.https.html
+++ b/testing/web-platform/tests/webxr/events_input_source_recreation.https.html
@@ -26,38 +26,58 @@ let testFunction = function(session, fak
       if (inputChangeEvents == 1) {
         // The first change event should be adding our controller.
         validateAdded(event.added, 1);
         validateRemoved(event.removed, 0);
         cached_input_source = getInputSources()[0];
         assert_not_equals(cached_input_source, null);
         assert_equals(cached_input_source.handedness, "none");
         assert_equals(cached_input_source.targetRayMode, "gaze");
+        assertProfilesEqual(cached_input_source.profiles, ["a", "b"]);
       } else if (inputChangeEvents == 2) {
         // The second event should be replacing the controller with one that has
         // the updated target ray mode.
-        validateInputSourceChange(event, "none", "tracked-pointer");
+        validateInputSourceChange(event, "none", "tracked-pointer", ["a", "b"]);
         cached_input_source = getInputSources()[0];
       } else if (inputChangeEvents == 3) {
         // The third event should be replacing the controller with one that has
         // the updated handedness.
-        validateInputSourceChange(event, "left", "tracked-pointer");
+        validateInputSourceChange(event, "left", "tracked-pointer", ["a", "b"]);
+        cached_input_source = getInputSources()[0];
+      } else if (inputChangeEvents == 4) {
+        // The fourth event should be updating the second value in the profiles
+        // array.
+        validateInputSourceChange(event, "left", "tracked-pointer", ["a", "c"]);
+        cached_input_source = getInputSources()[0];
+      } else if (inputChangeEvents == 5) {
+        // The fifth event should be removing the second value from the profiles
+        // array.
+        validateInputSourceChange(event, "left", "tracked-pointer", ["a"]);
         session.dispatchEvent(watcherDone);
       }
     });
   }
 
-  function validateInputSourceChange(event, expected_hand, expected_mode) {
+  function assertProfilesEqual(profiles, expected_profiles) {
+    assert_equals(profiles.length, expected_profiles.length);
+    for (let i = 0; i < profiles.length; ++i) {
+      assert_equals(profiles[i], expected_profiles[i]);
+    }
+  }
+
+  function validateInputSourceChange(
+      event, expected_hand, expected_mode, expected_profiles) {
     validateAdded(event.added, 1);
     validateRemoved(event.removed, 1);
     assert_true(event.removed.includes(cached_input_source));
     assert_false(event.added.includes(cached_input_source));
     let source = event.added[0];
     assert_equals(source.handedness, expected_hand);
     assert_equals(source.targetRayMode, expected_mode);
+    assertProfilesEqual(source.profiles, expected_profiles);
   }
 
   function validateAdded(added, length) {
     t.step(() => {
       assert_not_equals(added, null);
       assert_equals(added.length, length,
           "Added length matches expectations");
 
@@ -90,27 +110,34 @@ let testFunction = function(session, fak
   session.addEventListener('inputsourceschange', onInputSourcesChange, false);
 
   // Create a gaze based input source with no handedness that we can change
   // to validate SameObject properties.
   let input_source = fakeDeviceController.simulateInputSourceConnection({
     handedness: "none",
     targetRayMode: "gaze",
     pointerOrigin: VALID_POINTER_TRANSFORM,
-    profiles: []
+    profiles: ["a", "b"]
   });
 
-  // Make our input source change after one frame, and wait an additional
-  // frame for that change to propogate.
-  // Two changes made in total.
+  // Make our first input source change after one frame, and wait an additional
+  // frame for that change to propogate. Then make additional changes, waiting
+  // one frame after each one to verify that they fired an inputsourceschanged
+  // event.
   session.requestAnimationFrame((time, xrFrame) => {
     input_source.setTargetRayMode("tracked-pointer");
     session.requestAnimationFrame((time, xrFrame) => {
       input_source.setHandedness("left");
-      session.requestAnimationFrame((time, xrFrame) => {});
+      session.requestAnimationFrame((time, xrFrame) => {
+        input_source.setProfiles(["a", "c"]);
+        session.requestAnimationFrame((time, xrFrame) => {
+          input_source.setProfiles(["a"]);
+          session.requestAnimationFrame((time, xrFrame) => {});
+        });
+      });
     });
   });
 
   return eventPromise;
 };
 
 xr_session_promise_test(
   testName, testFunction, fakeDeviceInitParams, 'immersive-vr');