Bug 1841859 - Part 2: Parse the referrer policy from http header and update the referrer policy. r=jonco,smaug
This implementes the following requirement from the spec: https://html.spec.whatwg.org/#fetch-a-single-module-script 12. In both cases, let processResponseConsumeBody given response response and null, failure, or a byte sequence bodyBytes be the following algorithm: 5. Let referrerPolicy be the result of parsing the `Referrer-Policy` header given response. 6. If referrerPolicy is not the empty string, set options's referrer policy to referrerPolicy. Differential Revision: https://phabricator.services.mozilla.com/D186944
This commit is contained in:
@@ -3730,6 +3730,17 @@ nsresult ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (aRequest->IsModuleRequest()) {
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script
|
||||
// Update script's referrer-policy if there's a Referrer-Policy header in
|
||||
// the HTTP response.
|
||||
ReferrerPolicy policy =
|
||||
nsContentUtils::GetReferrerPolicyFromChannel(httpChannel);
|
||||
if (policy != ReferrerPolicy::_empty) {
|
||||
aRequest->UpdateReferrerPolicy(policy);
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoCString sourceMapURL;
|
||||
if (nsContentUtils::GetSourceMapURL(httpChannel, sourceMapURL)) {
|
||||
aRequest->mSourceMapURL = Some(NS_ConvertUTF8toUTF16(sourceMapURL));
|
||||
|
||||
Reference in New Issue
Block a user