# HG changeset patch # User Justin Lebar # Date 1309999369 14400 # Node ID 5c7105814a452089a7811dfd9f17e327ffe145cf # Parent 2d57f8e6aabb786366a15b3d3a34e0ea93308074 Bug 669671 - When navigating to a history entry created via pushState or touched by replaceState, we should not force the load from cache. diff --git a/docshell/shistory/public/nsISHEntry.idl b/docshell/shistory/public/nsISHEntry.idl --- a/docshell/shistory/public/nsISHEntry.idl +++ b/docshell/shistory/public/nsISHEntry.idl @@ -54,17 +54,17 @@ interface nsIStructuredCloneContainer; %{C++ struct nsIntRect; class nsDocShellEditorData; %} [ref] native nsIntRect(nsIntRect); [ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData); -[scriptable, uuid(5f3ebf43-6944-45fb-b1b1-78a05bf9370b)] +[scriptable, uuid(b92d403e-f5ec-4b81-b0e3-6e6c241cef2d)] interface nsISHEntry : nsIHistoryEntry { /** URI for the document */ void setURI(in nsIURI aURI); /** Referrer URI */ attribute nsIURI referrerURI; @@ -164,16 +164,26 @@ interface nsISHEntry : nsIHistoryEntry /** attribute to indicate whether the page is already expired in cache */ attribute boolean expirationStatus; /** * attribute to indicate the content-type of the document that this * is a session history entry for */ attribute ACString contentType; + + /** + * Was this SHEntry created via a call to history.pushState with a URI + * which differed from the original URI in more than just the hash, or was + * its URI changed via a call to history.replaceState? If so, this field + * is true. + * + * Calling setUniqueDocIdentifier() sets this field to false. + */ + attribute boolean URIWasModified; /** Set/Get scrollers' positon in anchored pages */ void setScrollPosition(in long x, in long y); void getScrollPosition(out long x, out long y); /** Additional ways to create an entry */ [noscript] void create(in nsIURI URI, in AString title, in nsIInputStream inputStream, diff --git a/docshell/shistory/src/nsSHEntry.cpp b/docshell/shistory/src/nsSHEntry.cpp --- a/docshell/shistory/src/nsSHEntry.cpp +++ b/docshell/shistory/src/nsSHEntry.cpp @@ -103,16 +103,17 @@ static void StopTrackingEntry(nsSHEntry nsSHEntry::nsSHEntry() : mLoadType(0) , mID(gEntryID++) , mDocIdentifier(gEntryDocIdentifier++) , mScrollPositionX(0) , mScrollPositionY(0) + , mURIWasModified(PR_FALSE) , mIsFrameNavigation(PR_FALSE) , mSaveLayoutState(PR_TRUE) , mExpired(PR_FALSE) , mSticky(PR_TRUE) , mDynamicallyCreated(PR_FALSE) , mParent(nsnull) , mViewerBounds(0, 0, 0, 0) , mDocShellID(0) @@ -127,16 +128,17 @@ nsSHEntry::nsSHEntry(const nsSHEntry &ot , mTitle(other.mTitle) , mPostData(other.mPostData) , mLayoutHistoryState(other.mLayoutHistoryState) , mLoadType(0) // XXX why not copy? , mID(other.mID) , mDocIdentifier(other.mDocIdentifier) , mScrollPositionX(0) // XXX why not copy? , mScrollPositionY(0) // XXX why not copy? + , mURIWasModified(other.mURIWasModified) , mIsFrameNavigation(other.mIsFrameNavigation) , mSaveLayoutState(other.mSaveLayoutState) , mExpired(other.mExpired) , mSticky(PR_TRUE) , mDynamicallyCreated(other.mDynamicallyCreated) // XXX why not copy mContentType? , mCacheKey(other.mCacheKey) , mParent(other.mParent) @@ -203,16 +205,28 @@ NS_IMETHODIMP nsSHEntry::SetScrollPositi NS_IMETHODIMP nsSHEntry::GetScrollPosition(PRInt32 *x, PRInt32 *y) { *x = mScrollPositionX; *y = mScrollPositionY; return NS_OK; } +NS_IMETHODIMP nsSHEntry::GetURIWasModified(PRBool* aOut) +{ + *aOut = mURIWasModified; + return NS_OK; +} + +NS_IMETHODIMP nsSHEntry::SetURIWasModified(PRBool aIn) +{ + mURIWasModified = aIn; + return NS_OK; +} + NS_IMETHODIMP nsSHEntry::GetURI(nsIURI** aURI) { *aURI = mURI; NS_IF_ADDREF(*aURI); return NS_OK; } NS_IMETHODIMP nsSHEntry::SetURI(nsIURI* aURI) diff --git a/docshell/shistory/src/nsSHEntry.h b/docshell/shistory/src/nsSHEntry.h --- a/docshell/shistory/src/nsSHEntry.h +++ b/docshell/shistory/src/nsSHEntry.h @@ -97,16 +97,17 @@ private: nsCOMPtr mPostData; nsCOMPtr mLayoutHistoryState; nsCOMArray mChildren; PRUint32 mLoadType; PRUint32 mID; PRInt64 mDocIdentifier; PRInt32 mScrollPositionX; PRInt32 mScrollPositionY; + PRPackedBool mURIWasModified; PRPackedBool mIsFrameNavigation; PRPackedBool mSaveLayoutState; PRPackedBool mExpired; PRPackedBool mSticky; PRPackedBool mDynamicallyCreated; nsCString mContentType; nsCOMPtr mCacheKey; nsISHEntry * mParent; // weak reference diff --git a/docshell/test/Makefile.in b/docshell/test/Makefile.in --- a/docshell/test/Makefile.in +++ b/docshell/test/Makefile.in @@ -111,16 +111,18 @@ _TEST_FILES = \ file_bug660404^headers^ \ test_bug662170.html \ file_bug662170.html \ test_bug570341.html \ bug570341_recordevents.html \ test_bug668513.html \ bug668513_redirect.html \ bug668513_redirect.html^headers^ \ + test_bug669671.html \ + file_bug669671.sjs \ $(NULL) ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) _TEST_FILES += \ test_bug511449.html \ file_bug511449.html \ $(NULL) endif diff --git a/docshell/test/file_bug669671.sjs b/docshell/test/file_bug669671.sjs new file mode 100644 --- /dev/null +++ b/docshell/test/file_bug669671.sjs @@ -0,0 +1,13 @@ +function handleRequest(request, response) +{ + var count = parseInt(getState('count')); + if (!count) + count = 0; + setState('count', count + 1 + ''); + + response.setHeader('Content-Type', 'text/html', false); + response.setHeader('Cache-Control', 'no-cache'); + response.write('' + + count + ''); +} diff --git a/docshell/test/test_bug669671.html b/docshell/test/test_bug669671.html new file mode 100644 --- /dev/null +++ b/docshell/test/test_bug669671.html @@ -0,0 +1,78 @@ + + + + + Test for Bug 669671 + + + + + +Mozilla Bug 669671 +

+ +
+
+
+ +