Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2024-09-22 20:54:25 +08:00
commit 2b0cdc7b62
18 changed files with 104 additions and 37 deletions

View file

@ -507,6 +507,12 @@ pref("javascript.options.showInConsole", true);
pref("general.warnOnAboutConfig", false);
#endif
// Enable unlinking of ghost windows so they can be garbage collected.
pref("browser.ghostbuster.enabled", true);
// Disable GC on memory pressure, avoid incessant recycling when websites
// misbehave. Should also avoid spurious GCs during ghostbusting.
pref("javascript.options.gc_on_memory_pressure", false);
// This is the pref to control the location bar, change this to true to
// force this - this makes the origin of popup windows more obvious to avoid
// spoofing. We would rather not do it by default because it affects UE for web
@ -576,8 +582,8 @@ pref("network.http.pipelining.ssl", true);
pref("network.predictor.enabled", false);
pref("network.prefetch-next", false);
// Disable DNS prefetching
pref("network.dns.disablePrefetch", true);
// Enable DNS prefetching
pref("network.dns.disablePrefetch", false);
// Tune DNS lookups
pref("network.dnsCacheEntries", 800);
@ -631,7 +637,7 @@ pref("browser.xul.error_pages.expert_bad_cert", false);
// Work Offline is best manually managed by the user.
pref("network.manage-offline-status", false);
// We want to make sure mail URLs are handled externally...
// We want to make sure known external protocol URLs are handled externally.
pref("network.protocol-handler.external.mailto", true); // for mail
pref("network.protocol-handler.external.news", true); // for news
pref("network.protocol-handler.external.snews", true); // for secure news
@ -640,11 +646,11 @@ pref("network.protocol-handler.external.nntp", true); // also news
pref("network.protocol-handler.external.ms-windows-store", true);
#endif
// ...without warning dialogs
// Configure external handler warning dialogs.
pref("network.protocol-handler.warn-external.mailto", false);
pref("network.protocol-handler.warn-external.news", false);
pref("network.protocol-handler.warn-external.snews", false);
pref("network.protocol-handler.warn-external.nntp", false);
pref("network.protocol-handler.warn-external.news", true);
pref("network.protocol-handler.warn-external.snews", true);
pref("network.protocol-handler.warn-external.nntp", true);
#ifdef XP_WIN
pref("network.protocol-handler.warn-external.ms-windows-store", false);
#endif

View file

@ -2132,15 +2132,28 @@
}
// We're going to remove the tab and the browser now.
// Interrupt all tab activity to aid in cleaning up detached window objects.
// Using the "STOP_ALL" flag should halt all animations, fetches, network
// activity, etc. to come to a clean state for removal and unlinking (if enabled).
var browser = this.getBrowserForTab(aTab);
browser.webNavigation.stop(nsIWebNavigation.STOP_ALL);
// Clean up mTabFilters and mTabListeners now rather than in
// _beginRemoveTab, so that their size is always in sync with the
// number of tabs and browsers (the xbl destructor depends on this).
this.mTabFilters.splice(aTab._tPos, 1);
this.mTabListeners.splice(aTab._tPos, 1);
var browser = this.getBrowserForTab(aTab);
this._outerWindowIDBrowserMap.delete(browser.outerWindowID);
if (Services.prefs.getBoolPref("browser.ghostbuster.enabled", true)) {
Cu.unlinkGhostWindows();
#ifdef DEBUG
dump("Unlinking ghost windows has run on tab close.\n");
#endif
}
// Because of the way XBL works (fields just set JS
// properties on the element) and the code we have in place
// to preserve the JS objects for any elements that have

View file

