Bug 311007 - Add aFlags arg to onLocationChange(...), to distinguish between same-document and different-document. r=smaug, sr=bzbarsky

This commit is contained in:
Oonishi Atsushi 2011-11-10 15:01:11 +01:00
parent f1ee85e466
commit 5db5ec8f54
53 changed files with 381 additions and 88 deletions

View File

@ -238,7 +238,8 @@ nsAccDocManager::OnProgressChange(nsIWebProgress *aWebProgress,
NS_IMETHODIMP
nsAccDocManager::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aLocation)
nsIRequest *aRequest, nsIURI *aLocation,
PRUint32 aFlags)
{
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
return NS_OK;

View File

@ -4586,7 +4586,7 @@ var XULBrowserWindow = {
}
},
onLocationChange: function (aWebProgress, aRequest, aLocationURI) {
onLocationChange: function (aWebProgress, aRequest, aLocationURI, aFlags) {
var location = aLocationURI ? aLocationURI.spec : "";
this._hostChanged = true;
@ -5052,7 +5052,8 @@ var TabsProgressListener = {
}
},
onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI) {
onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI,
aFlags) {
// Filter out any sub-frame loads
if (aBrowser.contentWindow == aWebProgress.DOMWindow)
FullZoom.onLocationChange(aLocationURI, false, aBrowser);

View File

@ -608,7 +608,8 @@
this.mStatus = aStatus;
},
onLocationChange: function (aWebProgress, aRequest, aLocation) {
onLocationChange: function (aWebProgress, aRequest, aLocation,
aFlags) {
// OnLocationChange is called for both the top-level content
// and the subframes.
let topLevel = aWebProgress.DOMWindow == this.mBrowser.contentWindow;
@ -641,7 +642,8 @@
if (!this.mBlank) {
this._callProgressListeners("onLocationChange",
[aWebProgress, aRequest, aLocation]);
[aWebProgress, aRequest, aLocation,
aFlags]);
}
if (topLevel)
@ -890,7 +892,8 @@
var securityUI = this.mCurrentBrowser.securityUI;
this._callProgressListeners(null, "onLocationChange",
[webProgress, null, loc], true, false);
[webProgress, null, loc, 0], true,
false);
if (securityUI) {
this._callProgressListeners(null, "onSecurityChange",

View File

@ -17,7 +17,7 @@ var gFrontProgressListener = {
gFrontNotificationsPos++;
},
onLocationChange: function (aWebProgress, aRequest, aLocationURI) {
onLocationChange: function (aWebProgress, aRequest, aLocationURI, aFlags) {
var state = "onLocationChange";
info("FrontProgress: " + state + " " + aLocationURI.spec);
ok(gFrontNotificationsPos < gFrontNotifications.length, "Got an expected notification for the front notifications listener");
@ -53,7 +53,8 @@ var gAllProgressListener = {
}
},
onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI) {
onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI,
aFlags) {
var state = "onLocationChange";
info("AllProgress: " + state + " " + aLocationURI.spec);
ok(aBrowser == gTestBrowser, state + " notification came from the correct browser");

View File

@ -72,7 +72,7 @@ var panelProgressListener = {
}
,
onLocationChange : function(aWebProgress, aRequest, aLocation) {
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) {
UpdateBackForwardCommands(getPanelBrowser().webNavigation);
},

View File

@ -64,7 +64,8 @@ var gTabsListener = {
"Tab has been opened in current browser window");
},
onLocationChange: function(aBrowser, aWebProgress, aRequest, aLocationURI) {
onLocationChange: function(aBrowser, aWebProgress, aRequest, aLocationURI,
aFlags) {
var spec = aLocationURI.spec;
ok(true, spec);
// When a new tab is opened, location is first set to "about:blank", so

View File

@ -235,7 +235,8 @@ nsMacShellService::OnProgressChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP
nsMacShellService::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aLocation)
nsIURI* aLocation,
PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -395,7 +395,8 @@ nsHTMLDNSPrefetch::nsDeferrals::OnProgressChange(nsIWebProgress *aProgress,
NS_IMETHODIMP
nsHTMLDNSPrefetch::nsDeferrals::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *location)
nsIURI *location,
PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -1843,7 +1843,8 @@ nsHTMLFormElement::OnProgressChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP
nsHTMLFormElement::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* location)
nsIURI* location,
PRUint32 aFlags)
{
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
return NS_OK;

View File

@ -221,7 +221,7 @@ runItem.prototype =
onProgressChange: function(aProg, b,c,d,e,f)
{
},
onLocationChange: function(aProg, aRequest, aURI)
onLocationChange: function(aProg, aRequest, aURI, aFlags)
{
},
onStatusChange: function(aProg, aRequest, aStatus, aMessage)

View File

@ -1770,17 +1770,19 @@ nsDocShell::GetChromeEventHandler(nsIDOMEventTarget** aChromeEventHandler)
return NS_OK;
}
/* [noscript] void setCurrentURI (in nsIURI uri); */
/* void setCurrentURI (in nsIURI uri); */
NS_IMETHODIMP
nsDocShell::SetCurrentURI(nsIURI *aURI)
{
SetCurrentURI(aURI, nsnull, true);
// Note that securityUI will set STATE_IS_INSECURE, even if
// the scheme of |aURI| is "https".
SetCurrentURI(aURI, nsnull, true, 0);
return NS_OK;
}
bool
nsDocShell::SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
bool aFireOnLocationChange)
bool aFireOnLocationChange, PRUint32 aLocationFlags)
{
#ifdef PR_LOGGING
if (gDocShellLeakLog && PR_LOG_TEST(gDocShellLeakLog, PR_LOG_DEBUG)) {
@ -1824,7 +1826,7 @@ nsDocShell::SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
}
if (aFireOnLocationChange) {
FireOnLocationChange(this, aRequest, aURI);
FireOnLocationChange(this, aRequest, aURI, aLocationFlags);
}
return !aFireOnLocationChange;
}
@ -5928,7 +5930,7 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
// a new DOM here.
rv = AddToSessionHistory(uri, wcwgChannel, nsnull, false,
getter_AddRefs(mLSHE));
SetCurrentURI(uri, aRequest, true);
SetCurrentURI(uri, aRequest, true, 0);
// Save history state of the previous page
rv = PersistLayoutHistoryState();
// We'll never get an Embed() for this load, so just go ahead
@ -5984,8 +5986,8 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
}
NS_IMETHODIMP
nsDocShell::OnLocationChange(nsIWebProgress * aProgress,
nsIRequest * aRequest, nsIURI * aURI)
nsDocShell::OnLocationChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
nsIURI * aURI, PRUint32 aFlags)
{
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
return NS_OK;
@ -6515,7 +6517,7 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
viewer->SetContainer(static_cast<nsIContentViewerContainer *>(this));
Embed(viewer, "", 0);
SetCurrentURI(blankDoc->GetDocumentURI(), nsnull, true);
SetCurrentURI(blankDoc->GetDocumentURI(), nsnull, true, 0);
rv = mIsBeingDestroyed ? NS_ERROR_NOT_AVAILABLE : NS_OK;
}
}
@ -7166,7 +7168,7 @@ nsDocShell::RestoreFromHistory()
// is still mLSHE or whether it's now mOSHE.
nsCOMPtr<nsIURI> uri;
origLSHE->GetURI(getter_AddRefs(uri));
SetCurrentURI(uri, document->GetChannel(), true);
SetCurrentURI(uri, document->GetChannel(), true, 0);
}
// This is the end of our CreateContentViewer() replacement.
@ -7505,7 +7507,7 @@ nsDocShell::CreateContentViewer(const char *aContentType,
}
if (onLocationChangeNeeded) {
FireOnLocationChange(this, request, mCurrentURI);
FireOnLocationChange(this, request, mCurrentURI, 0);
}
return NS_OK;
@ -8365,6 +8367,11 @@ nsDocShell::InternalLoad(nsIURI * aURI,
// Pass true for aCloneSHChildren, since we're not
// changing documents here, so all of our subframes are
// still relevant to the new session history entry.
//
// It also makes OnNewURI(...) set LOCATION_CHANGE_SAME_DOCUMENT
// flag on firing onLocationChange(...).
// Anyway, aCloneSHChildren param is simply reflecting
// doShortCircuitedLoad in this scope.
OnNewURI(aURI, nsnull, owner, mLoadType, true, true, true);
nsCOMPtr<nsIInputStream> postData;
@ -9418,8 +9425,14 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, nsISupports* aOwner,
#endif
}
}
// aCloneSHChildren exactly means "we are not loading a new document".
PRUint32 locationFlags = aCloneSHChildren?
PRUint32(LOCATION_CHANGE_SAME_DOCUMENT) : 0;
bool onLocationChangeNeeded = SetCurrentURI(aURI, aChannel,
aFireOnLocationChange);
aFireOnLocationChange,
locationFlags);
// Make sure to store the referrer from the channel, if any
SetupReferrerFromChannel(aChannel);
return onLocationChangeNeeded;
@ -9727,8 +9740,14 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
// gets updated and the back button is enabled, but we only need to
// explicitly call FireOnLocationChange if we're not calling SetCurrentURI,
// since SetCurrentURI will call FireOnLocationChange for us.
//
// Both SetCurrentURI(...) and FireDummyOnLocationChange() pass
// nsnull for aRequest param to FireOnLocationChange(...). Such an update
// notification is allowed only when we know docshell is not loading a new
// document and it requires LOCATION_CHANGE_SAME_DOCUMENT flag. Otherwise,
// FireOnLocationChange(...) breaks security UI.
if (!equalURIs) {
SetCurrentURI(newURI, nsnull, true);
SetCurrentURI(newURI, nsnull, true, LOCATION_CHANGE_SAME_DOCUMENT);
document->SetDocumentURI(newURI);
AddURIVisit(newURI, oldURI, oldURI, 0);

View File

@ -269,10 +269,12 @@ public:
friend class OnLinkClickEvent;
// We need dummy OnLocationChange in some cases to update the UI.
// We need dummy OnLocationChange in some cases to update the UI without
// updating security info.
void FireDummyOnLocationChange()
{
FireOnLocationChange(this, nsnull, mCurrentURI);
FireOnLocationChange(this, nsnull, mCurrentURI,
LOCATION_CHANGE_SAME_DOCUMENT);
}
nsresult HistoryTransactionRemoved(PRInt32 aIndex);
@ -593,7 +595,8 @@ protected:
// FireOnLocationChange is called.
// In all other cases false is returned.
bool SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
bool aFireOnLocationChange);
bool aFireOnLocationChange,
PRUint32 aLocationFlags);
// The following methods deal with saving and restoring content viewers
// in session history.

