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
--- 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()) {