Bug 1317212 - Make tab progress listeners smarter at ignoring nsIWebProgress notifications from an initial about:blank. r?Gijs
MozReview-Commit-ID: Ji1oCNZksge
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -575,16 +575,25 @@
if ((aRequest instanceof Ci.nsIChannel) &&
aRequest.originalURI.schemeIs("about") &&
(aRequest.URI.schemeIs("jar") || aRequest.URI.schemeIs("file")))
return false;
return true;
},
+ _isForInitialAboutBlank(aWebProgress, aLocation) {
+ if (!this.mBlank || !aWebProgress.isTopLevel) {
+ return false;
+ }
+
+ let location = aLocation ? aLocation.spec : "";
+ return location == "about:blank";
+ },
+
onProgressChange(aWebProgress, aRequest,
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress) {
this.mTotalProgress = aMaxTotalProgress ? aCurTotalProgress / aMaxTotalProgress : 0;
if (!this._shouldShowProgress(aRequest))
return;
@@ -604,27 +613,37 @@
aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress,
aMaxTotalProgress);
},
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
if (!aRequest)
return;
- var oldBlank = this.mBlank;
-
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
const nsIChannel = Components.interfaces.nsIChannel;
let location, originalLocation;
try {
aRequest.QueryInterface(nsIChannel)
location = aRequest.URI;
originalLocation = aRequest.originalURI;
} catch (ex) {}
+ let ignoreBlank = this._isForInitialAboutBlank(aWebProgress, location);
+ // If we were ignoring some messages about the initial about:blank, and we
+ // got the STATE_STOP for it, we'll want to pay attention to those messages
+ // from here forward. Similarly, if we conclude that this state change
+ // is one that we shouldn't be ignoring, then stop ignoring.
+ if ((ignoreBlank &&
+ aStateFlags & nsIWebProgressListener.STATE_STOP &&
+ aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) ||
+ !ignoreBlank && this.mBlank) {
+ this.mBlank = false;
+ }
+
if (aStateFlags & nsIWebProgressListener.STATE_START) {
this.mRequestCount++;
} else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
const NS_ERROR_UNKNOWN_HOST = 2152398878;
if (--this.mRequestCount > 0 && aStatus == NS_ERROR_UNKNOWN_HOST) {
// to prevent bug 235825: wait for the request handled
// by the automatic keyword resolver
return;
@@ -701,31 +720,28 @@
} else if (isSuccessful) {
this.mBrowser.urlbarChangeTracker.finishedLoad();
}
if (!this.mBrowser.mIconURL)
this.mTabBrowser.useDefaultIcon(this.mTab);
}
- if (this.mBlank)
- this.mBlank = false;
-
// For keyword URIs clear the user typed value since they will be changed into real URIs
if (location.scheme == "keyword")
this.mBrowser.userTypedValue = null;
if (this.mTab.label == this.mTabBrowser.mStringBundle.getString("tabs.connecting"))
this.mTabBrowser.setTabTitle(this.mTab);
if (this.mTab.selected)
this.mTabBrowser.mIsBusy = false;
}
- if (oldBlank) {
+ if (ignoreBlank) {
this._callProgressListeners("onUpdateCurrentBrowser",
[aStateFlags, aStatus, "", 0],
true, false);
} else {
this._callProgressListeners("onStateChange",
[aWebProgress, aRequest, aStateFlags, aStatus],
true, false);
}