From 066e83f229cd178698c04e90a294a47f483fd329 Mon Sep 17 00:00:00 2001 From: Benjamin VanderSloot Date: Mon, 17 Oct 2022 16:07:50 +0000 Subject: [PATCH] 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 --- .../server/actors/network-monitor/utils/network-utils.js | 1 + dom/base/nsContentPolicyUtils.h | 1 + dom/base/nsIContentPolicy.idl | 6 ++++++ dom/cache/DBSchema.cpp | 3 ++- dom/fetch/InternalRequest.cpp | 2 ++ dom/security/SecFetch.cpp | 2 ++ dom/security/nsCSPUtils.cpp | 1 + ipc/glue/IPCMessageUtilsSpecializations.h | 2 +- remote/cdp/domains/parent/Network.sys.mjs | 1 + 9 files changed, 17 insertions(+), 2 deletions(-) diff --git a/devtools/server/actors/network-monitor/utils/network-utils.js b/devtools/server/actors/network-monitor/utils/network-utils.js index bddcca393cfd..1a0abf2f9e22 100644 --- a/devtools/server/actors/network-monitor/utils/network-utils.js +++ b/devtools/server/actors/network-monitor/utils/network-utils.js @@ -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( diff --git a/dom/base/nsContentPolicyUtils.h b/dom/base/nsContentPolicyUtils.h index 51fe4150f2f5..77cab8a87d34 100644 --- a/dom/base/nsContentPolicyUtils.h +++ b/dom/base/nsContentPolicyUtils.h @@ -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. diff --git a/dom/base/nsIContentPolicy.idl b/dom/base/nsIContentPolicy.idl index 785b11ad8633..484abe322bbe 100644 --- a/dom/base/nsIContentPolicy.idl +++ b/dom/base/nsIContentPolicy.idl @@ -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 diff --git a/dom/cache/DBSchema.cpp b/dom/cache/DBSchema.cpp index 4c49452bbab6..92f928e4f850 100644 --- a/dom/cache/DBSchema.cpp +++ b/dom/cache/DBSchema.cpp @@ -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 { diff --git a/dom/fetch/InternalRequest.cpp b/dom/fetch/InternalRequest.cpp index 65ade82a5f53..a6dbf73bdfac 100644 --- a/dom/fetch/InternalRequest.cpp +++ b/dom/fetch/InternalRequest.cpp @@ -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. diff --git a/dom/security/SecFetch.cpp b/dom/security/SecFetch.cpp index 7c18e60d0345..06aa3de699eb 100644 --- a/dom/security/SecFetch.cpp +++ b/dom/security/SecFetch.cpp @@ -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. diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp index 3f0ca7fb77fc..2d3fbf6d2488 100644 --- a/dom/security/nsCSPUtils.cpp +++ b/dom/security/nsCSPUtils.cpp @@ -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: diff --git a/ipc/glue/IPCMessageUtilsSpecializations.h b/ipc/glue/IPCMessageUtilsSpecializations.h index 72e69a7860df..9cb462a83b5a 100644 --- a/ipc/glue/IPCMessageUtilsSpecializations.h +++ b/ipc/glue/IPCMessageUtilsSpecializations.h @@ -329,7 +329,7 @@ template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< nsContentPolicyType, nsIContentPolicy::TYPE_INVALID, - nsIContentPolicy::TYPE_INTERNAL_FETCH_PRELOAD> {}; + nsIContentPolicy::TYPE_WEB_IDENTITY> {}; template <> struct ParamTraits { diff --git a/remote/cdp/domains/parent/Network.sys.mjs b/remote/cdp/domains/parent/Network.sys.mjs index e100ce8cc7e5..bccebe7aedae 100644 --- a/remote/cdp/domains/parent/Network.sys.mjs +++ b/remote/cdp/domains/parent/Network.sys.mjs @@ -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 {