Skip to content

Commit

Permalink
Bug 1793647, part 1 - Create new Sec-Fetch-Dest value for WebIdentity…
Browse files Browse the repository at this point in the history
… (FedCM), r=freddyb,webdriver-reviewers,whimboo

This is to keep up with WHATWG Fetch whatwg/fetch#1495 .
Also revised to not include the new destination type in the RequestDestination enum, per whatwg/fetch#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
  • Loading branch information
bvandersloot-mozilla committed Oct 17, 2022
1 parent 701569f commit 066e83f
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsContentPolicyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions dom/base/nsIContentPolicy.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion dom/cache/DBSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions dom/fetch/InternalRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions dom/security/SecFetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions dom/security/nsCSPUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ipc/glue/IPCMessageUtilsSpecializations.h
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
1 change: 1 addition & 0 deletions remote/cdp/domains/parent/Network.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 066e83f

Please sign in to comment.