зеркало из https://github.com/mozilla/pjs.git
Fix for bug # 69457 r=valeski, rpotts
This commit is contained in:
Родитель
1f9eeeb83a
Коммит
36e002d883
|
@ -128,6 +128,7 @@ nsDocShell::nsDocShell() :
|
|||
mInitialPageLoad(PR_TRUE),
|
||||
mAllowPlugins(PR_TRUE),
|
||||
mAllowJavascript(PR_TRUE),
|
||||
mAllowMetaRedirects(PR_TRUE),
|
||||
mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
|
||||
mViewMode(viewNormal),
|
||||
mLastViewMode(viewNormal),
|
||||
|
@ -714,6 +715,23 @@ NS_IMETHODIMP nsDocShell::SetAllowJavascript(PRBool aAllowJavascript)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetAllowMetaRedirects(PRBool * aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
*aReturn = mAllowMetaRedirects;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetAllowMetaRedirects(PRBool aValue)
|
||||
{
|
||||
mAllowMetaRedirects = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetAppType(PRUint32* aAppType)
|
||||
{
|
||||
*aAppType = mAppType;
|
||||
|
@ -4478,23 +4496,36 @@ NS_IMETHODIMP_(void) nsRefreshTimer::Notify(nsITimer *aTimer)
|
|||
}
|
||||
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
||||
mDocShell->CreateLoadInfo (getter_AddRefs (loadInfo));
|
||||
/* Check if this refresh causes a redirection
|
||||
* to another site within the threshold time we
|
||||
* have in mind(15000 ms as defined by REFRESH_REDIRECT_TIMER).
|
||||
* If so, pass a REPLACE flag to LoadURI().
|
||||
/* Check if this META refresh causes a redirection
|
||||
* to another site. If so, check if this is permitted. Some
|
||||
* embedded applications may not want to do this.
|
||||
*/
|
||||
PRBool equalUri = PR_FALSE;
|
||||
if (NS_SUCCEEDED(mURI->Equals(currURI, &equalUri)) && (delay <= REFRESH_REDIRECT_TIMER) && (!equalUri) && mMetaRefresh) {
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadNormalReplace);
|
||||
nsresult rv = mURI->Equals(currURI, &equalUri);
|
||||
if (NS_SUCCEEDED(rv) && (!equalUri) && mMetaRefresh) {
|
||||
PRBool allowRedirects=PR_TRUE;
|
||||
mDocShell->GetAllowMetaRedirects(&allowRedirects);
|
||||
if (!allowRedirects)
|
||||
return;
|
||||
/* It is a META refresh based redirection. Now check if it happened within
|
||||
* the threshold time we have in mind(15000 ms as defined by REFRESH_REDIRECT_TIMER).
|
||||
* If so, pass a REPLACE flag to LoadURI().
|
||||
*/
|
||||
if (delay <= REFRESH_REDIRECT_TIMER) {
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadNormalReplace);
|
||||
}
|
||||
else
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh);
|
||||
/*
|
||||
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
|
||||
* its refreshData instance to be released...
|
||||
*/
|
||||
mDocShell->LoadURI(mURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
|
||||
}
|
||||
else
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh);
|
||||
mDocShell->LoadURI(mURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
|
||||
* its refreshData instance to be released...
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -289,6 +289,7 @@ protected:
|
|||
PRBool mInitialPageLoad;
|
||||
PRBool mAllowPlugins;
|
||||
PRBool mAllowJavascript;
|
||||
PRBool mAllowMetaRedirects;
|
||||
PRUint32 mAppType;
|
||||
PRInt32 mViewMode;
|
||||
PRInt32 mLastViewMode;
|
||||
|
|
|
@ -148,6 +148,12 @@ interface nsIDocShell : nsISupports
|
|||
*/
|
||||
attribute boolean allowJavascript;
|
||||
|
||||
/**
|
||||
* Attribute stating if refresh based redirects can be allowed
|
||||
*/
|
||||
attribute boolean allowMetaRedirects;
|
||||
|
||||
|
||||
/*
|
||||
The type of application that created this window
|
||||
*/
|
||||
|
|
|
@ -34,6 +34,9 @@ interface nsIWebBrowserSetup : nsISupports
|
|||
{
|
||||
const unsigned long SETUP_ALLOW_PLUGINS = 1;
|
||||
const unsigned long SETUP_ALLOW_JAVASCRIPT = 2;
|
||||
const unsigned long SETUP_ALLOW_META_REDIRECTS =3;
|
||||
|
||||
|
||||
|
||||
void setProperty(in unsigned long aId, in unsigned long aValue);
|
||||
};
|
|
@ -604,7 +604,13 @@ NS_IMETHODIMP nsWebBrowser::SetProperty(PRUint32 aId, PRUint32 aValue)
|
|||
mDocShell->SetAllowJavascript(aValue);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIWebBrowserSetup::SETUP_ALLOW_META_REDIRECTS:
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
NS_ENSURE_TRUE((aValue == PR_TRUE || aValue == PR_FALSE), NS_ERROR_INVALID_ARG);
|
||||
mDocShell->SetAllowMetaRedirects(aValue);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче