Bug 1847811 - Remove network.preload pref. r=necko-reviewers,anti-tracking-reviewers,pbz,kershaw

Having it disabled is not web compatible, and there's no strong reason
to keep it, IMO.

If we want another pref to determine whether preloads are actually
triggered we can add it in the future.

Differential Revision: https://phabricator.services.mozilla.com/D186014
This commit is contained in:
Emilio Cobos Álvarez 2023-08-14 10:46:03 +00:00
parent 0d1a2c2300
commit ea11c5c0b4
18 changed files with 69 additions and 132 deletions

View file

@ -79,10 +79,6 @@ function resetState() {
* testing if referrer header is sent correctly
*/
var tests = (function* () {
yield SpecialPowers.pushPrefEnv(
{ set: [["network.preload", true]] },
advance
);
yield SpecialPowers.pushPrefEnv(
{ set: [["security.mixed_content.block_active_content", false]] },
advance

View file

@ -71,12 +71,10 @@ const CROSS_ORIGIN = "http://example.com" + SJS_PATH;
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["network.preload", true]]})
// test same origin
.then(() => testPreloadEvent(SAME_ORIGIN + "?statusCode=200&cacheControl=no-cache", false, true))
.then(() => testPreloadEvent(SAME_ORIGIN + "?statusCode=404&cacheControl=no-cache", false, false))
.then(() => testPreloadEvent(SAME_ORIGIN + "?statusCode=200&cacheControl=max-age%3D120", false, true))
testPreloadEvent(SAME_ORIGIN + "?statusCode=200&cacheControl=no-cache", false, true)
.then(() => testPreloadEvent(SAME_ORIGIN + "?statusCode=404&cacheControl=no-cache", false, false))
.then(() => testPreloadEvent(SAME_ORIGIN + "?statusCode=200&cacheControl=max-age%3D120", false, true))
.then(() => testPreloadEvent(SAME_ORIGIN + "?statusCode=404&cacheControl=max-age%3D120", false, false))
// test cross origin without CORS

View file

@ -110,10 +110,8 @@ const CROSS_ORIGIN = "http://example.com";
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["network.preload", true]]})
// Test changing as parameter from a wrong to a correct one.
.then(() => testPreloadEventAsAttributeChange(SAME_ORIGIN + IMAGE_PATH))
testPreloadEventAsAttributeChange(SAME_ORIGIN + IMAGE_PATH)
// Test changing type parameter from a wrong to a correct one for given as parameter.
.then(() => testPreloadEventAttributeChange(SAME_ORIGIN + IMAGE_PATH, "type", "text/vtt", "image/png"))
// Test changing media parameter from a wrong to a correct one.

View file

