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
11291144nsresult Loader::LoadSheetSyncInternal (SheetLoadData& aLoadData,
0 commit comments