Bug 1964951 - Implement #inform-the-navigation-api-about-aborting-navigation. r=jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D248259
This commit is contained in:
committed by
afarre@mozilla.com
parent
60cc0878d3
commit
ff18eb8060
@@ -13964,3 +13964,36 @@ bool nsDocShell::IsSameDocumentAsActiveEntry(
|
|||||||
const mozilla::dom::SessionHistoryInfo& aSHInfo) {
|
const mozilla::dom::SessionHistoryInfo& aSHInfo) {
|
||||||
return mActiveEntry ? mActiveEntry->SharesDocumentWith(aSHInfo) : false;
|
return mActiveEntry ? mActiveEntry->SharesDocumentWith(aSHInfo) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/#nav-window
|
||||||
|
nsPIDOMWindowInner* nsDocShell::GetActiveWindow() {
|
||||||
|
nsPIDOMWindowOuter* outer = GetWindow();
|
||||||
|
return outer ? outer->GetCurrentInnerWindow() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/#inform-the-navigation-api-about-aborting-navigation
|
||||||
|
void nsDocShell::InformNavigationAPIAboutAbortingNavigation(JSContext* aCx) {
|
||||||
|
// Step 1
|
||||||
|
// This becomes an assert since we have a common event loop.
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
// No ongoing navigations if we don't have a window.
|
||||||
|
RefPtr<nsPIDOMWindowInner> window = GetActiveWindow();
|
||||||
|
if (!window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2
|
||||||
|
RefPtr<Navigation> navigation = window->Navigation();
|
||||||
|
if (!navigation) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 3
|
||||||
|
if (!navigation->HasOngoingNavigateEvent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 4
|
||||||
|
navigation->AbortOngoingNavigation(aCx);
|
||||||
|
}
|
||||||
|
|||||||
@@ -388,6 +388,8 @@ class nsDocShell final : public nsDocLoader,
|
|||||||
return mozilla::dom::WindowProxyHolder(mBrowsingContext);
|
return mozilla::dom::WindowProxyHolder(mBrowsingContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsPIDOMWindowInner* GetActiveWindow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the given URI. See comments on nsDocShellLoadState members for more
|
* Loads the given URI. See comments on nsDocShellLoadState members for more
|
||||||
* information on information used.
|
* information on information used.
|
||||||
@@ -1140,6 +1142,9 @@ class nsDocShell final : public nsDocLoader,
|
|||||||
mozilla::dom::UserNavigationInvolvement::None);
|
mozilla::dom::UserNavigationInvolvement::None);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
|
void InformNavigationAPIAboutAbortingNavigation(JSContext* aCx);
|
||||||
|
|
||||||
void SetCurrentURIInternal(nsIURI* aURI);
|
void SetCurrentURIInternal(nsIURI* aURI);
|
||||||
|
|
||||||
// data members
|
// data members
|
||||||
|
|||||||
@@ -1097,6 +1097,10 @@ void Navigation::SetFocusedChangedDuringOngoingNavigation(
|
|||||||
mFocusChangedDuringOngoingNavigation = aFocusChangedDUringOngoingNavigation;
|
mFocusChangedDuringOngoingNavigation = aFocusChangedDUringOngoingNavigation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Navigation::HasOngoingNavigateEvent() const {
|
||||||
|
return mOngoingNavigateEvent;
|
||||||
|
}
|
||||||
|
|
||||||
// The associated document of navigation's relevant global object.
|
// The associated document of navigation's relevant global object.
|
||||||
Document* Navigation::GetAssociatedDocument() const {
|
Document* Navigation::GetAssociatedDocument() const {
|
||||||
nsGlobalWindowInner* window = GetOwnerWindow();
|
nsGlobalWindowInner* window = GetOwnerWindow();
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ class Navigation final : public DOMEventTargetHelper {
|
|||||||
void SetFocusedChangedDuringOngoingNavigation(
|
void SetFocusedChangedDuringOngoingNavigation(
|
||||||
bool aFocusChangedDuringOngoingNavigation);
|
bool aFocusChangedDuringOngoingNavigation);
|
||||||
|
|
||||||
|
bool HasOngoingNavigateEvent() const;
|
||||||
|
|
||||||
|
void AbortOngoingNavigation(
|
||||||
|
JSContext* aCx, JS::Handle<JS::Value> aError = JS::UndefinedHandleValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using UpcomingTraverseAPIMethodTrackers =
|
using UpcomingTraverseAPIMethodTrackers =
|
||||||
nsTHashMap<nsIDHashKey, RefPtr<NavigationAPIMethodTracker>>;
|
nsTHashMap<nsIDHashKey, RefPtr<NavigationAPIMethodTracker>>;
|
||||||
@@ -183,9 +188,6 @@ class Navigation final : public DOMEventTargetHelper {
|
|||||||
|
|
||||||
static void CleanUp(NavigationAPIMethodTracker* aNavigationAPIMethodTracker);
|
static void CleanUp(NavigationAPIMethodTracker* aNavigationAPIMethodTracker);
|
||||||
|
|
||||||
void AbortOngoingNavigation(
|
|
||||||
JSContext* aCx, JS::Handle<JS::Value> aError = JS::UndefinedHandleValue);
|
|
||||||
|
|
||||||
Document* GetAssociatedDocument() const;
|
Document* GetAssociatedDocument() const;
|
||||||
|
|
||||||
void LogHistory() const;
|
void LogHistory() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user