Bug 1793647, part 1 - Create new Sec-Fetch-Dest value for WebIdentity (FedCM), r=freddyb,webdriver-reviewers,whimboo

This is to keep up with WHATWG Fetch https://github.com/whatwg/fetch/pull/1495 .
Also revised to not include the new destination type in the RequestDestination enum, per https://github.com/whatwg/fetch/pull/1500 .

I added an element to nsIContentPolicy::nsContentPolicyType as my starting point and
proceeded from there, following the instructions at the end of the internal enum.

Differential Revision: https://phabricator.services.mozilla.com/D158657
This commit is contained in:
Benjamin VanderSloot 2022-10-17 16:07:50 +00:00
parent 701569f1d4
commit 066e83f229
9 changed files with 17 additions and 2 deletions

View file

@ -51,6 +51,7 @@ const LOAD_CAUSE_STRINGS = {
[Ci.nsIContentPolicy.TYPE_FETCH]: "fetch",
[Ci.nsIContentPolicy.TYPE_IMAGESET]: "imageset",
[Ci.nsIContentPolicy.TYPE_WEB_MANIFEST]: "webManifest",
[Ci.nsIContentPolicy.TYPE_WEB_IDENTITY]: "webidentity",
};
exports.causeTypeToString = function(

View file

@ -145,6 +145,7 @@ inline const char* NS_CP_ContentTypeName(nsContentPolicyType contentType) {
CASE_RETURN(TYPE_INTERNAL_FETCH_PRELOAD);
CASE_RETURN(TYPE_UA_FONT);
CASE_RETURN(TYPE_PROXIED_WEBRTC_MEDIA);
CASE_RETURN(TYPE_WEB_IDENTITY);
case nsIContentPolicy::TYPE_INVALID:
break;
// Do not add default: so that compilers can catch the missing case.

View file

@ -427,6 +427,12 @@ interface nsIContentPolicy : nsISupports
*/
TYPE_PROXIED_WEBRTC_MEDIA = 56,
/**
* Indicates the load of data via the Federated Credential Management API
* with data destined for a browser context.
*/
TYPE_WEB_IDENTITY = 57,
/* When adding new content types, please update
* NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective,
* DoContentSecurityChecks, all nsIContentPolicy implementations, the

View file

@ -341,7 +341,8 @@ static_assert(
nsIContentPolicy::TYPE_INTERNAL_CHROMEUTILS_COMPILED_SCRIPT == 52 &&
nsIContentPolicy::TYPE_INTERNAL_FRAME_MESSAGEMANAGER_SCRIPT == 53 &&
nsIContentPolicy::TYPE_INTERNAL_FETCH_PRELOAD == 54 &&
nsIContentPolicy::TYPE_UA_FONT == 55,
nsIContentPolicy::TYPE_UA_FONT == 55 &&
nsIContentPolicy::TYPE_WEB_IDENTITY == 57,
"nsContentPolicyType values are as expected");
namespace {

View file

@ -302,6 +302,8 @@ RequestDestination InternalRequest::MapContentPolicyTypeToRequestDestination(
return RequestDestination::Paintworklet;
case nsIContentPolicy::TYPE_PROXIED_WEBRTC_MEDIA:
return RequestDestination::_empty;
case nsIContentPolicy::TYPE_WEB_IDENTITY:
return RequestDestination::_empty;
case nsIContentPolicy::TYPE_INVALID:
break;
// Do not add default: so that compilers can catch the missing case.

View file

@ -106,6 +106,8 @@ nsCString MapInternalContentPolicyTypeToDest(nsContentPolicyType aType) {
return "empty"_ns;
case nsIContentPolicy::TYPE_PROXIED_WEBRTC_MEDIA:
return "empty"_ns;
case nsIContentPolicy::TYPE_WEB_IDENTITY:
return "webidentity"_ns;
case nsIContentPolicy::TYPE_INVALID:
break;
// Do not add default: so that compilers can catch the missing case.

View file

@ -322,6 +322,7 @@ CSPDirective CSP_ContentTypeToDirective(nsContentPolicyType aType) {
case nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST:
case nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE:
case nsIContentPolicy::TYPE_INTERNAL_FETCH_PRELOAD:
case nsIContentPolicy::TYPE_WEB_IDENTITY:
return nsIContentSecurityPolicy::CONNECT_SRC_DIRECTIVE;
case nsIContentPolicy::TYPE_OBJECT:

View file

@ -329,7 +329,7 @@ template <>
struct ParamTraits<nsContentPolicyType>
: public ContiguousEnumSerializerInclusive<
nsContentPolicyType, nsIContentPolicy::TYPE_INVALID,
nsIContentPolicy::TYPE_INTERNAL_FETCH_PRELOAD> {};
nsIContentPolicy::TYPE_WEB_IDENTITY> {};
template <>
struct ParamTraits<mozilla::TimeDuration> {

View file

@ -28,6 +28,7 @@ const LOAD_CAUSE_STRINGS = {
[Ci.nsIContentPolicy.TYPE_FETCH]: "Fetch",
[Ci.nsIContentPolicy.TYPE_IMAGESET]: "Imageset",
[Ci.nsIContentPolicy.TYPE_WEB_MANIFEST]: "WebManifest",
[Ci.nsIContentPolicy.TYPE_WEB_IDENTITY]: "Webidentity",
};
export class Network extends Domain {