mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Backed out changeset 8e21fdfc60f0 (bug 1868001) for causing mochitest failures at dom/tests/mochitest/general/test_resource_timing_cross_origin.html CLOSED TREE
This commit is contained in:
parent
be27c149eb
commit
b1d213acb7
@ -10590,8 +10590,7 @@ static nsresult AppendSegmentToString(nsIInputStream* aIn, void* aClosure,
|
||||
}
|
||||
|
||||
/* static */ uint32_t nsDocShell::ComputeURILoaderFlags(
|
||||
BrowsingContext* aBrowsingContext, uint32_t aLoadType,
|
||||
bool aIsDocumentLoad) {
|
||||
BrowsingContext* aBrowsingContext, uint32_t aLoadType) {
|
||||
MOZ_ASSERT(aBrowsingContext);
|
||||
|
||||
uint32_t openFlags = 0;
|
||||
@ -10602,13 +10601,6 @@ static nsresult AppendSegmentToString(nsIInputStream* aIn, void* aClosure,
|
||||
openFlags |= nsIURILoader::DONT_RETARGET;
|
||||
}
|
||||
|
||||
// Unless the pref is set, object/embed loads always specify DONT_RETARGET.
|
||||
// See bug 1868001 for details.
|
||||
if (!aIsDocumentLoad &&
|
||||
!StaticPrefs::dom_navigation_object_embed_allow_retargeting()) {
|
||||
openFlags |= nsIURILoader::DONT_RETARGET;
|
||||
}
|
||||
|
||||
return openFlags;
|
||||
}
|
||||
|
||||
|
@ -489,8 +489,7 @@ class nsDocShell final : public nsDocLoader,
|
||||
bool HasDocumentViewer() const { return !!mDocumentViewer; }
|
||||
|
||||
static uint32_t ComputeURILoaderFlags(
|
||||
mozilla::dom::BrowsingContext* aBrowsingContext, uint32_t aLoadType,
|
||||
bool aIsDocumentLoad = true);
|
||||
mozilla::dom::BrowsingContext* aBrowsingContext, uint32_t aLoadType);
|
||||
|
||||
void SetLoadingSessionHistoryInfo(
|
||||
const mozilla::dom::LoadingSessionHistoryInfo& aLoadingInfo,
|
||||
|
@ -1249,11 +1249,7 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad,
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t uriLoaderFlags = nsDocShell::ComputeURILoaderFlags(
|
||||
docShell->GetBrowsingContext(), LOAD_NORMAL,
|
||||
/* aIsDocumentLoad */ false);
|
||||
|
||||
rv = uriLoader->OpenChannel(mChannel, uriLoaderFlags, req,
|
||||
rv = uriLoader->OpenChannel(mChannel, nsIURILoader::DONT_RETARGET, req,
|
||||
getter_AddRefs(finalListener));
|
||||
// finalListener will receive OnStartRequest either below, or if
|
||||
// `mChannel` is a `DocumentChannel`, it will be received after
|
||||
|
@ -109,16 +109,6 @@ skip-if = [
|
||||
]
|
||||
support-files = ["browser_multiple_popups.html"]
|
||||
|
||||
["browser_object_attachment.js"]
|
||||
support-files = [
|
||||
"file_img_object_attachment.html",
|
||||
"file_img_attachment.jpg",
|
||||
"file_img_attachment.jpg^headers^",
|
||||
"file_pdf_object_attachment.html",
|
||||
"file_pdf_attachment.pdf",
|
||||
"file_pdf_attachment.pdf^headers^",
|
||||
]
|
||||
|
||||
["browser_outline_refocus.js"]
|
||||
|
||||
["browser_page_load_event_telemetry.js"]
|
||||
|
@ -1,168 +0,0 @@
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
Downloads: "resource://gre/modules/Downloads.sys.mjs",
|
||||
});
|
||||
|
||||
const httpsTestRoot = getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
"https://example.com"
|
||||
);
|
||||
|
||||
add_task(async function test_pdf_object_attachment() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.navigation.object_embed.allow_retargeting", false]],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
`${httpsTestRoot}/file_pdf_object_attachment.html`,
|
||||
async browser => {
|
||||
is(
|
||||
browser.browsingContext.children.length,
|
||||
1,
|
||||
"Should have a child frame"
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let obj = content.document.querySelector("object");
|
||||
is(
|
||||
obj.displayedType,
|
||||
Ci.nsIObjectLoadingContent.TYPE_DOCUMENT,
|
||||
"should be displaying TYPE_DOCUMENT"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_img_object_attachment() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.navigation.object_embed.allow_retargeting", false]],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
`${httpsTestRoot}/file_img_object_attachment.html`,
|
||||
async browser => {
|
||||
is(
|
||||
browser.browsingContext.children.length,
|
||||
1,
|
||||
"Should have a child frame"
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let obj = content.document.querySelector("object");
|
||||
is(
|
||||
obj.displayedType,
|
||||
Ci.nsIObjectLoadingContent.TYPE_DOCUMENT,
|
||||
"should be displaying TYPE_DOCUMENT"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
async function waitForDownload() {
|
||||
// Get the downloads list and add a view to listen for a download to be added.
|
||||
let downloadList = await Downloads.getList(Downloads.ALL);
|
||||
|
||||
// Wait for a single download
|
||||
let downloadView;
|
||||
let finishedAllDownloads = new Promise(resolve => {
|
||||
downloadView = {
|
||||
onDownloadAdded(aDownload) {
|
||||
info("download added");
|
||||
resolve(aDownload);
|
||||
},
|
||||
};
|
||||
});
|
||||
await downloadList.addView(downloadView);
|
||||
let download = await finishedAllDownloads;
|
||||
await downloadList.removeView(downloadView);
|
||||
|
||||
// Clean up the download from the list.
|
||||
await downloadList.remove(download);
|
||||
await download.finalize(true);
|
||||
|
||||
// Return the download
|
||||
return download;
|
||||
}
|
||||
|
||||
add_task(async function test_pdf_object_attachment_download() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.navigation.object_embed.allow_retargeting", true]],
|
||||
});
|
||||
|
||||
// Set the behaviour to save pdfs to disk and not handle internally, so we
|
||||
// don't end up with extra tabs after the test.
|
||||
var gMimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
|
||||
var gHandlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"].getService(
|
||||
Ci.nsIHandlerService
|
||||
);
|
||||
const mimeInfo = gMimeSvc.getFromTypeAndExtension("application/pdf", "pdf");
|
||||
let previousAction = mimeInfo.preferredAction;
|
||||
mimeInfo.preferredAction = Ci.nsIHandlerInfo.saveToDisk;
|
||||
gHandlerSvc.store(mimeInfo);
|
||||
registerCleanupFunction(() => {
|
||||
mimeInfo.preferredAction = previousAction;
|
||||
gHandlerSvc.store(mimeInfo);
|
||||
});
|
||||
|
||||
// Start listening for the download before opening the new tab.
|
||||
let downloadPromise = waitForDownload();
|
||||
await BrowserTestUtils.withNewTab(
|
||||
`${httpsTestRoot}/file_pdf_object_attachment.html`,
|
||||
async browser => {
|
||||
let download = await downloadPromise;
|
||||
is(
|
||||
download.source.url,
|
||||
`${httpsTestRoot}/file_pdf_attachment.pdf`,
|
||||
"download should be the pdf"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let obj = content.document.querySelector("object");
|
||||
is(
|
||||
obj.displayedType,
|
||||
Ci.nsIObjectLoadingContent.TYPE_FALLBACK,
|
||||
"should be displaying TYPE_FALLBACK"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_img_object_attachment_download() {
|
||||
// NOTE: This is testing our current behaviour here as of bug 1868001 (which
|
||||
// is to download an image with `Content-Disposition: attachment` embedded
|
||||
// within an object or embed element).
|
||||
//
|
||||
// Other browsers ignore the `Content-Disposition: attachment` header when
|
||||
// loading images within object or embed element as-of december 2023, as
|
||||
// we did prior to the changes in bug 1595491.
|
||||
//
|
||||
// If this turns out to be a web-compat issue, we may want to introduce
|
||||
// special handling to ignore content-disposition when loading images within
|
||||
// an object or embed element.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.navigation.object_embed.allow_retargeting", true]],
|
||||
});
|
||||
|
||||
// Start listening for the download before opening the new tab.
|
||||
let downloadPromise = waitForDownload();
|
||||
await BrowserTestUtils.withNewTab(
|
||||
`${httpsTestRoot}/file_img_object_attachment.html`,
|
||||
async browser => {
|
||||
let download = await downloadPromise;
|
||||
is(
|
||||
download.source.url,
|
||||
`${httpsTestRoot}/file_img_attachment.jpg`,
|
||||
"download should be the jpg"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let obj = content.document.querySelector("object");
|
||||
is(
|
||||
obj.displayedType,
|
||||
Ci.nsIObjectLoadingContent.TYPE_FALLBACK,
|
||||
"should be displaying TYPE_FALLBACK"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
@ -1 +0,0 @@
|
||||
Content-Disposition: attachment
|
@ -1,6 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<object data="file_img_attachment.jpg" type="image/jpeg" width="100%" height="600">fallback</object>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
Content-Type: application/octet-stream
|
||||
Content-Disposition: attachment
|
@ -1,6 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<object data="file_pdf_attachment.pdf" type="application/pdf" width="100%" height="600">fallback</object>
|
||||
</body>
|
||||
</html>
|
@ -3099,13 +3099,6 @@
|
||||
value: 10
|
||||
mirror: always
|
||||
|
||||
# Whether to allow <object> and <embed> element loads to be retargeted to an
|
||||
# external application or download.
|
||||
- name: dom.navigation.object_embed.allow_retargeting
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Network Information API
|
||||
# This feature is not available on Firefox desktop. It exposes too much
|
||||
# user information. Let's be consistent and disable it on Android.
|
||||
|
@ -340,17 +340,6 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo,
|
||||
|
||||
nsresult OnObjectStartRequest(nsIRequest* request) {
|
||||
LOG(("ParentProcessDocumentOpenInfo OnObjectStartRequest [this=%p]", this));
|
||||
|
||||
// If this load will be treated as a document load, run through
|
||||
// nsDocumentOpenInfo for consistency with other document loads.
|
||||
//
|
||||
// If the dom.navigation.object_embed.allow_retargeting pref is enabled,
|
||||
// this may lead to the resource being downloaded.
|
||||
if (nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
channel && channel->IsDocument()) {
|
||||
return OnDocumentStartRequest(request);
|
||||
}
|
||||
|
||||
// Just redirect to the nsObjectLoadingContent in the content process.
|
||||
m_targetStreamListener = mListener;
|
||||
return m_targetStreamListener->OnStartRequest(request);
|
||||
@ -826,9 +815,11 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
|
||||
}
|
||||
|
||||
// Recalculate the openFlags, matching the logic in use in Content process.
|
||||
// NOTE: The only case not handled here to mirror Content process is
|
||||
// redirecting to re-use the channel.
|
||||
MOZ_ASSERT(!aLoadState->GetPendingRedirectedChannel());
|
||||
uint32_t openFlags = nsDocShell::ComputeURILoaderFlags(
|
||||
loadingContext, aLoadState->LoadType(), mIsDocumentLoad);
|
||||
uint32_t openFlags =
|
||||
nsDocShell::ComputeURILoaderFlags(loadingContext, aLoadState->LoadType());
|
||||
|
||||
RefPtr<ParentProcessDocumentOpenInfo> openInfo =
|
||||
new ParentProcessDocumentOpenInfo(mParentChannelListener, openFlags,
|
||||
|
@ -274,19 +274,12 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest* request) {
|
||||
// could happen because the Content-Disposition header is set so, or, in the
|
||||
// future, because the user has specified external handling for the MIME
|
||||
// type.
|
||||
//
|
||||
// If we're not going to be able to retarget to an external handler, ignore
|
||||
// content-disposition, and unconditionally try to display the content.
|
||||
// This is used for object/embed tags, which expect to display subresources
|
||||
// marked with an attachment disposition.
|
||||
bool forceExternalHandling = false;
|
||||
if (!(mFlags & nsIURILoader::DONT_RETARGET)) {
|
||||
uint32_t disposition;
|
||||
rv = aChannel->GetContentDisposition(&disposition);
|
||||
uint32_t disposition;
|
||||
rv = aChannel->GetContentDisposition(&disposition);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && disposition == nsIChannel::DISPOSITION_ATTACHMENT) {
|
||||
forceExternalHandling = true;
|
||||
}
|
||||
if (NS_SUCCEEDED(rv) && disposition == nsIChannel::DISPOSITION_ATTACHMENT) {
|
||||
forceExternalHandling = true;
|
||||
}
|
||||
|
||||
LOG((" forceExternalHandling: %s", forceExternalHandling ? "yes" : "no"));
|
||||
|
Loading…
Reference in New Issue
Block a user