View File

@ -122,6 +122,8 @@ _TEST_FILES = \
662200c.html \
test_bug690056.xul \
bug690056_window.xul \
test_bug311007.xul \
bug311007_window.xul \
$(NULL)
_DOCSHELL_SUBHARNESS = \

View File

@ -0,0 +1,186 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window id="311007Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="600"
height="600"
onload="startup();"
title="bug 311007 test">
<script type="application/javascript" src="docshell_helpers.js"></script>
<script type="application/javascript"><![CDATA[
/*
Regression test for bug 283733 and bug 307027.
Bug 283733
"accessing a relative anchor in a secure page removes the
locked icon and yellow background UI"
Bug 307027
"Going back from secure page to error page does not clear yellow bar"
*/
const kDNSErrorURI = "https://example/err.html";
const kSecureURI =
"https://example.com/tests/docshell/test/navigation/blank.html";
/*
Step 1: load a network error page. <err.html> Not Secure
Step 2: load a secure page. <blank.html> Secure
Step 3: a secure page + hashchange. <blank.html#foo> Secure (bug 283733)
Step 4: go back to the error page. <err.html> Not Secure (bug 307027)
*/
var gListener = null;
function WebProgressListener() {
this._callback = null;
}
WebProgressListener.prototype = {
QueryInterface: function(aIID) {
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
setTimeout(this._callback, 0, aWebProgress, aRequest, aLocation, aFlags);
},
set callback(aVal) {
this._callback = aVal;
}
};
function startup() {
gListener = new WebProgressListener();
document.getElementById("content")
.webProgress
.addProgressListener(gListener,
Components.interfaces.nsIWebProgress
.NOTIFY_LOCATION);
setTimeout(step1A, 0);
}
/******************************************************************************
* Step 1: Load an error page, and confirm UA knows it's insecure.
******************************************************************************/
function step1A() {
gListener.callback = step1B;
content.location = kDNSErrorURI;
}
function step1B(aWebProgress, aRequest, aLocation, aFlags) {
/* XXX Here we receive 2 notifications, due to bug 673752. */
if (!aRequest) {
return;
}
is(aLocation.spec, kDNSErrorURI, "Error page's URI (1)");
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
.LOCATION_CHANGE_SAME_DOCUMENT),
"DocShell loaded a document (1)");
ok(!(aWebProgress.QueryInterface(Components.interfaces.nsIDocShell)
.securityUI.state &
Components.interfaces.nsIWebProgressListener.STATE_IS_SECURE),
"This is not a secure page (1)");
/* Go to step 2. */
setTimeout(step2A, 0);
}
/******************************************************************************
* Step 2: Load a HTTPS page, and confirm it's secure.
******************************************************************************/
function step2A() {
gListener.callback = step2B;
content.location = kSecureURI;
}
function step2B(aWebProgress, aRequest, aLocation, aFlags) {
is(aLocation.spec, kSecureURI, "A URI on HTTPS (2)");
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
.LOCATION_CHANGE_SAME_DOCUMENT),
"DocShell loaded a document (2)");
ok((aWebProgress.QueryInterface(Components.interfaces.nsIDocShell)
.securityUI.state &
Components.interfaces.nsIWebProgressListener.STATE_IS_SECURE),
"This is a secure page (2)");
/* Go to step 3. */
setTimeout(step3A, 0);
}
/*****************************************************************************
* Step 3: Trigger hashchange within a secure page, and confirm UA knows
* it's secure. (Bug 283733)
*****************************************************************************/
function step3A() {
gListener.callback = step3B;
content.location += "#foo";
}
function step3B(aWebProgress, aRequest, aLocation, aFlags) {
is(aLocation.spec, kSecureURI + "#foo", "hashchange on HTTPS (3)");
ok((aFlags & Components.interfaces.nsIWebProgressListener
.LOCATION_CHANGE_SAME_DOCUMENT),
"We are in the same document as before (3)");
ok((aWebProgress.QueryInterface(Components.interfaces.nsIDocShell)
.securityUI.state &
Components.interfaces.nsIWebProgressListener.STATE_IS_SECURE),
"This is a secure page (3)");
/* Go to step 4. */
setTimeout(step4A, 0);
}
/*****************************************************************************
* Step 4: Go back from a secure page to an error page, and confirm UA knows
* it's not secure. (Bug 307027)
*****************************************************************************/
function step4A() {
gListener.callback = step4B;
content.history.go(-2);
}
function step4B(aWebProgress, aRequest, aLocation, aFlags) {
if (!aRequest) // See step1B(...) and bug 673752.
return;
is(aLocation.spec, kDNSErrorURI, "Go back to the error URI (4)");
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
.LOCATION_CHANGE_SAME_DOCUMENT),
"DocShell loaded a document (4)");
ok(!(aWebProgress.QueryInterface(Components.interfaces.nsIDocShell)
.securityUI.state &
Components.interfaces.nsIWebProgressListener.STATE_IS_SECURE),
"This is not a secure page (4)");
/* End. */
aWebProgress.removeProgressListener(gListener);
delete(gListener);
finish();
}
]]></script>
<browser type="content-primary" flex="1" id="content" src="about:blank"/>
</window>

