Bug 1717833 - reorder asserting for non-external protocols and checking external prefs disallowing registering some schemes, r=nika a=RyanVM
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 24 Jun 2021 17:03:51 +0000
changeset 600658 5d50d1be643b30bd45146bd243faa48cb7427437
parent 600657 3b90b75cb1e6d06c1f590bb8d6122174319797f1
child 600659 02dd1826fc564da9ef3b96965525f3a7db23fee7
push id312
push userryanvm@gmail.com
push dateMon, 16 Aug 2021 13:50:33 +0000
treeherdermozilla-esr78@02dd1826fc56 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika, RyanVM
bugs1717833
milestone78.14.0
Bug 1717833 - reorder asserting for non-external protocols and checking external prefs disallowing registering some schemes, r=nika a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D118715
dom/base/Navigator.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -947,34 +947,34 @@ void Navigator::CheckProtocolHandlerAllo
   nsCOMPtr<nsIProtocolHandler> handler;
   nsCOMPtr<nsIIOService> io = services::GetIOService();
   if (NS_FAILED(
           io->GetProtocolHandler(scheme.get(), getter_AddRefs(handler)))) {
     raisePermissionDeniedScheme();
     return;
   }
 
-  // Check to make sure this isn't already handled internally (we don't
-  // want to let them take over, say "chrome"). In theory, the checks above
-  // should have already taken care of this.
-  nsCOMPtr<nsIExternalProtocolHandler> externalHandler =
-      do_QueryInterface(handler);
-  MOZ_RELEASE_ASSERT(
-      externalHandler,
-      "We should never allow overriding a builtin protocol handler");
-
   // check if we have prefs set saying not to add this.
   bool defaultExternal =
       Preferences::GetBool("network.protocol-handler.external-default");
   nsPrintfCString specificPref("network.protocol-handler.external.%s",
                                scheme.get());
   if (!Preferences::GetBool(specificPref.get(), defaultExternal)) {
     raisePermissionDeniedScheme();
     return;
   }
+
+  // Check to make sure this isn't already handled internally (we don't
+  // want to let them take over, say "chrome"). In theory, the checks above
+  // should have already taken care of this.
+  nsCOMPtr<nsIExternalProtocolHandler> externalHandler =
+      do_QueryInterface(handler);
+  MOZ_RELEASE_ASSERT(
+      externalHandler,
+      "We should never allow overriding a builtin protocol handler");
 }
 
 void Navigator::RegisterProtocolHandler(const nsAString& aScheme,
                                         const nsAString& aURI,
                                         const nsAString& aTitle,
                                         ErrorResult& aRv) {
   if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell() ||
       !mWindow->GetDoc()) {