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 be0bef3b34
commit 908c2bdbfa
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;

View File

@ -938,6 +938,7 @@ protected:
bool mAllowKeywordFixup;
bool mIsOffScreenBrowser;
bool mIsActive;
bool mDisableMetaRefreshWhenInactive;
bool mIsPrerendered;
bool mIsAppTab;
bool mUseGlobalHistory;

View File

@ -618,6 +618,9 @@ pref("dom.webnotifications.enabled", true);
// prevent tooltips from showing up
pref("browser.chrome.toolbar_tips", false);
// don't allow meta-refresh when backgrounded
pref("browser.meta_refresh_when_inactive.disabled", true);
// prevent video elements from preloading too much data
pref("media.preload.default", 1); // default to preload none
pref("media.preload.auto", 2); // preload metadata if preload=auto

View File

@ -4491,6 +4491,8 @@ pref("browser.history.allowReplaceState", true);
pref("browser.history.allowPopState", true);
pref("browser.history.maxStateObjectSize", 655360);
pref("browser.meta_refresh_when_inactive.disabled", false);
// XPInstall prefs
pref("xpinstall.whitelist.required", true);
// Only Firefox requires add-on signatures