View File

@ -0,0 +1,43 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet
href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=311007.xul
-->
<window title="Mozilla Bug 311007"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<title>Test for Bug 311007</title>
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=311007">
Mozilla Bug 311007</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
/** Test for Bug 311007 **/
SimpleTest.waitForExplicitFinish();
window.open("bug311007_window.xul", "bug311007",
"chrome,width=600,height=600");
]]>
</script>
</window>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window id="303267Test"
<window id="{BUGNUMBER}Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="600"
height="600"

View File

@ -837,7 +837,8 @@ nsEditingSession::OnProgressChange(nsIWebProgress *aWebProgress,
----------------------------------------------------------------------------*/
NS_IMETHODIMP
nsEditingSession::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aURI)
nsIRequest *aRequest, nsIURI *aURI,
PRUint32 aFlags)
{
nsCOMPtr<nsIDOMWindow> domWindow;
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));

View File

@ -78,7 +78,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=434998
{
},
onLocationChange : function(aWebProgress, aRequest, aLocation)
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
{
},

View File

@ -83,7 +83,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607584
{
},
onLocationChange : function(aWebProgress, aRequest, aLocation)
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
{
},

View File

@ -73,7 +73,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=616590
{
},
onLocationChange : function(aWebProgress, aRequest, aLocation)
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
{
},

