diff --git a/mozilla/content/html/content/src/nsFormSubmission.cpp b/mozilla/content/html/content/src/nsFormSubmission.cpp
index 676b3c81528..b8e00dc425c 100644
--- a/mozilla/content/html/content/src/nsFormSubmission.cpp
+++ b/mozilla/content/html/content/src/nsFormSubmission.cpp
@@ -737,18 +737,16 @@ nsFormSubmission::SubmitTo(nsIURI* aActionURL, const nsAString& aTarget,
//
nsCOMPtr handler;
aPresContext->GetLinkHandler(getter_AddRefs(handler));
- if (handler) {
- nsCAutoString actionURLSpec;
- aActionURL->GetSpec(actionURLSpec);
+ NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);
- handler->OnLinkClickSync(aSource, eLinkVerb_Replace,
- NS_ConvertUTF8toUCS2(actionURLSpec).get(),
- PromiseFlatString(aTarget).get(),
- postDataStream, nsnull,
- aDocShell, aRequest);
- }
+ nsCAutoString actionURLSpec;
+ aActionURL->GetSpec(actionURLSpec);
- return rv;
+ return handler->OnLinkClickSync(aSource, eLinkVerb_Replace,
+ NS_ConvertUTF8toUCS2(actionURLSpec).get(),
+ PromiseFlatString(aTarget).get(),
+ postDataStream, nsnull,
+ aDocShell, aRequest);
}
// JBK moved from nsFormFrame - bug 34297
diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp
index 962f0694ea0..e3602495db8 100644
--- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp
@@ -748,9 +748,16 @@ nsHTMLFormElement::DoSubmit(nsIPresContext* aPresContext, nsEvent* aEvent)
getter_AddRefs(mSubmittingRequest));
NS_ENSURE_SUBMIT_SUCCESS(rv);
- nsCOMPtr webProgress = do_GetInterface(docShell);
- NS_ASSERTION(webProgress, "nsIDocShell null or not converted to nsIWebProgress!");
- return webProgress->AddProgressListener(this);
+ // Even if the submit succeeds, it's possible for there to be no docshell
+ // or request; for example, if it's to a named anchor within the same page
+ // the submit will not really do anything.
+ if (docShell) {
+ nsCOMPtr webProgress = do_GetInterface(docShell);
+ NS_ASSERTION(webProgress, "nsIDocShell not converted to nsIWebProgress!");
+ rv = webProgress->AddProgressListener(this);
+ }
+
+ return rv;
}
diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp
index 9da0c2bf672..ede21d5bff2 100644
--- a/mozilla/docshell/base/nsWebShell.cpp
+++ b/mozilla/docshell/base/nsWebShell.cpp
@@ -601,7 +601,8 @@ nsWebShell::OnLinkClickSync(nsIContent *aContent,
listener->OnStartURIOpen(uri, &abort);
}
}
- return rv;
+ // We didn't load the URI, so we failed
+ return NS_ERROR_FAILURE;
}
return InternalLoad(uri, // New URI