Bug 1717833 - reorder asserting for non-external protocols and checking external prefs disallowing registering some schemes, r=nika
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 24 Jun 2021 17:03:51 +0000
changeset 584290 976b92bb11db522804a44c9f66fc8f43dd7225e1
parent 584289 d99fe7dbb8f8a7f090df19d9c80b05fa386b2811
child 584291 5b9012813f110eb5c181b7637d5696e7e5a6b3f6
push id38563
push usercbrindusan@mozilla.com
push dateFri, 25 Jun 2021 09:34:36 +0000
treeherdermozilla-central@531323de1a48 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1717833
milestone91.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 1717833 - reorder asserting for non-external protocols and checking external prefs disallowing registering some schemes, r=nika Differential Revision: https://phabricator.services.mozilla.com/D118715
dom/base/Navigator.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -962,34 +962,34 @@ void Navigator::CheckProtocolHandlerAllo
   nsCOMPtr<nsIProtocolHandler> handler;
   nsCOMPtr<nsIIOService> io = components::IO::Service();
   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,
                                         ErrorResult& aRv) {
   if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell() ||
       !mWindow->GetDoc()) {
     return;