View File

@ -723,7 +723,8 @@ nsDocShellTreeOwner::OnStateChange(nsIWebProgress* aProgress,
NS_IMETHODIMP
nsDocShellTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aURI)
nsIURI* aURI,
PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -852,12 +852,12 @@ NS_IMETHODIMP nsWebBrowser::OnProgressChange(nsIWebProgress *aWebProgress, nsIRe
return NS_OK;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP nsWebBrowser::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP nsWebBrowser::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
if (mProgressListener)
{
return mProgressListener->OnLocationChange(aWebProgress, aRequest, location);
return mProgressListener->OnLocationChange(aWebProgress, aRequest, location, aFlags);
}
return NS_OK;
}

View File

@ -257,8 +257,8 @@ NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, ns
return rv;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -136,9 +136,9 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
return NS_OK;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -254,8 +254,8 @@ NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, ns
return rv;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -289,12 +289,12 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
return NS_OK;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
if (mWebProgressListener) {
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location);
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location, aFlags);
}
return NS_OK;
}

View File

@ -257,8 +257,8 @@ NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, ns
return rv;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -308,12 +308,12 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
return NS_OK;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
if (mWebProgressListener) {
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location);
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location, aFlags);
}
return NS_OK;
}

View File

@ -285,8 +285,8 @@ NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, ns
return rv;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -357,13 +357,13 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
return NS_ERROR_FAILURE;
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
NS_IMETHODIMP
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, PRUint32 aFlags)
{
if (mWebProgressListener)
{
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location);
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location, aFlags);
}
return NS_ERROR_FAILURE;
}

