Bug 1631464 Remove the title argument from registerProtocolHandler() r=smaug
authorFrederic Wang <fred.wang@free.fr>
Tue, 27 Oct 2020 14:10:22 +0000
changeset 554667 e6dcf7fa653df399dd51a398bb2ff72a1bb866bf
parent 554666 fbac66dafee12b30fa951cfd9edcdc04b494117d
child 554668 ab66bd46c2d6874336d5fad4faceaa9b9448ff5f
push id37897
push userncsoregi@mozilla.com
push dateTue, 27 Oct 2020 21:20:52 +0000
treeherdermozilla-central@ab66bd46c2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1631464
milestone84.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 1631464 Remove the title argument from registerProtocolHandler() r=smaug See https://groups.google.com/g/mozilla.dev.platform/c/T633aemFPJU/m/dbv5_iB8AgAJ Differential Revision: https://phabricator.services.mozilla.com/D71714
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/webidl/Navigator.webidl
testing/web-platform/meta/html/dom/idlharness.https.html.ini
testing/web-platform/meta/html/webappapis/system-state-and-capabilities/the-navigator-object/historical.https.window.js.ini
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -980,17 +980,16 @@ void Navigator::CheckProtocolHandlerAllo
   if (!Preferences::GetBool(specificPref.get(), defaultExternal)) {
     raisePermissionDeniedScheme();
     return;
   }
 }
 
 void Navigator::RegisterProtocolHandler(const nsAString& aScheme,
                                         const nsAString& aURI,
-                                        const nsAString& aTitle,
                                         ErrorResult& aRv) {
   if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell() ||
       !mWindow->GetDoc()) {
     return;
   }
   nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(mWindow);
   if (loadContext->UsePrivateBrowsing()) {
     // If we're a private window, don't alert the user or webpage. We log to the
@@ -1009,30 +1008,34 @@ void Navigator::RegisterProtocolHandler(
   nsCOMPtr<nsIURI> handlerURI;
   NS_NewURI(getter_AddRefs(handlerURI), NS_ConvertUTF16toUTF8(aURI),
             doc->GetDocumentCharacterSet(), docURI);
   CheckProtocolHandlerAllowed(aScheme, handlerURI, docURI, aRv);
   if (aRv.Failed()) {
     return;
   }
 
+  // Determine a title from the document URI.
+  nsAutoCString docDisplayHostPort;
+  docURI->GetDisplayHostPort(docDisplayHostPort);
+  NS_ConvertASCIItoUTF16 title(docDisplayHostPort);
+
   if (XRE_IsContentProcess()) {
     nsAutoString scheme(aScheme);
-    nsAutoString title(aTitle);
     RefPtr<BrowserChild> browserChild = BrowserChild::GetFrom(mWindow);
     browserChild->SendRegisterProtocolHandler(scheme, handlerURI, title,
                                               docURI);
     return;
   }
 
   nsCOMPtr<nsIWebProtocolHandlerRegistrar> registrar =
       do_GetService(NS_WEBPROTOCOLHANDLERREGISTRAR_CONTRACTID);
   if (registrar) {
-    aRv = registrar->RegisterProtocolHandler(aScheme, handlerURI, aTitle,
-                                             docURI, mWindow->GetOuterWindow());
+    aRv = registrar->RegisterProtocolHandler(aScheme, handlerURI, title, docURI,
+                                             mWindow->GetOuterWindow());
   }
 }
 
 Geolocation* Navigator::GetGeolocation(ErrorResult& aRv) {
   if (mGeolocation) {
     return mGeolocation;
   }
 
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -118,17 +118,17 @@ class Navigator final : public nsISuppor
                    ErrorResult& aRv) const;
   void GetUserAgent(nsAString& aUserAgent, CallerType aCallerType,
                     ErrorResult& aRv) const;
   bool OnLine();
   void CheckProtocolHandlerAllowed(const nsAString& aScheme,
                                    nsIURI* aHandlerURI, nsIURI* aDocumentURI,
                                    ErrorResult& aRv);
   void RegisterProtocolHandler(const nsAString& aScheme, const nsAString& aURL,
-                               const nsAString& aTitle, ErrorResult& aRv);
+                               ErrorResult& aRv);
   nsMimeTypeArray* GetMimeTypes(ErrorResult& aRv);
   nsPluginArray* GetPlugins(ErrorResult& aRv);
   Permissions* GetPermissions(ErrorResult& aRv);
   void GetDoNotTrack(nsAString& aResult);
   Geolocation* GetGeolocation(ErrorResult& aRv);
   Promise* GetBattery(ErrorResult& aRv);
 
   Promise* Share(const ShareData& aData, ErrorResult& aRv);
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -79,17 +79,17 @@ interface mixin NavigatorOnLine {
   readonly attribute boolean onLine;
 };
 
 interface mixin NavigatorContentUtils {
   // content handler registration
   [Throws, ChromeOnly]
   void checkProtocolHandlerAllowed(DOMString scheme, URI handlerURI, URI documentURI);
   [Throws, SecureContext]
-  void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title);
+  void registerProtocolHandler(DOMString scheme, DOMString url);
   // NOT IMPLEMENTED
   //void unregisterProtocolHandler(DOMString scheme, DOMString url);
 };
 
 [SecureContext]
 interface mixin NavigatorStorage {
   [Pref="dom.storageManager.enabled"]
   readonly attribute StorageManager storage;
--- a/testing/web-platform/meta/html/dom/idlharness.https.html.ini
+++ b/testing/web-platform/meta/html/dom/idlharness.https.html.ini
@@ -706,19 +706,16 @@ prefs: [dom.security.featurePolicy.exper
     expected: FAIL
 
   [OffscreenCanvas interface: operation convertToBlob(optional ImageEncodeOptions)]
     expected: FAIL
 
   [OffscreenCanvasRenderingContext2D interface: operation arc(unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, optional boolean)]
     expected: FAIL
 
-  [Navigator interface: operation registerProtocolHandler(DOMString, USVString)]
-    expected: FAIL
-
   [ElementInternals interface: operation setValidity(optional ValidityStateFlags, optional DOMString, optional HTMLElement)]
     expected: FAIL
 
   [ElementInternals interface: attribute shadowRoot]
     expected: FAIL
 
 
 [idlharness.https.html?include=(Document|Window)]
deleted file mode 100644
--- a/testing/web-platform/meta/html/webappapis/system-state-and-capabilities/the-navigator-object/historical.https.window.js.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[historical.https.window.html]
-  [registerProtocolHandler has no third argument]
-    expected: FAIL
-