Bug 1045096. Make sure initial about:blank in iframes have a nsDOMNavigationTiming object, so we don't end up with window.performance throwing when accessed on their window. r=smaug

This commit is contained in:
Boris Zbarsky
2014-08-04 01:25:30 -04:00
parent 2d5e318af3
commit 75c61b0a15
3 changed files with 41 additions and 2 deletions

View File

@@ -7366,15 +7366,18 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
// mContentViewer->PermitUnload may release |this| docshell.
nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
// Make sure timing is created. But first record whether we had it
// already, so we don't clobber the timing for an in-progress load.
bool hadTiming = mTiming;
MaybeInitTiming();
if (mContentViewer) {
// We've got a content viewer already. Make sure the user
// permits us to discard the current document and replace it
// with about:blank. And also ensure we fire the unload events
// in the current document.
// Make sure timing is created. Unload gets fired first for
// Unload gets fired first for
// document loaded from the session history.
MaybeInitTiming();
mTiming->NotifyBeforeUnload();
bool okToUnload;
@@ -7459,6 +7462,12 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
// The transient about:blank viewer doesn't have a session history entry.
SetHistoryEntry(&mOSHE, nullptr);
// Clear out our mTiming like we would in EndPageLoad, if we didn't
// have one before entering this function.
if (!hadTiming) {
mTiming = nullptr;
}
return rv;
}