Skip to content

Commit 8a8fd7b

Browse files
committed
Bug 1968644 - Part 5: Populate triggeringFirstPartyClassificationFlags and triggeringThirdPartyClassificationFlags for CSS loads. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D252447
1 parent 7b3ba3b commit 8a8fd7b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

layout/style/Loader.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "nsContentPolicyUtils.h"
4343
#include "nsIHttpChannel.h"
4444
#include "nsIHttpChannelInternal.h"
45+
#include "nsIClassifiedChannel.h"
4546
#include "nsIClassOfService.h"
4647
#include "nsIScriptError.h"
4748
#include "nsMimeTypes.h"
@@ -1069,6 +1070,7 @@ nsresult Loader::NewStyleSheetChannel(SheetLoadData& aLoadData,
10691070
nsIChannel** aOutChannel) {
10701071
nsCOMPtr<nsILoadGroup> loadGroup;
10711072
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
1073+
net::ClassificationFlags triggeringClassificationFlags;
10721074
if (aUseLoadGroup == UseLoadGroup::Yes && mDocument) {
10731075
loadGroup = mDocument->GetDocumentLoadGroup();
10741076
// load for a document with no loadgrup indicates that something is
@@ -1079,6 +1081,11 @@ nsresult Loader::NewStyleSheetChannel(SheetLoadData& aLoadData,
10791081
}
10801082

10811083
cookieJarSettings = mDocument->CookieJarSettings();
1084+
1085+
// If the script context is tracking, we use the flags from the script
1086+
// tracking flags. Otherwise, we fallback to use the flags from the
1087+
// document.
1088+
triggeringClassificationFlags = mDocument->GetScriptTrackingFlags();
10821089
}
10831090

10841091
nsSecurityFlags securityFlags =
@@ -1121,9 +1128,17 @@ nsresult Loader::NewStyleSheetChannel(SheetLoadData& aLoadData,
11211128
}
11221129
}
11231130

1124-
return NS_NewChannel(aOutChannel, aLoadData.mURI, triggeringPrincipal,
1125-
securityFlags, contentPolicyType, cookieJarSettings,
1126-
/* aPerformanceStorage = */ nullptr, loadGroup);
1131+
MOZ_TRY(NS_NewChannel(aOutChannel, aLoadData.mURI, triggeringPrincipal,
1132+
securityFlags, contentPolicyType, cookieJarSettings,
1133+
/* aPerformanceStorage = */ nullptr, loadGroup));
1134+
1135+
nsCOMPtr<nsILoadInfo> loadInfo = (*aOutChannel)->LoadInfo();
1136+
loadInfo->SetTriggeringFirstPartyClassificationFlags(
1137+
triggeringClassificationFlags.firstPartyFlags);
1138+
loadInfo->SetTriggeringThirdPartyClassificationFlags(
1139+
triggeringClassificationFlags.thirdPartyFlags);
1140+
1141+
return NS_OK;
11271142
}
11281143

11291144
nsresult Loader::LoadSheetSyncInternal(SheetLoadData& aLoadData,

0 commit comments

Comments
 (0)