Bug 1721217 - Part 6: Don't cancel concurrent loads if they are downloads, r=nika,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D126846
This commit is contained in:
Anny Gakhokidze
2021-11-25 20:40:58 +00:00
parent a81e51b3a2
commit a80d859187
4 changed files with 21 additions and 3 deletions

View File

@@ -2084,8 +2084,14 @@ bool CanonicalBrowsingContext::StartDocumentLoad(
// that we need to cancel any existing ones.
if (StaticPrefs::browser_tabs_documentchannel_parent_controlled() &&
mozilla::SessionHistoryInParent() && mCurrentLoad) {
// Make sure we are not loading a javascript URI.
MOZ_ASSERT(!aLoad->IsLoadingJSURI());
// If we want to do a download, don't cancel the current navigation.
if (!aLoad->IsDownload()) {
mCurrentLoad->Cancel(NS_BINDING_CANCELLED_OLD_LOAD);
}
}
mCurrentLoad = aLoad;
if (NS_FAILED(SetCurrentLoadIdentifier(Some(aLoad->GetLoadIdentifier())))) {

View File

@@ -532,6 +532,9 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
loadingContext->GetOriginAttributes(attrs);
mLoadIdentifier = aLoadState->GetLoadIdentifier();
// See description of mFileName in nsDocShellLoadState.h
mIsDownload = !aLoadState->FileName().IsVoid();
mIsLoadingJSURI = net::SchemeIsJavascript(aLoadState->URI());
// Check for infinite recursive object or iframe loads
if (aLoadState->OriginalFrameSrc() || !mIsDocumentLoad) {

View File

@@ -282,6 +282,8 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
uint64_t GetLoadIdentifier() const { return mLoadIdentifier; }
uint32_t GetLoadType() const { return mLoadStateLoadType; }
bool IsDownload() const { return mIsDownload; }
bool IsLoadingJSURI() const { return mIsLoadingJSURI; }
mozilla::dom::LoadingSessionHistoryInfo* GetLoadingSessionHistoryInfo() {
return mLoadingSessionHistoryInfo.get();
@@ -538,6 +540,12 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
uint32_t mLoadStateInternalLoadFlags = 0;
uint32_t mLoadStateLoadType = 0;
// Indicates if this load is a download.
bool mIsDownload = false;
// Indicates if we are loading a javascript URI.
bool mIsLoadingJSURI = false;
// Corresponding redirect channel registrar Id for the final channel that
// we want to use when redirecting the child, or doing a process switch.
// 0 means redirection is not started.

View File

@@ -88,7 +88,7 @@ add_task(async function check_download_spam_permissions() {
});
let download = await downloadFinishedPromise;
TestUtils.waitForCondition(
await TestUtils.waitForCondition(
() => gBrowser.tabs.length == INITIAL_TABS_COUNT + 1
);
is(
@@ -109,7 +109,8 @@ add_task(async function check_download_spam_permissions() {
"An other file should be blocked"
);
TestUtils.waitForCondition(() => blockedDownloadsCount >= 99);
info("Will wait for blockedDownloadsCount to be >= 99");
await TestUtils.waitForCondition(() => blockedDownloadsCount >= 99);
is(blockedDownloadsCount, 99, "Browser should block 99 downloads");
is(
blockedDownloadsURI,