View File

@ -276,7 +276,8 @@ NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIReque
NS_IMETHODIMP WebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *location)
nsIURI *location,
PRUint32 aFlags)
{
bool isSubFrameLoad = false; // Is this a subframe load
if (aWebProgress) {

View File

@ -20,7 +20,7 @@ function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
var listener = {
onLocationChange: function(webProgress, request, location) { },
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
maxSelfProgress, curTotalProgress,
maxTotalProgress) { },

View File

@ -20,7 +20,7 @@ function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
var listener = {
onLocationChange: function(webProgress, request, location) { },
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
maxSelfProgress, curTotalProgress,
maxTotalProgress) { },

View File

@ -27,7 +27,7 @@ function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
var listener = {
onLocationChange: function(webProgress, request, location) { },
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
maxSelfProgress, curTotalProgress,
maxTotalProgress) { },

View File

@ -105,7 +105,7 @@ nsLDBBrowserContentListener.prototype = {
{
},
onLocationChange : function(aWebProgress, aRequest, aLocation)
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
{
this.mURLBar.value = aLocation.spec;
this.setButtonEnabled(this.mForwardButton, gBrowser.canGoForward);

View File

@ -35,7 +35,7 @@ let WebProgressListener = {
_firstPaint: false,
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocationURI) {
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocationURI, aFlags) {
if (content != aWebProgress.DOMWindow)
return;

View File

@ -1511,7 +1511,8 @@ nsresult nsSecureBrowserUIImpl::TellTheWorld(bool showWarning,
NS_IMETHODIMP
nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aLocation)
nsIURI* aLocation,
PRUint32 aFlags)
{
#ifdef DEBUG
nsAutoAtomic atomic(mOnStateLocationChangeReentranceDetection);
@ -1551,9 +1552,10 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress,
NS_ASSERTION(window, "Window has gone away?!");
}
// If the location change does not have a corresponding request, then we
// assume that it does not impact the security state.
if (!aRequest)
// When |aRequest| is null, basically we don't trust that document. But if
// docshell insists that the document has not changed at all, we will reuse
// the previous security state, no matter what |aRequest| may be.
if (aFlags & LOCATION_CHANGE_SAME_DOCUMENT)
return NS_OK;
// The location bar has changed, so we must update the security state. The

View File

@ -2482,7 +2482,8 @@ nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
NS_IMETHODIMP
nsDownload::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aLocation)
nsIRequest *aRequest, nsIURI *aLocation,
PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -123,10 +123,11 @@ public:
}
NS_IMETHODIMP OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aLocation)
nsIRequest *aRequest, nsIURI *aLocation,
PRUint32 aFlags)
{
NS_ENSURE_TRUE(mInner, NS_ERROR_NOT_INITIALIZED);
return mInner->OnLocationChange(aWebProgress, aRequest, aLocation);
return mInner->OnLocationChange(aWebProgress, aRequest, aLocation, aFlags);
}
NS_IMETHODIMP OnProgressChange(nsIWebProgress *aWebProgress,

View File

@ -543,7 +543,7 @@ nsHelpStatusHandler.prototype = {
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {},
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {},
onSecurityChange : function(aWebProgress, aRequest, state) {},
onLocationChange : function(aWebProgress, aRequest, aLocation) {
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) {
UpdateBackForwardButtons();
},
QueryInterface : function(aIID) {

View File

@ -91,7 +91,7 @@ var progressListener = {
}
},
onLocationChange: function (aWebProgress, aRequest, aLocation) {},
onLocationChange: function (aWebProgress, aRequest, aLocation, aFlags) {},
onSecurityChange: function (aWebProgress, aRequest, state) {},
onStatusChange: function (aWebProgress, aRequest, aStatus, aMessage)

View File

@ -180,7 +180,7 @@ var progressListener = {
}
},
onLocationChange: function(aWebProgress, aRequest, aLocation)
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags)
{
// we can ignore this notification
},

