commit c8e38a7f68cb207a419c278e17c1f0183155430f parent b383d13135c02470cb08301477094aa167c6c68b Author: Serban Stanca <sstanca@mozilla.com> Date: Fri, 3 Oct 2025 14:25:03 +0300 Revert "Bug 1991265 - Make push to replace load conversion follow spec. r=smaug" for causing wpt failures. This reverts commit 91a14bd0378b66562bc5597690dc21b024075cdd. Diffstat:
48 files changed, 152 insertions(+), 244 deletions(-)
diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp @@ -2127,7 +2127,6 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState, if (mDocShell) { nsCOMPtr<nsIDocShell> docShell = mDocShell; - return docShell->LoadURI(aLoadState, aSetNavigating); } @@ -2438,7 +2437,7 @@ BrowsingContext::CheckURLAndCreateLoadState(nsIURI* aURI, void BrowsingContext::Navigate(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv, NavigationHistoryBehavior aHistoryHandling, - bool aNeedsCompletelyLoadedDocument) { + bool aShouldNotForceReplaceInOnLoad) { MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Navigate to {} as {}", *aURI, aHistoryHandling); CallerType callerType = aSubjectPrincipal.IsSystemPrincipal() @@ -2457,16 +2456,27 @@ void BrowsingContext::Navigate(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, return; } - if (mozilla::SessionHistoryInParent()) { - loadState->SetNeedsCompletelyLoadedDocument(aNeedsCompletelyLoadedDocument); - - loadState->SetShouldNotForceReplaceInOnLoad( - /* aShouldNotForceReplaceInOnLoad */ true); + loadState->SetShouldNotForceReplaceInOnLoad(aShouldNotForceReplaceInOnLoad); - loadState->SetHistoryBehavior(aHistoryHandling); + // Step 12 + NavigationHistoryBehavior historyHandling = aHistoryHandling; + if (aHistoryHandling == NavigationHistoryBehavior::Auto) { + if (auto* document = GetExtantDocument()) { + bool equals = false; + aURI->Equals(document->GetDocumentURI(), &equals); + if (equals && document->GetPrincipal()) { + document->GetPrincipal()->Equals(&aSubjectPrincipal, &equals); + } + if (equals) { + historyHandling = NavigationHistoryBehavior::Replace; + } else { + historyHandling = NavigationHistoryBehavior::Push; + } + } } - if (aHistoryHandling == NavigationHistoryBehavior::Replace) { + // Step 13 of #navigate are handled later in nsDocShell::InternalLoad(). + if (historyHandling == NavigationHistoryBehavior::Replace) { loadState->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE); } else { loadState->SetLoadType(LOAD_STOP_CONTENT); diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h @@ -459,7 +459,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache { void Navigate(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv, NavigationHistoryBehavior aHistoryHandling = NavigationHistoryBehavior::Auto, - bool aNeedsCompletelyLoadedDocument = false); + bool aShouldNotForceReplaceInOnLoad = false); // Removes the root document for this BrowsingContext tree from the BFCache, // if it is cached, and returns true if it was. diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp @@ -72,7 +72,6 @@ #include "mozilla/dom/Navigation.h" #include "mozilla/dom/NavigationBinding.h" #include "mozilla/dom/NavigationHistoryEntry.h" -#include "mozilla/dom/NavigationUtils.h" #include "mozilla/dom/PerformanceNavigation.h" #include "mozilla/dom/PermissionMessageUtils.h" #include "mozilla/dom/PolicyContainer.h" @@ -8730,7 +8729,6 @@ struct SameDocumentNavigationState { bool mSameExceptHashes = false; bool mSecureUpgradeURI = false; bool mHistoryNavBetweenSameDoc = false; - bool mIdentical = false; }; bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState, @@ -8836,12 +8834,6 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState, } } - // Two URIs are identical if they're same except hashes, they both have - // hashes, and their hashes are the same. - aState.mIdentical = aState.mSameExceptHashes && - (aState.mNewURIHasRef == aState.mCurrentURIHasRef) && - aState.mCurrentHash.Equals(aState.mNewHash); - // A same document navigation happens when we navigate between two SHEntries // for the same document. We do a same document navigation under two // circumstances. Either @@ -9389,8 +9381,10 @@ nsresult nsDocShell::HandleSameDocumentNavigation( // https://html.spec.whatwg.org/multipage/browsing-the-web.html#updating-the-document navigation->UpdateEntriesForSameDocumentNavigation( mActiveEntry.get(), - NavigationUtils::NavigationTypeFromLoadType(mLoadType).valueOr( - NavigationType::Push)); + LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY) + ? NavigationType::Replace + : aLoadState->LoadIsFromSessionHistory() ? NavigationType::Traverse + : NavigationType::Push); } // Fire a hashchange event URIs differ, and only in their hashes. @@ -9471,34 +9465,6 @@ uint32_t nsDocShell::GetLoadTypeForFormSubmission( : LOAD_LINK; } -static void MaybeConvertToReplaceLoad(nsDocShellLoadState* aLoadState, - Document* aExtantDocument, - bool aIdenticalURI) { - if (!aExtantDocument || !mozilla::SessionHistoryInParent()) { - return; - } - - bool convertToReplaceLoad = aLoadState->NeedsCompletelyLoadedDocument() && - !aExtantDocument->IsCompletelyLoaded(); - if (const auto& historyBehavior = aLoadState->HistoryBehavior(); - !convertToReplaceLoad && historyBehavior && - *historyBehavior == NavigationHistoryBehavior::Auto) { - convertToReplaceLoad = aIdenticalURI; - if (convertToReplaceLoad && aExtantDocument->GetPrincipal()) { - aExtantDocument->GetPrincipal()->Equals(aLoadState->TriggeringPrincipal(), - &convertToReplaceLoad); - } - } - - if (convertToReplaceLoad) { - MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, - "Convert to replace when navigating from {} to {}", - *aExtantDocument->GetDocumentURI(), *aLoadState->URI()); - aLoadState->SetLoadType(MaybeAddLoadFlags( - aLoadState->LoadType(), nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY)); - } -} - // InternalLoad performs several of the steps from // https://html.spec.whatwg.org/#navigate. nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState, @@ -9559,11 +9525,6 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState, IsSameDocumentNavigation(aLoadState, sameDocumentNavigationState) && !aLoadState->GetPendingRedirectedChannel(); - if (mLoadType != LOAD_ERROR_PAGE) { - MaybeConvertToReplaceLoad(aLoadState, GetExtantDocument(), - sameDocumentNavigationState.mIdentical); - } - // Note: We do this check both here and in BrowsingContext:: // LoadURI/InternalLoad, since document-specific sandbox flags are only // available in the process triggering the load, and we don't want the target diff --git a/docshell/base/nsDocShellLoadState.cpp b/docshell/base/nsDocShellLoadState.cpp @@ -71,9 +71,6 @@ nsDocShellLoadState::nsDocShellLoadState( mOriginalFrameSrc = aLoadState.OriginalFrameSrc(); mShouldCheckForRecursion = aLoadState.ShouldCheckForRecursion(); mIsFormSubmission = aLoadState.IsFormSubmission(); - mShouldNotForceReplaceInOnLoad = aLoadState.ShouldNotForceReplaceInOnLoad(); - mNeedsCompletelyLoadedDocument = aLoadState.NeedsCompletelyLoadedDocument(); - mHistoryBehavior = aLoadState.HistoryBehavior(); mLoadType = aLoadState.LoadType(); mTarget = aLoadState.Target(); mTargetBrowsingContext = aLoadState.TargetBrowsingContext(); @@ -175,6 +172,7 @@ nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther) mInheritPrincipal(aOther.mInheritPrincipal), mPrincipalIsExplicit(aOther.mPrincipalIsExplicit), mNotifiedBeforeUnloadListeners(aOther.mNotifiedBeforeUnloadListeners), + mShouldNotForceReplaceInOnLoad(aOther.mShouldNotForceReplaceInOnLoad), mPrincipalToInherit(aOther.mPrincipalToInherit), mPartitionedPrincipalToInherit(aOther.mPartitionedPrincipalToInherit), mForceAllowDataURI(aOther.mForceAllowDataURI), @@ -183,9 +181,6 @@ nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther) mOriginalFrameSrc(aOther.mOriginalFrameSrc), mShouldCheckForRecursion(aOther.mShouldCheckForRecursion), mIsFormSubmission(aOther.mIsFormSubmission), - mShouldNotForceReplaceInOnLoad(aOther.mShouldNotForceReplaceInOnLoad), - mNeedsCompletelyLoadedDocument(aOther.mNeedsCompletelyLoadedDocument), - mHistoryBehavior(aOther.mHistoryBehavior), mLoadType(aOther.mLoadType), mSHEntry(aOther.mSHEntry), mTarget(aOther.mTarget), @@ -240,14 +235,12 @@ nsDocShellLoadState::nsDocShellLoadState(nsIURI* aURI, uint64_t aLoadIdentifier) mInheritPrincipal(false), mPrincipalIsExplicit(false), mNotifiedBeforeUnloadListeners(false), + mShouldNotForceReplaceInOnLoad(false), mForceAllowDataURI(false), mIsExemptFromHTTPSFirstMode(false), mOriginalFrameSrc(false), mShouldCheckForRecursion(false), mIsFormSubmission(false), - mShouldNotForceReplaceInOnLoad(false), - mNeedsCompletelyLoadedDocument(false), - mHistoryBehavior(Nothing()), mLoadType(LOAD_NORMAL), mSrcdocData(VoidString()), mLoadFlags(0), @@ -677,6 +670,15 @@ void nsDocShellLoadState::SetNotifiedBeforeUnloadListeners( mNotifiedBeforeUnloadListeners = aNotifiedBeforeUnloadListeners; } +bool nsDocShellLoadState::ShouldNotForceReplaceInOnLoad() const { + return mShouldNotForceReplaceInOnLoad; +} + +void nsDocShellLoadState::SetShouldNotForceReplaceInOnLoad( + bool aShouldNotForceReplaceInOnLoad) { + mShouldNotForceReplaceInOnLoad = aShouldNotForceReplaceInOnLoad; +} + bool nsDocShellLoadState::ForceAllowDataURI() const { return mForceAllowDataURI; } @@ -725,34 +727,6 @@ void nsDocShellLoadState::SetIsFormSubmission(bool aIsFormSubmission) { mIsFormSubmission = aIsFormSubmission; } -bool nsDocShellLoadState::ShouldNotForceReplaceInOnLoad() const { - return mShouldNotForceReplaceInOnLoad; -} - -void nsDocShellLoadState::SetShouldNotForceReplaceInOnLoad( - bool aShouldNotForceReplaceInOnLoad) { - mShouldNotForceReplaceInOnLoad = aShouldNotForceReplaceInOnLoad; -} - -bool nsDocShellLoadState::NeedsCompletelyLoadedDocument() const { - return mNeedsCompletelyLoadedDocument; -} - -void nsDocShellLoadState::SetNeedsCompletelyLoadedDocument( - bool aNeedsCompletelyLoadedDocument) { - mNeedsCompletelyLoadedDocument = aNeedsCompletelyLoadedDocument; -} - -Maybe<mozilla::dom::NavigationHistoryBehavior> -nsDocShellLoadState::HistoryBehavior() const { - return mHistoryBehavior; -} - -void nsDocShellLoadState::SetHistoryBehavior( - mozilla::dom::NavigationHistoryBehavior aHistoryBehavior) { - mHistoryBehavior = Some(aHistoryBehavior); -} - uint32_t nsDocShellLoadState::LoadType() const { return mLoadType; } void nsDocShellLoadState::SetLoadType(uint32_t aLoadType) { @@ -1403,9 +1377,6 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize( loadState.OriginalFrameSrc() = mOriginalFrameSrc; loadState.ShouldCheckForRecursion() = mShouldCheckForRecursion; loadState.IsFormSubmission() = mIsFormSubmission; - loadState.ShouldNotForceReplaceInOnLoad() = mShouldNotForceReplaceInOnLoad; - loadState.NeedsCompletelyLoadedDocument() = mNeedsCompletelyLoadedDocument; - loadState.HistoryBehavior() = mHistoryBehavior; loadState.LoadType() = mLoadType; loadState.userNavigationInvolvement() = mUserNavigationInvolvement; loadState.Target() = mTarget; diff --git a/docshell/base/nsDocShellLoadState.h b/docshell/base/nsDocShellLoadState.h @@ -178,16 +178,6 @@ class nsDocShellLoadState final { void SetIsFormSubmission(bool aIsFormSubmission); - bool NeedsCompletelyLoadedDocument() const; - - void SetNeedsCompletelyLoadedDocument(bool aNeedsCompletelyLoadedDocument); - - mozilla::Maybe<mozilla::dom::NavigationHistoryBehavior> HistoryBehavior() - const; - - void SetHistoryBehavior( - mozilla::dom::NavigationHistoryBehavior aHistoryBehavior); - uint32_t LoadType() const; void SetLoadType(uint32_t aLoadType); @@ -552,6 +542,10 @@ class nsDocShellLoadState final { // notified if applicable. bool mNotifiedBeforeUnloadListeners; + // If this attribute is true, navigations for subframes taking place inside of + // an onload handler will not be changed to replace loads. + bool mShouldNotForceReplaceInOnLoad; + // Principal we're inheriting. If null, this means the principal should be // inherited from the current document. If set to NullPrincipal, the channel // will fill in principal information later in the load. See internal comments @@ -591,18 +585,6 @@ class nsDocShellLoadState final { // form submission. bool mIsFormSubmission; - // If this attribute is true, navigations for subframes taking place inside of - // an onload handler will not be changed to replace loads. - bool mShouldNotForceReplaceInOnLoad; - - // If this attribute is true, we need to check if the current document is - // completely loaded to determine if we should perform a push or replace load. - bool mNeedsCompletelyLoadedDocument; - - // If this attribute is `Auto`, we should determine if this should be a push - // or replace load when actually loading. - mozilla::Maybe<mozilla::dom::NavigationHistoryBehavior> mHistoryBehavior; - // Contains a load type as specified by the nsDocShellLoadTypes::load* // constants uint32_t mLoadType; diff --git a/docshell/base/nsDocShellLoadTypes.h b/docshell/base/nsDocShellLoadTypes.h @@ -21,7 +21,6 @@ # define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16)) # define LOAD_TYPE_HAS_FLAGS(type, flags) ((type) & ((flags) << 16)) -# define LOAD_TYPE_SET_FLAGS(type, flags) ((type) | ((flags) << 16)) /** * These are flags that confuse ConvertLoadTypeToDocShellLoadInfo and should @@ -202,17 +201,5 @@ inline nsDOMNavigationTiming::Type ConvertLoadTypeToNavigationType( return result; } -static inline uint32_t MaybeAddLoadFlags(uint32_t aLoadType, uint32_t aFlags) { - uint32_t loadType = LOAD_TYPE_SET_FLAGS(aLoadType, aFlags); - if (IsValidLoadType(loadType)) { - return loadType; - } - - NS_WARNING("Adjusting load flags results in an invalid load type."); - return aLoadType; -} - -# undef LOAD_TYPE_SET_FLAGS - #endif // MOZILLA_INTERNAL_API #endif diff --git a/docshell/test/chrome/bug311007_window.xhtml b/docshell/test/chrome/bug311007_window.xhtml @@ -114,13 +114,6 @@ function step2A() { } function step2B(aWebProgress, aRequest, aLocation, aFlags) { - content.addEventListener( - 'load', - () => step2C(aWebProgress, aRequest, aLocation, aFlags), - {once: true}); -} - -function step2C(aWebProgress, aRequest, aLocation, aFlags) { is(aLocation.spec, kSecureURI, "A URI on HTTPS (2)"); ok(!(aFlags & Ci.nsIWebProgressListener diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp @@ -1391,7 +1391,6 @@ Document::Document(const char* aContentType) mHaveFiredTitleChange(false), mIsShowing(false), mVisible(true), - mIsCompletelyLoaded(false), mRemovedFromDocShell(false), // mAllowDNSPrefetch starts true, so that we can always reliably && it // with various values that might disable it. Since we never prefetch @@ -12573,8 +12572,6 @@ void Document::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget, if (auto* wgc = GetWindowGlobalChild()) { wgc->UnblockBFCacheFor(BFCacheStatus::PAGE_LOADING); } - - mIsCompletelyLoaded = true; } static void DispatchFullscreenChange(Document& aDocument, nsINode* aTarget) { diff --git a/dom/base/Document.h b/dom/base/Document.h @@ -2676,20 +2676,12 @@ class Document : public nsINode, * called yet. */ bool IsShowing() const { return mIsShowing; } - /** * Return whether the document is currently visible (in the sense of * OnPageHide having been called and OnPageShow not yet having been called) */ bool IsVisible() const { return mVisible; } - /** - * Return whether the document has completely finished loading, in the spec - * sense. We only store a bool though, whereas spec stores when loading - * finished. See https://html.spec.whatwg.org/#completely-loaded-time - */ - bool IsCompletelyLoaded() const { return mIsCompletelyLoaded; } - void SetSuppressedEventListener(EventListener* aListener); EventListener* GetSuppressedEventListener() { @@ -4846,10 +4838,6 @@ class Document : public nsINode, // it's false only when we're in bfcache or unloaded. bool mVisible : 1; - // State for IsCompletelyLoaded. Starts off false and becomes true after - // pageshow has fired. Doesn't reset after that. - bool mIsCompletelyLoaded : 1; - // True if our content viewer has been removed from the docshell // (it may still be displayed, but in zombie state). Form control data // has been saved. diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp @@ -173,7 +173,7 @@ void Location::SetHash(const nsACString& aHash, nsIPrincipal& aSubjectPrincipal, return; } - Navigate(uri, aSubjectPrincipal, aRv); + SetURI(uri, aSubjectPrincipal, aRv); } void Location::GetHost(nsACString& aHost, nsIPrincipal& aSubjectPrincipal, @@ -211,7 +211,7 @@ void Location::SetHost(const nsACString& aHost, nsIPrincipal& aSubjectPrincipal, return; } - Navigate(uri, aSubjectPrincipal, aRv); + SetURI(uri, aSubjectPrincipal, aRv); } void Location::GetHostname(nsACString& aHostname, @@ -248,7 +248,7 @@ void Location::SetHostname(const nsACString& aHostname, return; } - Navigate(uri, aSubjectPrincipal, aRv); + SetURI(uri, aSubjectPrincipal, aRv); } nsresult Location::GetHref(nsACString& aHref) { @@ -328,7 +328,7 @@ void Location::SetPathname(const nsACString& aPathname, return; } - Navigate(uri, aSubjectPrincipal, aRv); + SetURI(uri, aSubjectPrincipal, aRv); } void Location::GetPort(nsACString& aPort, nsIPrincipal& aSubjectPrincipal, @@ -387,7 +387,7 @@ void Location::SetPort(const nsACString& aPort, nsIPrincipal& aSubjectPrincipal, return; } - Navigate(uri, aSubjectPrincipal, aRv); + SetURI(uri, aSubjectPrincipal, aRv); } void Location::GetProtocol(nsACString& aProtocol, @@ -462,7 +462,7 @@ void Location::SetProtocol(const nsACString& aProtocol, return; } - Navigate(uri, aSubjectPrincipal, aRv); + SetURI(uri, aSubjectPrincipal, aRv); } void Location::GetSearch(nsACString& aSearch, nsIPrincipal& aSubjectPrincipal, @@ -513,7 +513,7 @@ void Location::SetSearch(const nsACString& aSearch, return; } - Navigate(uri, aSubjectPrincipal, aRv); + SetURI(uri, aSubjectPrincipal, aRv); } void Location::Reload(JSContext* aCx, bool aForceget, diff --git a/dom/base/LocationBase.cpp b/dom/base/LocationBase.cpp @@ -12,7 +12,6 @@ #include "mozilla/dom/WindowContext.h" #include "nsCOMPtr.h" #include "nsContentUtils.h" -#include "nsDocLoader.h" #include "nsDocShellLoadState.h" #include "nsError.h" #include "nsGlobalWindowInner.h" @@ -24,28 +23,16 @@ namespace mozilla::dom { -static bool IncumbentGlobalHasTransientActivation() { - nsGlobalWindowInner* window = nsContentUtils::IncumbentInnerWindow(); - return window && window->GetWindowContext() && window->GetWindowContext() && - window->GetWindowContext()->HasValidTransientUserGestureActivation(); -} - -// https://html.spec.whatwg.org/#location-object-navigate -void LocationBase::Navigate(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, - ErrorResult& aRv, - NavigationHistoryBehavior aHistoryHandling) { - // Step 1 - RefPtr<BrowsingContext> navigable = GetBrowsingContext(); - if (!navigable || navigable->IsDiscarded()) { +void LocationBase::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, + ErrorResult& aRv, bool aReplace) { + RefPtr<BrowsingContext> bc = GetBrowsingContext(); + if (!bc || bc->IsDiscarded()) { return; } - // Step 2-3, except the check for if document is completely loaded. - bool needsCompletelyLoadedDocument = !IncumbentGlobalHasTransientActivation(); - - // Step 4 - navigable->Navigate(aURI, aSubjectPrincipal, aRv, aHistoryHandling, - needsCompletelyLoadedDocument); + bc->Navigate(aURI, aSubjectPrincipal, aRv, + aReplace ? NavigationHistoryBehavior::Replace + : NavigationHistoryBehavior::Auto); } void LocationBase::SetHref(const nsACString& aHref, @@ -107,12 +94,7 @@ void LocationBase::SetHrefWithBase(const nsACString& aHref, nsIURI* aBase, } } - NavigationHistoryBehavior historyHandling = NavigationHistoryBehavior::Auto; - if (aReplace || inScriptTag) { - historyHandling = NavigationHistoryBehavior::Replace; - } - - Navigate(newUri, aSubjectPrincipal, aRv, historyHandling); + SetURI(newUri, aSubjectPrincipal, aRv, aReplace || inScriptTag); } void LocationBase::Replace(const nsACString& aUrl, diff --git a/dom/base/LocationBase.h b/dom/base/LocationBase.h @@ -7,7 +7,6 @@ #ifndef mozilla_dom_LocationBase_h #define mozilla_dom_LocationBase_h -#include "mozilla/dom/NavigationBinding.h" #include "nsStringFwd.h" class nsIDocShell; @@ -38,9 +37,8 @@ class LocationBase { virtual BrowsingContext* GetBrowsingContext() = 0; virtual nsIDocShell* GetDocShell() = 0; - void Navigate(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv, - NavigationHistoryBehavior aHistoryHandling = - NavigationHistoryBehavior::Auto); + void SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv, + bool aReplace = false); void SetHrefWithBase(const nsACString& aHref, nsIURI* aBase, nsIPrincipal& aSubjectPrincipal, bool aReplace, ErrorResult& aRv); diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp @@ -6770,7 +6770,7 @@ nsresult nsGlobalWindowOuter::OpenInternal( // BrowsingContext::RevisePopupAbuseLevel() below. RefPtr<nsDocShellLoadState> loadState = aLoadState; if (!loadState && aNavigate && uri) { - loadState = nsWindowWatcher::CreateLoadState(uri, this, aDoJSFixups); + loadState = nsWindowWatcher::CreateLoadState(uri, this); } PopupBlocker::PopupControlState abuseLevel = diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh @@ -64,7 +64,6 @@ using mozilla::dom::NotificationDirection from "mozilla/dom/NotificationBinding. using mozilla::dom::UserNavigationInvolvement from "mozilla/dom/UserNavigationInvolvement.h"; using mozilla::net::ClassificationFlags from "nsIClassifiedChannel.h"; using mozilla::dom::ForceMediaDocument from "mozilla/dom/LoadURIOptionsBinding.h"; -using mozilla::dom::NavigationHistoryBehavior from "mozilla/dom/NavigationBinding.h"; namespace mozilla { namespace dom { @@ -227,10 +226,6 @@ struct DocShellLoadStateInit bool TextDirectiveUserActivation; bool AllowFocusMove; bool IsFromProcessingFrameAttributes; - bool NeedsCompletelyLoadedDocument; - bool ShouldNotForceReplaceInOnLoad; - NavigationHistoryBehavior? HistoryBehavior; - SchemelessInputType SchemelessInput; ForceMediaDocument forceMediaDocument; HTTPSUpgradeTelemetryType HttpsUpgradeTelemetry; diff --git a/dom/ipc/NavigationAPIIPCUtils.h b/dom/ipc/NavigationAPIIPCUtils.h @@ -23,10 +23,5 @@ template <> struct ParamTraits<mozilla::dom::NavigationType> : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::NavigationType> { }; - -template <> -struct ParamTraits<mozilla::dom::NavigationHistoryBehavior> - : public mozilla::dom::WebIDLEnumSerializer< - mozilla::dom::NavigationHistoryBehavior> {}; } // namespace IPC #endif diff --git a/dom/navigation/Navigation.cpp b/dom/navigation/Navigation.cpp @@ -564,7 +564,7 @@ void Navigation::Navigate(JSContext* aCx, const nsAString& aUrl, MOZ_DIAGNOSTIC_ASSERT(bc); bc->Navigate(urlRecord, *document->NodePrincipal(), /* per spec, error handling defaults to false */ IgnoreErrors(), - aOptions.mHistory); + aOptions.mHistory, /* aShouldNotForceReplaceInOnLoad */ true); // 13. If this's upcoming non-traverse API method tracker is apiMethodTracker, // then: diff --git a/dom/security/test/sec-fetch/file_no_cache.sjs b/dom/security/test/sec-fetch/file_no_cache.sjs @@ -2,7 +2,7 @@ const MESSAGE_PAGE = function (msg) { return ` <html> <script type="text/javascript"> -onload = () => window.parent.postMessage({test : "${msg}"},"*"); +window.parent.postMessage({test : "${msg}"},"*"); </script> <script> addEventListener("back", () => { diff --git a/dom/security/test/sec-fetch/test_iframe_history_manipulation.html b/dom/security/test/sec-fetch/test_iframe_history_manipulation.html @@ -78,7 +78,7 @@ SimpleTest.waitForExplicitFinish(); testFrame = document.createElement('iframe'); testFrame.src = `https://example.org/${REQUEST_PATH}?test`; -onload = () => setTimeout(() => document.body.appendChild(testFrame), 0); +document.body.appendChild(testFrame); </script> </body> diff --git a/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-assign-user-click.html.ini b/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-assign-user-click.html.ini @@ -2,5 +2,4 @@ expected: if (processor == "x86") and (os == "linux"): [OK, ERROR] [NO replace before load, triggered by location.assign()] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL diff --git a/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click.html.ini b/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click.html.ini @@ -2,13 +2,10 @@ expected: if (processor == "x86") and (os == "linux"): [OK, CRASH] [href] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL [search] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL [hash] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL diff --git a/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup.html.ini b/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup.html.ini @@ -2,13 +2,10 @@ expected: if (os == "android") and fission: [OK, TIMEOUT] [href] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL [search] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL [hash] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL diff --git a/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/window-open-self-during-load.html.ini b/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/window-open-self-during-load.html.ini @@ -2,5 +2,4 @@ expected: if (os == "android") and fission: [OK, TIMEOUT] [No replace during load, triggered by window.open(_self) on an iframe] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL diff --git a/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/window-open-self-during-pageshow.html.ini b/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/window-open-self-during-pageshow.html.ini @@ -2,5 +2,4 @@ expected: if (os == "android") and fission: [OK, TIMEOUT] [No replace during pageshow, triggered by window.open(_self) on an iframe] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL diff --git a/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/window-open-self.html.ini b/testing/web-platform/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/window-open-self.html.ini @@ -2,5 +2,4 @@ expected: if (os == "android") and fission: [OK, TIMEOUT] [No replace before load, triggered by window.open(_self) on an iframe] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL diff --git a/testing/web-platform/meta/html/browsers/history/the-history-interface/traverse-during-beforeunload.html.ini b/testing/web-platform/meta/html/browsers/history/the-history-interface/traverse-during-beforeunload.html.ini @@ -1,4 +1,4 @@ [traverse-during-beforeunload.html] [Traversing the history during beforeunload] - expected: - if (os == "android") and not sessionHistoryInParent: FAIL + expected: FAIL + diff --git a/testing/web-platform/meta/navigation-api/currententrychange-event/location-api.html.ini b/testing/web-platform/meta/navigation-api/currententrychange-event/location-api.html.ini @@ -0,0 +1,3 @@ +[location-api.html] + [currententrychange fires for location API navigations] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin-sameorigindomain.sub.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin-sameorigindomain.sub.html.ini @@ -0,0 +1,3 @@ +[location-crossdocument-crossorigin-sameorigindomain.sub.html] + [using location.href to navigate cross-document targeting a same-origin-domain (but cross-origin) window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-crossdocument-sameorigin.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-crossdocument-sameorigin.html.ini @@ -0,0 +1,3 @@ +[location-crossdocument-sameorigin.html] + [using location.href to navigate cross-document targeting a same-origin window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub.html.ini @@ -0,0 +1,12 @@ +[location-samedocument-crossorigin-sameorigindomain.sub.html] + expected: + if (os == "win") and debug and (processor == "x86_64"): [OK, CRASH, FAIL, ERROR] + if (os == "win") and debug and (processor == "x86"): [OK, FAIL, ERROR, CRASH] + if (os == "linux") and asan and fission: [CRASH, OK, FAIL] + if (os == "linux") and asan and not fission: [OK, CRASH, FAIL] + if (os == "linux") and not asan and (processor == "x86"): [OK, CRASH, FAIL] + if (os == "mac") and not debug: [OK, ERROR, FAIL, CRASH] + if (os == "android") and debug: [CRASH, OK, FAIL] + [OK, FAIL, CRASH] + [using location.href to navigate same-document targeting a same-origin-domain (but cross-origin) window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin.html.ini @@ -0,0 +1,3 @@ +[location-samedocument-crossorigin.html] + [using location.href to navigate same-document targeting a cross-origin window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin.html.ini @@ -0,0 +1,3 @@ +[location-samedocument-sameorigin.html] + [using location.href to navigate same-document targeting a same-origin window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin-sameorigindomain.sub.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin-sameorigindomain.sub.html.ini @@ -0,0 +1,3 @@ +[open-crossdocument-crossorigin-sameorigindomain.sub.html] + [using window.open() to navigate cross-document targeting a same-origin-domain (but cross-origin) window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-crossdocument-sameorigin.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-crossdocument-sameorigin.html.ini @@ -0,0 +1,3 @@ +[open-crossdocument-sameorigin.html] + [using window.open() to navigate cross-document targeting a same-origin window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub.html.ini @@ -0,0 +1,3 @@ +[open-samedocument-crossorigin-sameorigindomain.sub.html] + [using window.open() to navigate same-document targeting a same-origin-domain (but cross-origin) window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin.html.ini @@ -0,0 +1,3 @@ +[open-samedocument-crossorigin.html] + [using window.open() to navigate same-document targeting a cross-origin window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin.html.ini @@ -0,0 +1,3 @@ +[open-samedocument-sameorigin.html] + [using window.open() to navigate same-document targeting a same-origin window] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/navigate-iframe-location.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/navigate-iframe-location.html.ini @@ -0,0 +1,3 @@ +[navigate-iframe-location.html] + [location API on another window fires navigate event in the target window only] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/navigate-navigation-navigate.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/navigate-navigation-navigate.html.ini @@ -0,0 +1,3 @@ +[navigate-navigation-navigate.html] + [navigate event for navigation.navigate()] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigate-event/navigate-window-open.html.ini b/testing/web-platform/meta/navigation-api/navigate-event/navigate-window-open.html.ini @@ -0,0 +1,5 @@ +[navigate-window-open.html] + expected: + if os == "mac": [OK, ERROR, CRASH] + [window.open() fires navigate event in target window but not source] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigation-history-entry/current-basic.html.ini b/testing/web-platform/meta/navigation-api/navigation-history-entry/current-basic.html.ini @@ -0,0 +1,3 @@ +[current-basic.html] + [Basic tests for navigation.currentEntry] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/navigation-methods/sandboxing-back-parent.html.ini b/testing/web-platform/meta/navigation-api/navigation-methods/sandboxing-back-parent.html.ini @@ -1,6 +1,3 @@ [sandboxing-back-parent.html] - expected: - OK [A sandboxed iframe cannot navigate its parent via its own navigation object by using back()] - expected: - FAIL + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/state/cross-document-getState-undefined.html.ini b/testing/web-platform/meta/navigation-api/state/cross-document-getState-undefined.html.ini @@ -0,0 +1,3 @@ +[cross-document-getState-undefined.html] + [Default behavior for entry.getState() for a non-current cross-document entry] + expected: FAIL diff --git a/testing/web-platform/meta/navigation-api/state/cross-document-location-api.html.ini b/testing/web-platform/meta/navigation-api/state/cross-document-location-api.html.ini @@ -0,0 +1,15 @@ +[cross-document-location-api.html?method=navigate] + expected: + if (os == "linux") and not tsan and (processor == "x86_64") and debug and not fission: [CRASH, OK] + if (os == "win") and not debug and (processor == "x86"): [CRASH, OK] + if (os == "mac") and not debug: [ERROR, CRASH, OK] + if (os == "linux") and tsan: [CRASH, OK] + if (os == "android") and not debug: [CRASH, OK] + [OK, CRASH] + [entry.getState() behavior after cross-document location API navigation] + expected: FAIL + + +[cross-document-location-api.html?method=updateCurrentEntry] + [entry.getState() behavior after cross-document location API navigation] + expected: FAIL diff --git a/testing/web-platform/tests/css/cssom-view/scroll-behavior-smooth-navigation.html b/testing/web-platform/tests/css/cssom-view/scroll-behavior-smooth-navigation.html @@ -70,6 +70,7 @@ }); location.hash = "foo"; }; + instant(); function smooth() { document.documentElement.className = ""; @@ -109,9 +110,4 @@ }; testContainer.style.display = "none"; - - // Setting location.hash while loading results in a replace load, which we don't want. - window.onload = () => { - step_timeout(instant, 0); - } </script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/open-close/self-close.html b/testing/web-platform/tests/html/browsers/the-window-object/open-close/self-close.html @@ -2,7 +2,7 @@ <p>self-close.html?navs=n&channel=name will navigate n times, then close and notify the channel.</p> <script> -window.onload = () => setTimeout(() => { +window.onload = setTimeout(() => { const urlParams = new URLSearchParams(window.location.search); let n = parseInt(urlParams.get('navs')) || 0; diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigate-navigation-navigate.html b/testing/web-platform/tests/navigation-api/navigate-event/navigate-navigation-navigate.html @@ -4,7 +4,7 @@ <script> async_test(t => { navigation.onnavigate = t.step_func_done(e => { - assert_equals(e.navigationType, "push"); + assert_equals(e.navigationType, "replace"); assert_true(e.cancelable); assert_true(e.canIntercept); assert_false(e.userInitiated); diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.cpp b/toolkit/components/windowwatcher/nsWindowWatcher.cpp @@ -2064,7 +2064,7 @@ bool nsWindowWatcher::HaveSpecifiedSize(const WindowFeatures& features) { /* static */ already_AddRefed<nsDocShellLoadState> nsWindowWatcher::CreateLoadState( - nsIURI* aUri, nsPIDOMWindowOuter* aParent, bool aIsWindowOpen) { + nsIURI* aUri, nsPIDOMWindowOuter* aParent) { MOZ_ASSERT(aUri); RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(aUri); @@ -2094,13 +2094,6 @@ already_AddRefed<nsDocShellLoadState> nsWindowWatcher::CreateLoadState( } } - // If we're called from JS, i.e window.open, we need to set history handling - // behavior here to be able to do push to replace conversion if needed. - if (aIsWindowOpen && mozilla::SessionHistoryInParent()) { - loadState->SetHistoryBehavior(NavigationHistoryBehavior::Auto); - loadState->SetShouldNotForceReplaceInOnLoad(true); - } - return loadState.forget(); } diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.h b/toolkit/components/windowwatcher/nsWindowWatcher.h @@ -71,7 +71,6 @@ class nsWindowWatcher : public nsIWindowWatcher, * - the user gesture activation flag based on the parent document * - the text directive user activation flag; this will consume the parent * document's flag and OR's it with the user gesture activation flag. - * If `aIsWindowOpen` is true, history handling will be set to "auto". * * Currently, the returned load state is intended to be passed into * `OpenWindowInternal()`. @@ -79,7 +78,7 @@ class nsWindowWatcher : public nsIWindowWatcher, * function. */ static already_AddRefed<nsDocShellLoadState> CreateLoadState( - nsIURI* aUri, nsPIDOMWindowOuter* aParent, bool aIsWindowOpen = false); + nsIURI* aUri, nsPIDOMWindowOuter* aParent); protected: virtual ~nsWindowWatcher();