Bug 518805 - Don't do meta refreshes when backgrounded r=bz

This is controlled by browser.meta_refresh_when_inactive.disabled, which
is false (allow refreshes) on desktop, and true (disable refreshes) on Fennec
This commit is contained in:
James Willcox
2016-03-02 16:20:48 -06:00
parent 5e113cb492
commit eb86324af3
4 changed files with 25 additions and 5 deletions

View File

@@ -780,6 +780,7 @@ nsDocShell::nsDocShell()
, mAllowKeywordFixup(false)
, mIsOffScreenBrowser(false)
, mIsActive(true)
, mDisableMetaRefreshWhenInactive(false)
, mIsPrerendered(false)
, mIsAppTab(false)
, mUseGlobalHistory(false)
@@ -5630,6 +5631,10 @@ nsDocShell::Create()
gAddedPreferencesVarCache = true;
}
mDisableMetaRefreshWhenInactive =
Preferences::GetBool("browser.meta_refresh_when_inactive.disabled",
mDisableMetaRefreshWhenInactive);
mDeviceSizeIsPageSize =
Preferences::GetBool("docshell.device_size_is_page_size",
mDeviceSizeIsPageSize);
@@ -6132,6 +6137,15 @@ nsDocShell::SetIsActiveInternal(bool aIsActive, bool aIsHidden)
}
}
// Restart or stop meta refresh timers if necessary
if (mDisableMetaRefreshWhenInactive) {
if (mIsActive) {
ResumeRefreshURIs();
} else {
SuspendRefreshURIs();
}
}
return NS_OK;
}
@@ -6593,10 +6607,9 @@ nsDocShell::RefreshURI(nsIURI* aURI, int32_t aDelay, bool aRepeat,
NS_ERROR_FAILURE);
}
if (busyFlags & BUSY_FLAGS_BUSY) {
// We are busy loading another page. Don't create the
// timer right now. Instead queue up the request and trigger the
// timer in EndPageLoad().
if (busyFlags & BUSY_FLAGS_BUSY || (!mIsActive && mDisableMetaRefreshWhenInactive)) {
// We don't want to create the timer right now. Instead queue up the request
// and trigger the timer in EndPageLoad() or whenever we become active.
mRefreshURIList->AppendElement(refreshTimer);
} else {
// There is no page loading going on right now. Create the
@@ -7549,7 +7562,8 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
}
// if there's a refresh header in the channel, this method
// will set it up for us.
RefreshURIFromQueue();
if (mIsActive || !mDisableMetaRefreshWhenInactive)
RefreshURIFromQueue();
// Test whether this is the top frame or a subframe
bool isTopFrame = true;