Bug 1276918 - restrict multipart/x-mixed-replace to non-document loads r=necko-reviewers,valentin,kershaw

Ideally, I would like to remove this for all types except images, but there
is some uncertainty wrt to other media load types and making small steps is
easier than huge strides. Especially when it's risking compatibility.

Differential Revision: https://phabricator.services.mozilla.com/D194917
This commit is contained in:
Frederik Braun 2023-12-06 14:07:34 +00:00
Родитель 379b19fb54
Коммит 911a588250
7 изменённых файлов: 31 добавлений и 6 удалений

Просмотреть файл

@ -8,6 +8,11 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
);
const MULTIPART_URI = `${TEST_PATH}file_basic_multipart.sjs`;
add_setup(async () => {
await SpecialPowers.pushPrefEnv({
set: [["network.multipart-mixed-replace.enabled_for_document", true]],
});
});
add_task(async function viewsource_multipart_uri() {
await BrowserTestUtils.withNewTab("about:blank", async browser => {
BrowserTestUtils.startLoadingURIString(browser, MULTIPART_URI);

Просмотреть файл

@ -87,9 +87,15 @@
SimpleTest.finish();
});
}
SpecialPowers.pushPrefEnv({set:
[["network.multipart-mixed-replace.enabled_for_document", true]]},
() => {
runTest();
}
);
</script>
</head>
<body onload="runTest();">
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>

Просмотреть файл

@ -65,7 +65,8 @@ bc.onmessage = (msgEvent) => {
}
// If Fission is disabled, the pref is no-op.
SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]}, () => {
SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true],
["network.multipart-mixed-replace.enabled_for_document", true]]}, () => {
// Have to open a new window, since there's no bfcache in subframes
window.open("file_bug660404-1.html", "", "noopener");
});

Просмотреть файл

@ -33,8 +33,10 @@ function finishTest() {
SimpleTest.finish();
}
w = window.open("file_compressed_multipart");
SpecialPowers.pushPrefEnv({set:
[["network.multipart-mixed-replace.enabled_for_document", true]]}, () => {
w = window.open("file_compressed_multipart");
});
</script>
</pre>
</body>

Просмотреть файл

@ -183,7 +183,9 @@ SimpleTest.waitForExplicitFinish();
// load the test harness
SpecialPowers.pushPrefEnv({
"set": [["security.data_uri.block_toplevel_data_uri_navigations", false],]
"set": [["security.data_uri.block_toplevel_data_uri_navigations", false],
["network.multipart-mixed-replace.enabled_for_document", true],
]
}, function() {
document.getElementById("harness").src = "file_x-frame-options_main.html";
});

Просмотреть файл

@ -11711,6 +11711,12 @@
value: true
mirror: always
# Re-enables multipart/x-mixed-replace for DOCUMENT types
- name: network.multipart-mixed-replace.enabled_for_document
type: RelaxedAtomicBool
value: false
mirror: always
# Enables `<link rel="modulepreload">` tag and `Link: rel=modulepreload`
# response header handling.
- name: network.modulepreload

Просмотреть файл

@ -1703,7 +1703,10 @@ nsresult nsHttpChannel::CallOnStartRequest() {
nsAutoCString contentType;
mResponseHead->ContentType(contentType);
if (contentType.Equals("multipart/x-mixed-replace"_ns)) {
if (contentType.Equals("multipart/x-mixed-replace"_ns) &&
((mLoadInfo->GetExternalContentPolicyType() !=
ExtContentPolicyType::TYPE_DOCUMENT) ||
StaticPrefs::network_multipart_mixed_replace_enabled_for_document())) {
nsCOMPtr<nsIStreamConverterService> convServ(
do_GetService("@mozilla.org/streamConverters;1", &rv));
if (NS_SUCCEEDED(rv)) {