Bug 1480475 [wpt PR 12279] - Refactor vr_display_host into xr_device_impl, a=testonly
authorAnna Offenwanger <offenwanger@chromium.org>
Thu, 16 Aug 2018 21:56:46 +0000
changeset 487256 7c7f7bcb1ffd5617b3f86ce58f38804da8bf0a80
parent 487255 b6cd1e646ed9cc64d2f1dd34eeb3a36560ad0b3c
child 487257 578bfc018d3d055f4803e76924cc0595afc21bce
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1480475, 12279, 842025, 701027, 1159468, 583362
milestone63.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 1480475 [wpt PR 12279] - Refactor vr_display_host into xr_device_impl, a=testonly Automatic update from web-platform-testsRefactor vr_display_host into xr_device_impl Refactoring vr_display_host into xr_device_impl, and making it so that there is only one XRDeviceImpl, inline with what the WebXR spec expects. The xr_device_impl is not returned until requested, which is a step towards making the renderer not expect runtimes to be available until requested. Bug: 842025, 701027 Cq-Include-Trybots: luci.chromium.try​:android_optional_gpu_tests_rel;luci.chromium.try​:linux_optional_gpu_tests_rel;luci.chromium.try​:linux_vr;luci.chromium.try​:mac_optional_gpu_tests_rel;luci.chromium.try​:win_optional_gpu_tests_rel Change-Id: Iedb7dd4956ae1d98a9ae7811948ae645899df423 Reviewed-on: https://chromium-review.googlesource.com/1159468 Commit-Queue: Anna Offenwanger <offenwanger@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Bill Orr <billorr@chromium.org> Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org> Reviewed-by: Brian Sheedy <bsheedy@chromium.org> Cr-Commit-Position: refs/heads/master@{#583362} -- wpt-commits: ee2a6369665278d734892a0c1a3f92755c7fc8ca wpt-pr: 12279
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/resources/chromium/webxr-test.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -626533,17 +626533,17 @@
    "94db93d31e389aa2aa525d82feb57ff414d0426b",
    "support"
   ],
   "resources/chromium/webusb-test.js.headers": [
    "6805c323df5a975231648b830e33ce183c3cbbd3",
    "support"
   ],
   "resources/chromium/webxr-test.js": [
-   "d760e7c76d3050973e365021766cb00488b16156",
+   "10ed703e01b7efe434333a9c69ac27be1aa0cc08",
    "support"
   ],
   "resources/chromium/webxr-test.js.headers": [
    "6805c323df5a975231648b830e33ce183c3cbbd3",
    "support"
   ],
   "resources/idlharness.js": [
    "379785cd68517fe40d4b28d2dc6e2f8e63ea4af7",
--- a/testing/web-platform/tests/resources/chromium/webxr-test.js
+++ b/testing/web-platform/tests/resources/chromium/webxr-test.js
@@ -42,66 +42,60 @@ class MockVRService {
     this.interceptor_.start();
   }
 
   // Test methods
   addDevice(fakeDeviceInit) {
     let device = new MockDevice(fakeDeviceInit, this);
     this.devices_.push(device);
 
+    if (this.client_) {
+      this.client_.onDeviceChanged();
+    }
+
     return device;
   }
 
   // VRService implementation.
+  requestDevice() {
+    return Promise.resolve(
+        {device: this.devices_[0] ? this.devices_[0].getDevicePtr() : null});
+  }
+
   setClient(client) {
     this.client_ = client;
-    for (let i = 0; i < this.devices_.length; i++) {
-      this.devices_[i].notifyClientOfDisplay();
-    }
-
-    return Promise.resolve();
   }
 }
 
