Issue #2158 - Part 5: Guard preload links support with a preference

This is enabled by default.
This commit is contained in:
FranklinDM 2024-01-27 12:02:10 +08:00 committed by roytam1
commit 6c53117699
4 changed files with 24 additions and 1 deletions

View file

@ -295,6 +295,7 @@ bool nsContentUtils::sGettersDecodeURLHash = false;
bool nsContentUtils::sPrivacyResistFingerprinting = false;
bool nsContentUtils::sSendPerformanceTimingNotifications = false;
bool nsContentUtils::sUseActivityCursor = false;
bool nsContentUtils::sPreloadEnabled = true;
uint32_t nsContentUtils::sHandlingInputTimeout = 1000;
@ -633,6 +634,9 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sUseActivityCursor,
"ui.use_activity_cursor", false);
Preferences::AddBoolVarCache(&sPreloadEnabled,
"network.preload", true);
Element::InitCCCallbacks();
nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
@ -4125,6 +4129,10 @@ void
nsContentUtils::DispatchEventForPreloadURI(nsIDOMNode* aNode,
nsContentPolicyType& aPolicyType)
{
if (!IsPreloadEnabled()) {
return;
}
nsCOMPtr<nsINode> domNode = do_QueryInterface(aNode);
if (domNode && domNode->IsInComposedDoc()) {
bool success = aPolicyType != nsIContentPolicy::TYPE_INVALID;
@ -7396,6 +7404,12 @@ nsContentUtils::GPCEnabled()
return nsContentUtils::sGPCEnabled;
}
bool
nsContentUtils::IsPreloadEnabled()
{
return nsContentUtils::sPreloadEnabled;
}
mozilla::LogModule*
nsContentUtils::DOMDumpLog()
{