View File

@ -223,12 +223,14 @@ nsBrowserStatusFilter::OnProgressChange(nsIWebProgress *aWebProgress,
NS_IMETHODIMP
nsBrowserStatusFilter::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
nsIURI *aLocation)
nsIURI *aLocation,
PRUint32 aFlags)
{
if (!mListener)
return NS_OK;
return mListener->OnLocationChange(aWebProgress, aRequest, aLocation);
return mListener->OnLocationChange(aWebProgress, aRequest, aLocation,
aFlags);
}
NS_IMETHODIMP

View File

@ -109,7 +109,7 @@ nsUnkownContentTypeDialogProgressListener.prototype = {
onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus ) {
},
onLocationChange: function( aWebProgress, aRequest, aLocation ) {
onLocationChange: function( aWebProgress, aRequest, aLocation, aFlags ) {
},
onSecurityChange: function( aWebProgress, aRequest, state ) {

View File

@ -1909,7 +1909,7 @@ var gDiscoverView = {
this._browser.loadURIWithFlags(aURL, flags);
},
onLocationChange: function(aWebProgress, aRequest, aLocation) {
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
// Ignore the about:blank load
if (aLocation.spec == "about:blank")
return;

View File

@ -1391,7 +1391,8 @@ void nsDocLoader::DoFireOnStateChange(nsIWebProgress * const aProgress,
void
nsDocLoader::FireOnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *aUri)
nsIURI *aUri,
PRUint32 aFlags)
{
/*
* First notify any listeners of the new state info...
@ -1418,14 +1419,14 @@ nsDocLoader::FireOnLocationChange(nsIWebProgress* aWebProgress,
continue;
}
listener->OnLocationChange(aWebProgress, aRequest, aUri);
listener->OnLocationChange(aWebProgress, aRequest, aUri, aFlags);
}
mListenerInfoList.Compact();
// Pass the notification up to the parent...
if (mParent) {
mParent->FireOnLocationChange(aWebProgress, aRequest, aUri);
mParent->FireOnLocationChange(aWebProgress, aRequest, aUri, aFlags);
}
}

View File

@ -185,7 +185,8 @@ protected:
void FireOnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *aUri);
nsIURI *aUri,
PRUint32 aFlags);
bool RefreshAttempted(nsIWebProgress* aWebProgress,
nsIURI *aURI,

View File

@ -51,7 +51,7 @@ interface nsIURI;
* nsIWebProgress instances. nsIWebProgress.idl describes the parent-child
* relationship of nsIWebProgress instances.
*/
[scriptable, uuid(570F39D1-EFD0-11d3-B093-00A024FFC08C)]
[scriptable, uuid(a0cda7e4-c6ca-11e0-b6a5-001320257da5)]
interface nsIWebProgressListener : nsISupports
{
/**
@ -302,6 +302,16 @@ interface nsIWebProgressListener : nsISupports
in long aCurTotalProgress,
in long aMaxTotalProgress);
/**
* Flags for onLocationChange
*
* LOCATION_CHANGE_SAME_DOCUMENT
* This flag is on when |aWebProgress| did not load a new document.
* For example, the location change is due to an anchor scroll or a
* pushState/popState/replaceState.
*/
const unsigned long LOCATION_CHANGE_SAME_DOCUMENT = 0x00000001;
/**
* Called when the location of the window being watched changes. This is not
* when a load is requested, but rather once it is verified that the load is
@ -316,10 +326,14 @@ interface nsIWebProgressListener : nsISupports
* The associated nsIRequest. This may be null in some cases.
* @param aLocation
* The URI of the location that is being loaded.
* @param aFlags
* This is a value which explains the situation or the reason why
* the location has changed.
*/
void onLocationChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in nsIURI aLocation);
in nsIURI aLocation,
[optional] in unsigned long aFlags);
/**
* Notification that the status of a request has changed. The status message

View File

@ -206,7 +206,8 @@ nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP
nsOfflineCachePendingUpdate::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *location)
nsIURI *location,
PRUint32 aFlags)
{
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
return NS_OK;

View File

@ -898,7 +898,8 @@ nsPrefetchService::OnStateChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP
nsPrefetchService::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *location)
nsIURI *location,
PRUint32 aFlags)
{
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
return NS_OK;

View File

@ -189,7 +189,8 @@ TestApp::OnProgressChange(nsIWebProgress *aWebProgress,
NS_IMETHODIMP
TestApp::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
nsIURI *aLocation)
nsIURI *aLocation,
PRUint32 aFlags)
{
return NS_OK;
}

View File

@ -535,7 +535,8 @@ nsChromeTreeOwner::OnStateChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP nsChromeTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aLocation)
nsIURI* aLocation,
PRUint32 aFlags)
{
bool itsForYou = true;

View File

@ -595,7 +595,8 @@ nsWebShellWindow::OnStateChange(nsIWebProgress *aProgress,
NS_IMETHODIMP
nsWebShellWindow::OnLocationChange(nsIWebProgress *aProgress,
nsIRequest *aRequest,
nsIURI *aURI)
nsIURI *aURI,
PRUint32 aFlags)
{
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
return NS_OK;