diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 2ac0ad96bea..81ca3173224 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -73,7 +73,8 @@ nsDocShell::nsDocShell() : mTreeOwner(nsnull), mChromeEventHandler(nsnull), mCurrentScrollbarPref(-1,-1), - mDefaultScrollbarPref(-1,-1) + mDefaultScrollbarPref(-1,-1), + mEODForCurrentDocument (PR_FALSE) { NS_INIT_REFCNT(); } @@ -1893,7 +1894,7 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, } NS_ENSURE_SUCCESS(SetupNewViewer(viewer), NS_ERROR_FAILURE); - + mEODForCurrentDocument = PR_FALSE; // clear the current flag return NS_OK; } diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 9cdb2f371b4..bb1b278881f 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -199,6 +199,11 @@ protected: nsPoint mDefaultScrollbarPref; // persistent across doc loads PRBool mUpdateHistoryOnLoad; PRBool mInitialPageLoad; + // this flag is for bug #21358. a docshell may load many urls + // which don't result in new documents being created (i.e. a new content viewer) + // we want to make sure we don't call a on load event more than once for a given + // content viewer. + PRBool mEODForCurrentDocument; /* WEAK REFERENCES BELOW HERE. Note these are intentionally not addrefd. Doing so will create a cycle. diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp index f3e5a5e23d4..dc6cf696f67 100644 --- a/docshell/base/nsWebShell.cpp +++ b/docshell/base/nsWebShell.cpp @@ -2667,7 +2667,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, if (loader == mDocLoader) { mProcessedEndDocumentLoad = PR_TRUE; - if (mScriptGlobal) { + if (mScriptGlobal && !mEODForCurrentDocument) { nsIDocumentViewer* docViewer; if (nsnull != mContentViewer && NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) { @@ -2685,6 +2685,8 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, } } + mEODForCurrentDocument = PR_TRUE; + // Fire the EndLoadURL of the web shell container if (nsnull != aURL) { nsAutoString urlString; diff --git a/webshell/src/nsWebShell.cpp b/webshell/src/nsWebShell.cpp index f3e5a5e23d4..dc6cf696f67 100644 --- a/webshell/src/nsWebShell.cpp +++ b/webshell/src/nsWebShell.cpp @@ -2667,7 +2667,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, if (loader == mDocLoader) { mProcessedEndDocumentLoad = PR_TRUE; - if (mScriptGlobal) { + if (mScriptGlobal && !mEODForCurrentDocument) { nsIDocumentViewer* docViewer; if (nsnull != mContentViewer && NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) { @@ -2685,6 +2685,8 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, } } + mEODForCurrentDocument = PR_TRUE; + // Fire the EndLoadURL of the web shell container if (nsnull != aURL) { nsAutoString urlString;