-// Implements both XRDeviceImpl and VRMagicWindowProvider. Maintains a mock for
+// Implements both XRDevice and VRMagicWindowProvider. Maintains a mock for
 // XRPresentationProvider.
 class MockDevice {
   constructor(fakeDeviceInit, service) {
-    this.displayClient_ = new device.mojom.VRDisplayClientPtr();
+    this.sessionClient_ = new device.mojom.XRSessionClientPtr();
     this.presentation_provider_ = new MockXRPresentationProvider();
 
     this.pose_ = null;
     this.next_frame_id_ = 0;
 
     this.service_ = service;
 
     this.framesOfReference = {};
 
     if (fakeDeviceInit.supportsImmersive) {
       this.displayInfo_ = this.getImmersiveDisplayInfo();
     } else {
       this.displayInfo_ = this.getNonImmersiveDisplayInfo();
     }
-
-    if (service.client_) {
-      this.notifyClientOfDisplay();
-    }
   }
 
   // Functions for setup.
-  // This function calls to the backend to add this device to the list.
-  notifyClientOfDisplay() {
+  getDevicePtr() {
     let devicePtr = new device.mojom.XRDevicePtr();
-    let deviceRequest = mojo.makeRequest(devicePtr);
-    let deviceBinding =
-        new mojo.Binding(device.mojom.XRDevice, this, deviceRequest);
-
-    let clientRequest = mojo.makeRequest(this.displayClient_);
-    this.service_.client_.onDisplayConnected(
-        devicePtr, clientRequest, this.displayInfo_);
+    new mojo.Binding(device.mojom.XRDevice, this, mojo.makeRequest(devicePtr));
+    return devicePtr;
   }
 
   // Test methods.
   setXRPresentationFrameData(poseMatrix, views) {
     if (poseMatrix == null) {
       this.pose_ = null;
     } else {
       this.setPoseFromMatrix(poseMatrix);
@@ -115,17 +109,17 @@ class MockDevice {
           changed = true;
         } else if (views[i].eye == 'right') {
           this.displayInfo_.rightEye = this.getEye(views[i]);
           changed = true;
         }
       }
 
       if (changed) {
-        this.displayClient_.onChanged(this.displayInfo_);
+        this.sessionClient_.onChanged(this.displayInfo_);
       }
     }
   }
 
 
   setPoseFromMatrix(poseMatrix) {
     this.pose_ = {
       orientation: null,
@@ -274,18 +268,17 @@ class MockDevice {
     });
   }
 
   updateSessionGeometry(frame_size, display_rotation) {
     // This function must exist to ensure that calls to it do not crash, but we
     // do not have any use for this data at present.
   }
 
-  // XRDeviceImpl implementation.
-
+  // XRDevice implementation.
   requestSession(sessionOptions, was_activation) {
     return this.supportsSession(sessionOptions).then((result) => {
       // The JavaScript bindings convert c_style_names to camelCase names.
       let options = new device.mojom.XRPresentationTransportOptions();
       options.transportMethod =
           device.mojom.XRPresentationTransportMethod.SUBMIT_AS_MAILBOX_HOLDER;
       options.waitForTransferNotification = true;
       options.waitForRenderNotification = true;
@@ -305,33 +298,37 @@ class MockDevice {
 
         let enviromentProviderPtr =
             new device.mojom.XREnviromentIntegrationProviderPtr();
         let enviromentProviderRequest = mojo.makeRequest(enviromentProviderPtr);
         let enviromentProviderBinding = new mojo.Binding(
             device.mojom.XREnviromentIntegrationProvider, this,
             enviromentProviderRequest);
 
+        let clientRequest = mojo.makeRequest(this.sessionClient_);
+
         return Promise.resolve({
           session: {
             submitFrameSink: submit_frame_sink,
             dataProvider: dataProviderPtr,
-            enviromentProvider: enviromentProviderPtr
+            enviromentProvider: enviromentProviderPtr,
+            clientRequest: clientRequest,
+            displayInfo: this.displayInfo_
           }
         });
       } else {
         return Promise.resolve({session: null});
       }
     });
   }
 
   supportsSession(options) {
     return Promise.resolve({
       supportsSession:
-          !options.exclusive || this.displayInfo_.capabilities.canPresent
+          !options.immersive || this.displayInfo_.capabilities.canPresent
     });
   };
 }
 
 class MockXRPresentationProvider {
   constructor() {
     this.binding_ = new mojo.Binding(device.mojom.XRPresentationProvider, this);