@ -72,68 +72,62 @@ const SAME_ORIGIN = "http://mochi.test:8888" + SJS_PATH;
const CROSS_ORIGIN = "http://example.com" + SJS_PATH;
SimpleTest.waitForExplicitFinish();
SpecialPowers.spawnChrome([], () => {
let window = this.browsingContext.currentWindowGlobal;
window.ChannelEventSink = {
_classDescription: "WebRequest channel event sink",
_classID: Components.ID("115062f8-92f1-11e5-8b7f-08001110f7ec"),
_contractID: "@mozilla.org/webrequest/channel-event-sink;1",
SpecialPowers.pushPrefEnv({"set": [["network.preload", true]]})
QueryInterface: ChromeUtils.generateQI(["nsIChannelEventSink", "nsIFactory"]),
init() {
Components.manager
.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(
this._classID,
this._classDescription,
this._contractID,
this
);
},
.then(async () => {
await SpecialPowers.spawnChrome([], () => {
let window = this.browsingContext.currentWindowGlobal;
window.ChannelEventSink = {
_classDescription: "WebRequest channel event sink",
_classID: Components.ID("115062f8-92f1-11e5-8b7f-08001110f7ec"),
_contractID: "@mozilla.org/webrequest/channel-event-sink;1",
QueryInterface: ChromeUtils.generateQI(["nsIChannelEventSink", "nsIFactory"]),
init() {
Components.manager
.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(
this._classID,
this._classDescription,
register() {
Services.catMan.addCategoryEntry(
"net-channel-event-sinks",
this._contractID,
this
this._contractID,
false,
true
);
},
},
register() {
Services.catMan.addCategoryEntry(
"net-channel-event-sinks",
this._contractID,
this._contractID,
false,
true
);
},
unregister() {
Components.manager
.QueryInterface(Ci.nsIComponentRegistrar)
.unregisterFactory(this._classID, window.ChannelEventSink);
Services.catMan.deleteCategoryEntry(
"net-channel-event-sinks",
this._contractID,
false
);
},
unregister() {
Components.manager
.QueryInterface(Ci.nsIComponentRegistrar)
.unregisterFactory(this._classID, window.ChannelEventSink);
Services.catMan.deleteCategoryEntry(
"net-channel-event-sinks",
this._contractID,
false
);
},
// nsIChannelEventSink implementation
asyncOnChannelRedirect(oldChannel, newChannel, flags, redirectCallback) {
// Abort the redirection.
redirectCallback.onRedirectVerifyCallback(Cr.NS_ERROR_NO_INTERFACE);
},
// nsIChannelEventSink implementation
asyncOnChannelRedirect(oldChannel, newChannel, flags, redirectCallback) {
// Abort the redirection.
redirectCallback.onRedirectVerifyCallback(Cr.NS_ERROR_NO_INTERFACE);
},
// nsIFactory implementation
createInstance(iid) {
return this.QueryInterface(iid);
},
};
// nsIFactory implementation
createInstance(iid) {
return this.QueryInterface(iid);
},
};
window.ChannelEventSink.init();
window.ChannelEventSink.register();
})})
window.ChannelEventSink.init();
window.ChannelEventSink.register();
})
// test cross origin by redirection without CORS
.then(() => testPreloadEvent(SAME_ORIGIN + "?redirect=crossorigin&statusCode=200&cacheControl=no-cache", false, false))

View file

@ -309,26 +309,21 @@ void HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
}
// Keep this and the arrays below in sync with ToLinkMask in LinkStyle.cpp.
#define SUPPORTED_REL_VALUES_BASE \
"prefetch", "dns-prefetch", "stylesheet", "next", "alternate", "preconnect", \
"icon", "search", nullptr
#define SUPPORTED_REL_VALUES_BASE \
"preload", "prefetch", "dns-prefetch", "stylesheet", "next", "alternate", \
"preconnect", "icon", "search", nullptr
static const DOMTokenListSupportedToken sSupportedRelValueCombinations[][12] = {
{SUPPORTED_REL_VALUES_BASE},
{"manifest", SUPPORTED_REL_VALUES_BASE},
{"preload", SUPPORTED_REL_VALUES_BASE},
{"preload", "manifest", SUPPORTED_REL_VALUES_BASE},
{"modulepreload", SUPPORTED_REL_VALUES_BASE},
{"modulepreload", "manifest", SUPPORTED_REL_VALUES_BASE},
{"modulepreload", "preload", SUPPORTED_REL_VALUES_BASE},
{"modulepreload", "preload", "manifest", SUPPORTED_REL_VALUES_BASE}};
{"modulepreload", "manifest", SUPPORTED_REL_VALUES_BASE}};
#undef SUPPORTED_REL_VALUES_BASE
nsDOMTokenList* HTMLLinkElement::RelList() {
if (!mRelList) {
int index = (StaticPrefs::dom_manifest_enabled() ? 1 : 0) |
(StaticPrefs::network_preload() ? 2 : 0) |
(StaticPrefs::network_modulepreload() ? 4 : 0);
(StaticPrefs::network_modulepreload() ? 2 : 0);
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel,
sSupportedRelValueCombinations[index]);

View file

@ -15,16 +15,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1596040
async function run() {
const prefSetting = [
{ manifest: true, preload: true },
{ manifest: true, preload: false },
{ manifest: false, preload: true },
{ manifest: false, preload: false },
{ manifest: true, modulepreload: true },
{ manifest: true, modulepreload: false },
{ manifest: false, modulepreload: true },
{ manifest: false, modulepreload: false },
];
for (const { manifest, preload } of prefSetting) {
for (const { manifest, modulepreload } of prefSetting) {
await SpecialPowers.pushPrefEnv({
set: [
["dom.manifest.enabled", manifest],
["network.preload", preload],
["network.modulepreload", modulepreload],
],
});
const { relList } = document.createElement("link");
@ -34,9 +34,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1596040
`Expected manifest to be ${manifest}`
);
is(
relList.supports("preload"),
preload,
`Expected preload to be ${preload}`
relList.supports("modulepreload"),
modulepreload,
`Expected preload to be ${modulepreload}`
);
}
}

View file

@ -68,13 +68,7 @@ function checkFinished() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv(
{'set':[["network.preload", true]]},
function() {
document.getElementById("testframe").src = "file_link_rel_preload.html";
});
document.getElementById("testframe").src = "file_link_rel_preload.html";
</script>
</body>
</html>

View file

@ -79,10 +79,6 @@ function resetState() {
* testing if referrer header is sent correctly
*/
var tests = (function* () {
yield SpecialPowers.pushPrefEnv(
{ set: [["network.preload", true]] },
advance
);
yield SpecialPowers.pushPrefEnv(
{ set: [["security.mixed_content.block_active_content", false]] },
advance

View file

@ -2330,7 +2330,7 @@ nsresult imgLoader::LoadImage(
}
// Look in the preloaded images of loading document first.
if (StaticPrefs::network_preload() && !aLinkPreload && aLoadingDocument) {
if (!aLinkPreload && aLoadingDocument) {
// All Early Hints preloads are Link preloads, therefore we don't have a
// Early Hints preload here
MOZ_ASSERT(!aEarlyHintPreloaderId);

View file

@ -11691,13 +11691,6 @@
value: false
mirror: always
# Enables `<link rel="preload">` tag and `Link: rel=preload` response header
# handling.
- name: network.preload
type: RelaxedAtomicBool
value: true
mirror: always
# Enables `<link rel="preconnect">` tag and `Link: rel=preconnect` response header
# handling.
- name: network.preconnect

View file

@ -209,8 +209,7 @@ void EarlyHintPreloader::MaybeCreateAndInsertPreload(
ASDestination destination = static_cast<ASDestination>(as.GetEnumValue());
CollectResourcesTypeTelemetry(destination);
if (!StaticPrefs::network_early_hints_enabled() ||
!StaticPrefs::network_preload()) {
if (!StaticPrefs::network_early_hints_enabled()) {
return;
}

View file

@ -34,18 +34,6 @@ add_task(async function test_103_preload_disabled() {
Services.prefs.setBoolPref("network.early-hints.enabled", true);
});
// Test that with preload config option disabled, no early hint requests are made
add_task(async function test_103_preload_disabled() {
Services.prefs.setBoolPref("network.preload", false);
await test_hint_preload(
"test_103_preload_disabled",
"https://example.com",
"https://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 0, normal: 1 }
);
Services.prefs.clearUserPref("network.preload");
});
// Preload with same origin in secure context with mochitest http proxy
add_task(async function test_103_preload_https() {
await test_hint_preload(

View file

@ -302,8 +302,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
mSpeculativeLoadQueue.AppendElement()->InitPreconnect(
url, crossOrigin);
}
} else if (mozilla::StaticPrefs::network_preload() &&
rel.LowerCaseEqualsASCII("preload")) {
} else if (rel.LowerCaseEqualsASCII("preload")) {
nsHtml5String url =
aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF);
if (url) {

View file

@ -27,8 +27,6 @@ user_pref("focusmanager.testmode", true);
user_pref("media.navigator.streams.fake", true);
// Disable permission prompt for getUserMedia
user_pref("media.navigator.permission.disabled", true);
// Enable pre-fetching of resources
user_pref("network.preload", true);
// Enable direct connection
user_pref("network.proxy.type", 0);
// Web-platform-tests load a lot of URLs very quickly. This puts avoidable and

View file

@ -663,7 +663,6 @@ class ProfileCreator:
# TODO: Remove preferences once Firefox 64 is stable (Bug 905404)
"network.proxy.type": 0,
"places.history.enabled": False,
"network.preload": True,
})
if self.e10s:
profile.set_preferences({"browser.tabs.remote.autostart": True})

View file

@ -125,7 +125,6 @@ class ProfileCreator(FirefoxProfileCreator):
"dom.disable_open_during_load": False,
"places.history.enabled": False,
"dom.send_after_paint_to_content": True,
"network.preload": True,
"browser.tabs.remote.autostart": True,
})

View file

@ -57,7 +57,6 @@ async function checkCache(originAttributes) {
add_task(async () => {
do_get_profile();
Services.prefs.setBoolPref("network.preload", true);
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
const server = CookieXPCShellUtils.createServer({

View file

@ -68,10 +68,6 @@ already_AddRefed<PreloaderBase> PreloadService::PreloadLinkElement(
return nullptr;
}
if (!StaticPrefs::network_preload()) {
return nullptr;
}
nsAutoString as, charset, crossOrigin, integrity, referrerPolicy, rel, srcset,
sizes, type, url;
@ -123,10 +119,6 @@ void PreloadService::PreloadLinkHeader(
return;
}
if (!StaticPrefs::network_preload()) {
return;
}
PreloadOrCoalesce(aURI, aURL, aPolicyType, aAs, aType, u""_ns, aSrcset,
aSizes, aNonce, aIntegrity, aCORS, aReferrerPolicy,
/* aFromHeader = */ true, aEarlyHintPreloaderId);