mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
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:
parent
cd69bc3c65
commit
b758eaeb68
@ -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));
|
||||
|
@ -300,6 +300,10 @@ class ScriptLoadRequest
|
||||
return mReferrerPolicy;
|
||||
}
|
||||
|
||||
void UpdateReferrerPolicy(mozilla::dom::ReferrerPolicy aReferrerPolicy) {
|
||||
mReferrerPolicy = aReferrerPolicy;
|
||||
}
|
||||
|
||||
enum ParserMetadata ParserMetadata() const {
|
||||
return mFetchOptions->mParserMetadata;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user