Skip to content

Commit 911a588

Browse files
committed
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
1 parent 379b19f commit 911a588

File tree

7 files changed

+31
-6
lines changed

7 files changed

+31
-6
lines changed

docshell/test/browser/browser_viewsource_multipart.js

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
88
);
99
const MULTIPART_URI = `${TEST_PATH}file_basic_multipart.sjs`;
1010

11+
add_setup(async () => {
12+
await SpecialPowers.pushPrefEnv({
13+
set: [["network.multipart-mixed-replace.enabled_for_document", true]],
14+
});
15+
});
1116
add_task(async function viewsource_multipart_uri() {
1217
await BrowserTestUtils.withNewTab("about:blank", async browser => {
1318
BrowserTestUtils.startLoadingURIString(browser, MULTIPART_URI);

docshell/test/mochitest/test_bug1747033.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@
8787
SimpleTest.finish();
8888
});
8989
}
90+
SpecialPowers.pushPrefEnv({set:
91+
[["network.multipart-mixed-replace.enabled_for_document", true]]},
92+
() => {
93+
runTest();
94+
}
95+
);
9096
</script>
9197
</head>
92-
<body onload="runTest();">
98+
<body>
9399
<p id="display"></p>
94100
<div id="content" style="display: none"></div>
95101
<pre id="test"></pre>

docshell/test/mochitest/test_bug660404.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
}
6666

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

docshell/test/mochitest/test_compressed_multipart.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
SimpleTest.finish();
3434
}
3535

36-
w = window.open("file_compressed_multipart");
37-
36+
SpecialPowers.pushPrefEnv({set:
37+
[["network.multipart-mixed-replace.enabled_for_document", true]]}, () => {
38+
w = window.open("file_compressed_multipart");
39+
});
3840
</script>
3941
</pre>
4042
</body>

dom/base/test/test_x-frame-options.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@
183183

184184
// load the test harness
185185
SpecialPowers.pushPrefEnv({
186-
"set": [["security.data_uri.block_toplevel_data_uri_navigations", false],]
186+
"set": [["security.data_uri.block_toplevel_data_uri_navigations", false],
187+
["network.multipart-mixed-replace.enabled_for_document", true],
188+
]
187189
}, function() {
188190
document.getElementById("harness").src = "file_x-frame-options_main.html";
189191
});

modules/libpref/init/StaticPrefList.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -11711,6 +11711,12 @@
1171111711
value: true
1171211712
mirror: always
1171311713

11714+
# Re-enables multipart/x-mixed-replace for DOCUMENT types
11715+
- name: network.multipart-mixed-replace.enabled_for_document
11716+
type: RelaxedAtomicBool
11717+
value: false
11718+
mirror: always
11719+
1171411720
# Enables `<link rel="modulepreload">` tag and `Link: rel=modulepreload`
1171511721
# response header handling.
1171611722
- name: network.modulepreload

netwerk/protocol/http/nsHttpChannel.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,10 @@ nsresult nsHttpChannel::CallOnStartRequest() {
17031703
nsAutoCString contentType;
17041704
mResponseHead->ContentType(contentType);
17051705

1706-
if (contentType.Equals("multipart/x-mixed-replace"_ns)) {
1706+
if (contentType.Equals("multipart/x-mixed-replace"_ns) &&
1707+
((mLoadInfo->GetExternalContentPolicyType() !=
1708+
ExtContentPolicyType::TYPE_DOCUMENT) ||
1709+
StaticPrefs::network_multipart_mixed_replace_enabled_for_document())) {
17071710
nsCOMPtr<nsIStreamConverterService> convServ(
17081711
do_GetService("@mozilla.org/streamConverters;1", &rv));
17091712
if (NS_SUCCEEDED(rv)) {

0 commit comments

Comments
 (0)