mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1209591 - allow loadURI consumers to expose whether an error page was immediately loaded as result of an error, r=smaug,mak
--HG-- extra : commitid : 9tlkWrUKl12 extra : rebase_source : bb5b476dc28cebc66a99d23934a5214530e9a008 extra : amend_source : f62e5a91df5af9eea893fbb9a13980e9fdd56a38
This commit is contained in:
parent
c57e5b05dc
commit
35bed1c0ce
@ -397,6 +397,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
try {
|
||||
openUILinkIn(url, "current", {
|
||||
allowThirdPartyFixup: true,
|
||||
indicateErrorPageLoad: true,
|
||||
disallowInheritPrincipal: !mayInheritPrincipal,
|
||||
allowPinnedTabHostChange: true,
|
||||
postData: postData,
|
||||
@ -405,7 +406,9 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
} catch (ex) {
|
||||
// This load can throw an exception in certain cases, which means
|
||||
// we'll want to replace the URL with the loaded URL:
|
||||
this.handleRevert();
|
||||
if (ex.result != Cr.NS_ERROR_LOAD_SHOWED_ERRORPAGE) {
|
||||
this.handleRevert();
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the start of the URL is visible for UX reasons:
|
||||
|
@ -219,6 +219,7 @@ function openLinkIn(url, where, params) {
|
||||
var aNoReferrer = params.noReferrer;
|
||||
var aAllowPopups = !!params.allowPopups;
|
||||
var aUserContextId = params.userContextId;
|
||||
var aIndicateErrorPageLoad = params.indicateErrorPageLoad;
|
||||
|
||||
if (where == "save") {
|
||||
if (!aInitiatingDoc) {
|
||||
@ -338,6 +339,9 @@ function openLinkIn(url, where, params) {
|
||||
if (aAllowPopups) {
|
||||
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_POPUPS;
|
||||
}
|
||||
if (aIndicateErrorPageLoad) {
|
||||
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ERROR_LOAD_CHANGES_RV;
|
||||
}
|
||||
|
||||
w.gBrowser.loadURIWithFlags(url, {
|
||||
flags: flags,
|
||||
|
@ -4656,7 +4656,10 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
||||
// what happens
|
||||
|
||||
if (NS_ERROR_MALFORMED_URI == rv) {
|
||||
DisplayLoadError(rv, uri, aURI, nullptr);
|
||||
if (DisplayLoadError(rv, uri, aURI, nullptr) &&
|
||||
(aLoadFlags & LOAD_FLAGS_ERROR_LOAD_CHANGES_RV) != 0) {
|
||||
return NS_ERROR_LOAD_SHOWED_ERRORPAGE;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || !uri) {
|
||||
@ -4721,8 +4724,10 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
const char16_t* aURL,
|
||||
nsIChannel* aFailedChannel)
|
||||
nsIChannel* aFailedChannel,
|
||||
bool* aDisplayedErrorPage)
|
||||
{
|
||||
*aDisplayedErrorPage = false;
|
||||
// Get prompt and string bundle servcies
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
@ -5100,8 +5105,10 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
|
||||
if (UseErrorPages()) {
|
||||
// Display an error page
|
||||
LoadErrorPage(aURI, aURL, errorPage.get(), error.get(),
|
||||
messageStr.get(), cssClass.get(), aFailedChannel);
|
||||
nsresult loadedPage = LoadErrorPage(aURI, aURL, errorPage.get(),
|
||||
error.get(), messageStr.get(),
|
||||
cssClass.get(), aFailedChannel);
|
||||
*aDisplayedErrorPage = NS_SUCCEEDED(loadedPage);
|
||||
} else {
|
||||
// The prompter reqires that our private window has a document (or it
|
||||
// asserts). Satisfy that assertion now since GetDoc will force
|
||||
@ -10276,7 +10283,10 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsIChannel> chan(do_QueryInterface(req));
|
||||
DisplayLoadError(rv, aURI, nullptr, chan);
|
||||
if (DisplayLoadError(rv, aURI, nullptr, chan) &&
|
||||
(aFlags & LOAD_FLAGS_ERROR_LOAD_CHANGES_RV) != 0) {
|
||||
return NS_ERROR_LOAD_SHOWED_ERRORPAGE;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -728,6 +728,14 @@ protected:
|
||||
*/
|
||||
void MaybeInitTiming();
|
||||
|
||||
bool DisplayLoadError(nsresult aError, nsIURI* aURI, const char16_t* aURL,
|
||||
nsIChannel* aFailedChannel)
|
||||
{
|
||||
bool didDisplayLoadError = false;
|
||||
DisplayLoadError(aError, aURI, aURL, aFailedChannel, &didDisplayLoadError);
|
||||
return didDisplayLoadError;
|
||||
}
|
||||
|
||||
public:
|
||||
// Event type dispatched by RestorePresentation
|
||||
class RestorePresentationEvent : public nsRunnable
|
||||
|
@ -43,7 +43,7 @@ interface nsITabParent;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
[scriptable, builtinclass, uuid(9f2babc4-4c2a-4cf7-929f-a1efc325b0df)]
|
||||
[scriptable, builtinclass, uuid(b1df6e41-c8dd-45c2-bc18-dd330d986214)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
@ -460,11 +460,14 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
* @param aURI nsIURI of the page where the error happened
|
||||
* @param aURL wstring of the page where the error happened
|
||||
* @param aFailedChannel The channel related to this error
|
||||
*
|
||||
* Returns whether or not we displayed an error page (note: will always
|
||||
* return false if in-content error pages are disabled!)
|
||||
*/
|
||||
void displayLoadError(in nsresult aError,
|
||||
in nsIURI aURI,
|
||||
in wstring aURL,
|
||||
[optional] in nsIChannel aFailedChannel);
|
||||
boolean displayLoadError(in nsresult aError,
|
||||
in nsIURI aURI,
|
||||
in wstring aURL,
|
||||
[optional] in nsIChannel aFailedChannel);
|
||||
|
||||
/**
|
||||
* The channel that failed to load and resulted in an error page.
|
||||
|
@ -16,7 +16,7 @@ interface nsIURI;
|
||||
* location, stop or restart an in process load, or determine where the object
|
||||
* has previously gone.
|
||||
*/
|
||||
[scriptable, uuid(0e92d522-53a5-4af6-9a24-4eccdcbf4f91)]
|
||||
[scriptable, uuid(3ade79d4-8cb9-4952-b18d-4f9b63ca0d31)]
|
||||
interface nsIWebNavigation : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -184,6 +184,12 @@ interface nsIWebNavigation : nsISupports
|
||||
*/
|
||||
const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_OWNER = 0x40000;
|
||||
|
||||
/**
|
||||
* Overwrite the returned error code with a specific result code
|
||||
* when an error page is displayed.
|
||||
*/
|
||||
const unsigned long LOAD_FLAGS_ERROR_LOAD_CHANGES_RV = 0x80000;
|
||||
|
||||
/**
|
||||
* This flag specifies that the URI may be submitted to a third-party
|
||||
* server for correction. This should only be applied to non-sensitive
|
||||
@ -196,8 +202,6 @@ interface nsIWebNavigation : nsISupports
|
||||
*/
|
||||
const unsigned long LOAD_FLAGS_FIXUP_SCHEME_TYPOS = 0x200000;
|
||||
|
||||
/* Note that flag 0x80000 is available. */
|
||||
|
||||
/**
|
||||
* Loads a given URI. This will give priority to loading the requested URI
|
||||
* in the object implementing this interface. If it can't be loaded here
|
||||
|
@ -156,6 +156,7 @@ XPC_MSG_DEF(NS_ERROR_ENTITY_CHANGED , "It was attempted to resum
|
||||
XPC_MSG_DEF(NS_ERROR_REDIRECT_LOOP , "The request failed as a result of a detected redirection loop")
|
||||
XPC_MSG_DEF(NS_ERROR_UNSAFE_CONTENT_TYPE , "The request failed because the content type returned by the server was not a type expected by the channel")
|
||||
XPC_MSG_DEF(NS_ERROR_REMOTE_XUL , "Attempt to access remote XUL document that is not in website's whitelist")
|
||||
XPC_MSG_DEF(NS_ERROR_LOAD_SHOWED_ERRORPAGE , "The load caused an error page to be displayed.")
|
||||
|
||||
XPC_MSG_DEF(NS_ERROR_FTP_LOGIN , "FTP error while logging in")
|
||||
XPC_MSG_DEF(NS_ERROR_FTP_CWD , "FTP error while changing directory")
|
||||
|
@ -231,6 +231,8 @@
|
||||
/* The request failed because the user tried to access to a remote XUL
|
||||
* document from a website that is not in its white-list. */
|
||||
ERROR(NS_ERROR_REMOTE_XUL, FAILURE(75)),
|
||||
/* The request resulted in an error page being displayed. */
|
||||
ERROR(NS_ERROR_LOAD_SHOWED_ERRORPAGE, FAILURE(77)),
|
||||
|
||||
|
||||
/* FTP specific error codes: */
|
||||
|
Loading…
Reference in New Issue
Block a user