Bug 635844 part 2: Update pushState to latest agreed behavior. r=jlebar a=beltzner/jst

This commit is contained in:
Jonas Sicking
2011-02-28 23:08:56 -08:00
parent 96ca0dec0a
commit d3c29932f7
13 changed files with 234 additions and 81 deletions

View File

@@ -5782,6 +5782,9 @@ nsDocShell::Embed(nsIContentViewer * aContentViewer,
if (mLSHE->HasDetachedEditor()) {
ReattachEditorToWindow(mLSHE);
}
// Set history.state
SetDocCurrentStateObj(mLSHE);
SetHistoryEntry(&mOSHE, mLSHE);
}
@@ -6072,10 +6075,6 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
// Notify the ContentViewer that the Document has finished loading. This
// will cause any OnLoad(...) and PopState(...) handlers to fire.
if (!mEODForCurrentDocument && mContentViewer) {
// Set the pending state object which will be returned to the page in
// the popstate event.
SetDocCurrentStateObj(mLSHE);
mIsExecutingOnLoadHandler = PR_TRUE;
mContentViewer->LoadComplete(aStatus);
mIsExecutingOnLoadHandler = PR_FALSE;
@@ -8429,7 +8428,12 @@ nsDocShell::InternalLoad(nsIURI * aURI,
// Dispatch the popstate and hashchange events, as appropriate.
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mScriptGlobal);
if (window) {
window->DispatchSyncPopState();
// Need the doHashchange check here since sameDocIdent is
// false if we're navigating to a new shentry (i.e. a aSHEntry
// is null), such as when clicking a <a href="#foo">.
if (sameDocIdent || doHashchange) {
window->DispatchSyncPopState();
}
if (doHashchange)
window->DispatchAsyncHashchange();
@@ -9828,6 +9832,7 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
else {
FireDummyOnLocationChange();
}
document->SetCurrentStateObject(dataStr);
return NS_OK;
}