Bug 1589913 - Update FxR Desktop default home page r=kip,daoshengmu
authorthomasmo <thomasmo@mozilla.com>
Wed, 30 Oct 2019 13:54:49 +0000
changeset 499776 12d04605694859aa910235440fd63b5a3429c80c
parent 499775 e8f1b175ca80592042a6c17b9375e75a87e4c548
child 499777 a478ac8390169be2fac752abdc4f2ad61fde6415
push id36747
push useraciure@mozilla.com
push dateWed, 30 Oct 2019 21:51:16 +0000
treeherdermozilla-central@f68c212c8b2a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip, daoshengmu
bugs1589913
milestone72.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 1589913 - Update FxR Desktop default home page r=kip,daoshengmu This change updates the home page to webxr.today for Firefox Realty on Desktop. Further, since WebVR is not supported yet, this change includes a way to disable WebVR specifically for FxR windows without impacting Desktop Fx. Differential Revision: https://phabricator.services.mozilla.com/D49840
browser/fxr/content/fxrui.js
dom/base/Navigator.cpp
dom/ipc/BrowserParent.cpp
dom/ipc/BrowserParent.h
dom/ipc/PBrowser.ipdl
--- a/browser/fxr/content/fxrui.js
+++ b/browser/fxr/content/fxrui.js
@@ -1,17 +1,17 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* import-globals-from common.js */
 
 // Configuration vars
-let homeURL = "https://www.mozilla.org/en-US/";
+let homeURL = "https://webxr.today/";
 // Bug 1586294 - Localize the privacy policy URL (Services.urlFormatter?)
 let privacyPolicyURL = "https://www.mozilla.org/en-US/privacy/firefox/";
 let reportIssueURL = "https://mzl.la/fxr";
 let licenseURL =
   "https://mixedreality.mozilla.org/FirefoxRealityPC/license.html";
 
 // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser
 let browser = null;
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1475,32 +1475,53 @@ already_AddRefed<Promise> Navigator::Get
   }
 
   if (!FeaturePolicyUtils::IsFeatureAllowed(mWindow->GetExtantDoc(),
                                             NS_LITERAL_STRING("vr"))) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return nullptr;
   }
 
-  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
-  win->NotifyVREventListenerAdded();
-
   RefPtr<Promise> p = Promise::Create(mWindow->AsGlobal(), aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  // We pass mWindow's id to RefreshVRDisplays, so NotifyVRDisplaysUpdated will
-  // be called asynchronously, resolving the promises in mVRGetDisplaysPromises.
-  if (!VRDisplay::RefreshVRDisplays(win->WindowID())) {
-    p->MaybeReject(NS_ERROR_FAILURE);
-    return p.forget();
-  }
+  RefPtr<Navigator> self(this);
+  RefPtr<BrowserChild> browser(BrowserChild::GetFrom(mWindow));
+  int browserID = browser->ChromeOuterWindowID();
 
-  mVRGetDisplaysPromises.AppendElement(p);
+  browser->SendIsWindowSupportingWebVR(browserID)->Then(
+      GetCurrentThreadSerialEventTarget(), __func__,
+      [self, p](bool isSupportedLambda) {
+        if (isSupportedLambda) {
+          nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(self->mWindow);
+          win->NotifyVREventListenerAdded();
+          // We pass mWindow's id to RefreshVRDisplays, so
+          // NotifyVRDisplaysUpdated will be called asynchronously, resolving
+          // the promises in mVRGetDisplaysPromises.
+          if (!VRDisplay::RefreshVRDisplays(win->WindowID())) {
+            // Failed to refresh, reject the promise now
+            p->MaybeReject(NS_ERROR_FAILURE);
+          } else {
+            // Succeeded, so cache the promise to resolve later
+
+            self->mVRGetDisplaysPromises.AppendElement(p);
+          }
+        } else {
+          // WebVR in this window is not supported, so resolve the promise
+          // with no displays available
+          nsTArray<RefPtr<VRDisplay>> vrDisplaysEmpty;
+          p->MaybeResolve(vrDisplaysEmpty);
+        }
+      },
+      [](const mozilla::ipc::ResponseRejectReason) {
+        MOZ_CRASH("Failed to make IPC call to IsWindowSupportingWebVR");
+      });
+
   return p.forget();
 }
 
 void Navigator::GetActiveVRDisplays(
     nsTArray<RefPtr<VRDisplay>>& aDisplays) const {
   /**
    * Get only the active VR displays.
    * GetActiveVRDisplays should only enumerate displays that
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -3991,10 +3991,24 @@ mozilla::ipc::IPCResult BrowserParent::R
   aResolve(!isFxrWindow);
 #else
   MOZ_CRASH("Should only be called on Windows");
 #endif
 
   return IPC_OK();
 }
 
+mozilla::ipc::IPCResult BrowserParent::RecvIsWindowSupportingWebVR(
+    const uint64_t& aOuterWindowID,
+    IsWindowSupportingWebVRResolver&& aResolve) {
+#ifdef XP_WIN
+  bool isFxrWindow =
+      FxRWindowManager::GetInstance()->IsFxRWindow(aOuterWindowID);
+  aResolve(!isFxrWindow);
+#else
+  aResolve(true);
+#endif
+
+  return IPC_OK();
+}
+
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/BrowserParent.h
+++ b/dom/ipc/BrowserParent.h
@@ -502,16 +502,20 @@ class BrowserParent final : public PBrow
       PBrowserBridgeParent* aActor, const nsString& aPresentationURL,
       const nsString& aRemoteType, BrowsingContext* aBrowsingContext,
       const uint32_t& aChromeFlags, const TabId& aTabId) override;
 
   mozilla::ipc::IPCResult RecvIsWindowSupportingProtectedMedia(
       const uint64_t& aOuterWindowID,
       IsWindowSupportingProtectedMediaResolver&& aResolve);
 
+  mozilla::ipc::IPCResult RecvIsWindowSupportingWebVR(
+      const uint64_t& aOuterWindowID,
+      IsWindowSupportingWebVRResolver&& aResolve);
+
   void LoadURL(nsIURI* aURI);
 
   void ResumeLoad(uint64_t aPendingSwitchID);
 
   void InitRendering();
   bool AttachLayerManager();
   void MaybeShowFrame();
 
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -1030,16 +1030,21 @@ child:
     async SkipBrowsingContextDetach() returns (bool success);
 
 parent:
     /**
      * Fetches whether this window supports protected media, which is sent back in response.
      */
     async IsWindowSupportingProtectedMedia(uint64_t aOuterWindowID) returns(bool isSupported);
 
+    /**
+     * Fetches whether this window supports WebVR, which is sent back in response.
+     */
+    async IsWindowSupportingWebVR(uint64_t aOuterWindowID) returns(bool isSupported);
+
     /** Records a history visit. */
     async VisitURI(URIParams aURI, URIParams? aLastVisitedURI,
                    uint32_t aFlags);
 
     /** Fetches the visited status for an array of URIs (Android-only). */
     async QueryVisitedState(URIParams[] aURIs);
 
     /**