From 4876ea1f406c3ed03d296b4c31ab33f4b449a84b Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 4 Aug 2004 03:35:39 +0000 Subject: [PATCH] Don't throw from location.reload() if it's a POST page and the user cancels the reload. Bug 249405, r=darin, sr=jst git-svn-id: svn://10.0.0.236/trunk@160333 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 6 +++--- mozilla/docshell/base/nsIWebNavigation.idl | 1 + mozilla/docshell/base/nsWebShell.cpp | 5 ++--- mozilla/dom/src/base/nsLocation.cpp | 6 ++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 4309688d828..7b28844eabf 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -6459,11 +6459,11 @@ nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType) if (NS_SUCCEEDED(rv) && messageStr) { prompter->Confirm(nsnull, messageStr, &repost); - /* If the user pressed cancel in the dialog, - * return failure. + /* If the user pressed cancel in the dialog, return. We're + * done here. */ if (!repost) - return NS_ERROR_FAILURE; + return NS_BINDING_ABORTED; } } } diff --git a/mozilla/docshell/base/nsIWebNavigation.idl b/mozilla/docshell/base/nsIWebNavigation.idl index 99aa27d7ac3..eb543c2c100 100644 --- a/mozilla/docshell/base/nsIWebNavigation.idl +++ b/mozilla/docshell/base/nsIWebNavigation.idl @@ -167,6 +167,7 @@ interface nsIWebNavigation : nsISupports * * @param reloadFlags - Flags modifying reload behaviour. Generally you will * pass LOAD_FLAGS_NONE for this parameter. + * @throws NS_BINDING_ABORTED if the user cancels the reload. */ void reload(in unsigned long reloadFlags); diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 906ae43857a..ae754636d40 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -941,9 +941,8 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, if (NS_SUCCEEDED(rv) && messageStr) { prompter->Confirm(nsnull, messageStr, &repost); - /* If the user pressed cancel in the dialog, - * return failure. Don't try to load the page with out - * the post data. + /* If the user pressed cancel in the dialog, return. Don't + * try to load the page with out the post data. */ if (!repost) return NS_OK; diff --git a/mozilla/dom/src/base/nsLocation.cpp b/mozilla/dom/src/base/nsLocation.cpp index 992da291e5a..8cc8dc5d6db 100644 --- a/mozilla/dom/src/base/nsLocation.cpp +++ b/mozilla/dom/src/base/nsLocation.cpp @@ -825,6 +825,12 @@ LocationImpl::Reload(PRBool aForceget) nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY; } rv = webNav->Reload(reloadFlags); + if (rv == NS_BINDING_ABORTED) { + // This happens when we attempt to reload a POST result and the user says + // no at the "do you want to reload?" prompt. Don't propagate this one + // back to callers. + rv = NS_OK; + } } else { NS_ASSERTION(0, "nsIWebNavigation interface is not available!"); rv = NS_ERROR_FAILURE;