@ -62,6 +62,10 @@ const BOOKMARKS_BACKUP_INTERVAL = 86400 * 1000;
// Maximum number of backups to create. Old ones will be purged.
const BOOKMARKS_BACKUP_MAX_BACKUPS = 10;
// Use users' idle time to unlink ghost windows and clean up memory.
// Trigger this by default every 5 minutes.
const GHOSTBUSTER_INTERVAL = 5 * 60;
// Factory object
const BrowserGlueServiceFactory = {
_instance: null,
@ -82,6 +86,10 @@ function BrowserGlue() {
"@mozilla.org/widget/idleservice;1",
"nsIIdleService");
XPCOMUtils.defineLazyServiceGetter(this, "_ghostBusterService",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService");
XPCOMUtils.defineLazyGetter(this, "_distributionCustomizer", function() {
Cu.import("resource:///modules/distribution.js");
return new DistributionCustomizer();
@ -109,6 +117,7 @@ BrowserGlue.prototype = {
_isPlacesShutdownObserver: false,
_isPlacesDatabaseLocked: false,
_migrationImportsDefaultBookmarks: false,
_isGhostBusterObserver: false,
_setPrefToSaveSession: function(aForce) {
if (!this._saveSession && !aForce) {
@ -241,6 +250,15 @@ BrowserGlue.prototype = {
if (this._idleService.idleTime > BOOKMARKS_BACKUP_IDLE_TIME * 1000) {
this._backupBookmarks();
}
if (this._ghostBusterService.idleTime > GHOSTBUSTER_INTERVAL * 1000) {
if (Services.prefs.getBoolPref("browser.ghostbuster.enabled", true)) {
Cu.unlinkGhostWindows();
Cu.forceGC();
#ifdef DEBUG
dump("Unlinking ghost windows + GC has run on idle.\n");
#endif
}
}
break;
case "distribution-customization-complete":
Services.obs.removeObserver(this, "distribution-customization-complete");
@ -623,6 +641,13 @@ BrowserGlue.prototype = {
DateTimePickerHelper.init();
this._trackSlowStartup();
// Initialize ghost window idle observer.
if (!this._isGhostBusterObserver) {
this._ghostBusterService.addIdleObserver(this, GHOSTBUSTER_INTERVAL);
// Prevent re-entry.
this._isGhostBusterObserver = true;
}
},
/**
@ -639,6 +664,14 @@ BrowserGlue.prototype = {
FormValidationHandler.uninit();
AutoCompletePopup.uninit();
this._dispose();
// Shut down ghost window idle observer.
if (this._isGhostBusterObserver) {
this._ghostBusterService.removeIdleObserver(this, GHOSTBUSTER_INTERVAL);
this._isGhostBusterObserver = false;
}
// Do one final unlink to combat shutdown issues.
Cu.unlinkGhostWindows();
},
// All initial windows have opened.

View file

@ -52,6 +52,9 @@
<preference id="pref.general.captiveportal" name="network.captive-portal-service.enabled" type="bool"/>
<!-- Network tab -->
<preference id="network.dns.prefetch" name="network.dns.disablePrefetch" type="bool" inverted="true"/>
<!-- Cache tab -->
<preference id="browser.cache.disk.capacity" name="browser.cache.disk.capacity" type="int"/>
<preference id="browser.cache.disk.smart_size.enabled"
@ -124,6 +127,7 @@
<tabs id="tabsElement">
<tab id="generalTab" label="&generalTab.label;" helpTopic="prefs-advanced-general"/>
<tab id="networkTab" label="&networkTab.label;" helpTopic="prefs-advanced-network"/>
<tab id="cacheTab" label="&cacheTab.label;" helpTopic="prefs-advanced-cache"/>
<tab id="updateTab" label="&updateTab.label;" helpTopic="prefs-advanced-update"/>
<tab id="encryptionTab" label="&certificateTab.label;" helpTopic="prefs-advanced-encryption"/>
<tab id="scrollparamTab" label="&scrollparamTab.label;" helpTopic="prefs-advanced-scrollparams"/>
@ -221,7 +225,6 @@
<!-- Network -->
<tabpanel id="networkPanel" orient="vertical">
<!-- Connection -->
<groupbox id="connectionGroup">
<caption label="&connection.label;"/>
@ -233,8 +236,20 @@
oncommand="gAdvancedPane.showConnections();"/>
</hbox>
</groupbox>
<!-- DNS settings -->
<groupbox id="DNSGroup">
<caption label="&DNS.label;"/>
<checkbox id="enableDNSPrefetch"
label="&enableDNSPrefetch.label;"
accesskey="&enableDNSPrefetch.accesskey;"
preference="network.dns.prefetch"/>
</groupbox>
</tabpanel>
<!-- Cache -->
<tabpanel id="cachePanel" orient="vertical">
<!-- Cache -->
<groupbox id="cacheGroup">
<caption label="&httpCache.label;"/>

View file

@ -61,6 +61,12 @@
<!ENTITY connectionSettings.label "Settings…">
<!ENTITY connectionSettings.accesskey "e">
<!ENTITY DNS.label "DNS">
<!ENTITY enableDNSPrefetch.label "Prefetch DNS lookups">
<!ENTITY enableDNSPrefetch.accesskey "P">
<!ENTITY cacheTab.label "Cache">
<!ENTITY httpCache.label "Cached Web Content">
<!ENTITY offlineStorage2.label "Offline Web Content and User Data">