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:
@@ -2084,7 +2084,13 @@ bool CanonicalBrowsingContext::StartDocumentLoad(
|
|||||||
// that we need to cancel any existing ones.
|
// that we need to cancel any existing ones.
|
||||||
if (StaticPrefs::browser_tabs_documentchannel_parent_controlled() &&
|
if (StaticPrefs::browser_tabs_documentchannel_parent_controlled() &&
|
||||||
mozilla::SessionHistoryInParent() && mCurrentLoad) {
|
mozilla::SessionHistoryInParent() && mCurrentLoad) {
|
||||||
mCurrentLoad->Cancel(NS_BINDING_CANCELLED_OLD_LOAD);
|
// 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;
|
mCurrentLoad = aLoad;
|
||||||
|
|
||||||
|
|||||||
@@ -532,6 +532,9 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
|
|||||||
loadingContext->GetOriginAttributes(attrs);
|
loadingContext->GetOriginAttributes(attrs);
|
||||||
|
|
||||||
mLoadIdentifier = aLoadState->GetLoadIdentifier();
|
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
|
// Check for infinite recursive object or iframe loads
|
||||||
if (aLoadState->OriginalFrameSrc() || !mIsDocumentLoad) {
|
if (aLoadState->OriginalFrameSrc() || !mIsDocumentLoad) {
|
||||||
|
|||||||
@@ -282,6 +282,8 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
|
|||||||
|
|
||||||
uint64_t GetLoadIdentifier() const { return mLoadIdentifier; }
|
uint64_t GetLoadIdentifier() const { return mLoadIdentifier; }
|
||||||
uint32_t GetLoadType() const { return mLoadStateLoadType; }
|
uint32_t GetLoadType() const { return mLoadStateLoadType; }
|
||||||
|
bool IsDownload() const { return mIsDownload; }
|
||||||
|
bool IsLoadingJSURI() const { return mIsLoadingJSURI; }
|
||||||
|
|
||||||
mozilla::dom::LoadingSessionHistoryInfo* GetLoadingSessionHistoryInfo() {
|
mozilla::dom::LoadingSessionHistoryInfo* GetLoadingSessionHistoryInfo() {
|
||||||
return mLoadingSessionHistoryInfo.get();
|
return mLoadingSessionHistoryInfo.get();
|
||||||
@@ -538,6 +540,12 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
|
|||||||
uint32_t mLoadStateInternalLoadFlags = 0;
|
uint32_t mLoadStateInternalLoadFlags = 0;
|
||||||
uint32_t mLoadStateLoadType = 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
|
// Corresponding redirect channel registrar Id for the final channel that
|
||||||
// we want to use when redirecting the child, or doing a process switch.
|
// we want to use when redirecting the child, or doing a process switch.
|
||||||
// 0 means redirection is not started.
|
// 0 means redirection is not started.
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ add_task(async function check_download_spam_permissions() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let download = await downloadFinishedPromise;
|
let download = await downloadFinishedPromise;
|
||||||
TestUtils.waitForCondition(
|
await TestUtils.waitForCondition(
|
||||||
() => gBrowser.tabs.length == INITIAL_TABS_COUNT + 1
|
() => gBrowser.tabs.length == INITIAL_TABS_COUNT + 1
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
@@ -109,7 +109,8 @@ add_task(async function check_download_spam_permissions() {
|
|||||||
"An other file should be blocked"
|
"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(blockedDownloadsCount, 99, "Browser should block 99 downloads");
|
||||||
is(
|
is(
|
||||||
blockedDownloadsURI,
|
blockedDownloadsURI,
|
||||||
|
|||||||
Reference in New Issue
Block a user