chromium/third_party/blink/public/mojom/devtools/inspector_issue.mojom

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module blink.mojom;

import "url/mojom/url.mojom";
import "services/network/public/mojom/cookie_manager.mojom";
import "services/network/public/mojom/blocked_by_response_reason.mojom";
import "third_party/blink/public/mojom/fetch/fetch_api_request.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";

// A code that uniquely identifies an issue. This type should be descriptive
// enough for the front-end to provide a clear description of the issue.
enum InspectorIssueCode {
  kCookieIssue,
  kMixedContentIssue,
  kBlockedByResponseIssue,
  kContentSecurityPolicyIssue,
  kSharedArrayBufferIssue,
  kHeavyAdIssue,
  kAttributionReportingIssue,
  kLowTextContrastIssue,
  kFederatedAuthRequestIssue,
  kBounceTrackingIssue,
  kCookieDeprecationMetadataIssue,
  kGenericIssue,
  kDeprecationIssue,
  kFederatedAuthUserInfoRequestIssue,
};

// Information about a cookie that is affected by an issue.
struct AffectedCookie {
  string name;
  string path;
  string domain;
};

struct AffectedRequest {
  string request_id;
  string? url;
};

struct AffectedFrame {
  string frame_id;
};

struct AffectedLocation {
  string? script_id;
  string? url;
  uint32 line = 0;  // Zero-based as the DevTools front-end expects it.
  uint32 column = 0;
};

struct BlockedByResponseIssueDetails {
  AffectedRequest request;
  AffectedFrame? parentFrame;
  AffectedFrame? blockedFrame;
  network.mojom.BlockedByResponseReason reason;
};

enum HeavyAdResolutionStatus {
  kHeavyAdBlocked,
  kHeavyAdWarning,
};

enum HeavyAdReason {
  kNetworkTotalLimit,
  kCpuTotalLimit,
  kCpuPeakLimit,
};

struct HeavyAdIssueDetails {
  HeavyAdResolutionStatus resolution;
  HeavyAdReason reason;
  AffectedFrame frame;
};

enum AttributionReportingIssueType {
  kPermissionPolicyDisabled,
  kUntrustworthyReportingOrigin,
  kInsecureContext,
  kInvalidRegisterSourceHeader,
  kInvalidRegisterTriggerHeader,
  kSourceAndTriggerHeaders,
  kSourceIgnored,
  kTriggerIgnored,
  kOsSourceIgnored,
  kOsTriggerIgnored,
  kInvalidRegisterOsSourceHeader,
  kInvalidRegisterOsTriggerHeader,
  kWebAndOsHeaders,
  kNoWebOrOsSupport,
  kNavigationRegistrationWithoutTransientUserActivation,
  kInvalidInfoHeader,
  kNoRegisterSourceHeader,
  kNoRegisterTriggerHeader,
  kNoRegisterOsSourceHeader,
  kNoRegisterOsTriggerHeader,
  kNavigationRegistrationUniqueScopeAlreadySet,
};

struct AttributionReportingIssueDetails {
  AttributionReportingIssueType violation_type;
  AffectedRequest? request;
  string? invalid_parameter;
};

enum MixedContentResolutionStatus {
  kMixedContentBlocked,
  kMixedContentAutomaticallyUpgraded,
  kMixedContentWarning,
};

struct MixedContentIssueDetails {
  RequestContextType request_context;
  MixedContentResolutionStatus resolution_status;
  string insecure_url;
  string main_resource_url;
  AffectedRequest? request;
  AffectedFrame? frame;
};

enum ContentSecurityPolicyViolationType {
    kInlineViolation,
    kEvalViolation,
    kURLViolation,
    kTrustedTypesSinkViolation,
    kTrustedTypesPolicyViolation,
    kWasmEvalViolation,
};

struct ContentSecurityPolicyIssueDetails {
  url.mojom.Url? blocked_url;
  string violated_directive;
  bool is_report_only;
  ContentSecurityPolicyViolationType content_security_policy_violation_type;
  AffectedFrame? frame_ancestor;
  AffectedLocation? affected_location;
  // 0 is not a valid node id and is used to indicate absence.
  int32 violating_node_id = 0;
};

enum CookieOperation {
  kSetCookie, kReadCookie
};

// Reasons why a cookie was excluded from a cookie get or set operation,
// see net/cookies/cookie_inclusion_status.h
enum CookieExclusionReason {
  kExcludeSameSiteUnspecifiedTreatedAsLax,
  kExcludeSameSiteNoneInsecure,
  kExcludeSameSiteLax,
  kExcludeSameSiteStrict,
  kExcludeDomainNonASCII,
  kExcludeThirdPartyPhaseout,
};

// Reasons to warn about a cookie, see net/cookies/cookie_inclusion_status.h
enum CookieWarningReason {
  kWarnSameSiteUnspecifiedCrossSiteContext,
  kWarnSameSiteNoneInsecure,
  kWarnSameSiteUnspecifiedLaxAllowUnsafe,
  kWarnSameSiteStrictLaxDowngradeStrict,
  kWarnSameSiteStrictCrossDowngradeStrict,
  kWarnSameSiteStrictCrossDowngradeLax,
  kWarnSameSiteLaxCrossDowngradeStrict,
  kWarnSameSiteLaxCrossDowngradeLax,
  kWarnAttributeValueExceedsMaxSize,
  kWarnDomainNonASCII,
  kWarnThirdPartyPhaseout,
  kWarnCrossSiteRedirectDowngradeChangesInclusion,
};

// Specific information about |kCookieIssue| type issues.
struct CookieIssueDetails {
  AffectedCookie cookie;
  array<CookieExclusionReason> exclusion_reason;
  array<CookieWarningReason> warning_reason;
  CookieOperation operation;
  url.mojom.Url? site_for_cookies;
  url.mojom.Url? cookie_url;
  AffectedRequest? request;
};

enum SharedArrayBufferIssueType {
  kTransferIssue,
  kCreationIssue,
};

struct SharedArrayBufferIssueDetails {
  AffectedLocation? affected_location;
  bool is_warning;
  SharedArrayBufferIssueType type;
};

struct LowTextContrastIssue {
  int32 violating_node_id;
  string violating_node_selector;
  float contrast_ratio;
  float threshold_aa;
  float threshold_aaa;
  string font_size;
  string font_weight;
};

// Represents the fetch result from a federated authentication request. Should
// be updated alongside FederatedAuthRequestIssueReason in
// third_party/blink/public/devtools_protocol/browser_protocol.pdl, which
// includes all cases except for kSuccess.
enum FederatedAuthRequestResult {
  kSuccess,
  kShouldEmbargo,
  kIdpNotPotentiallyTrustworthy,
  kDisabledInSettings,
  kDisabledInFlags,
  kTooManyRequests,
  kWellKnownHttpNotFound,
  kWellKnownNoResponse,
  kWellKnownInvalidResponse,
  kWellKnownListEmpty,
  kWellKnownInvalidContentType,
  kConfigNotInWellKnown,
  kWellKnownTooBig,
  kConfigHttpNotFound,
  kConfigNoResponse,
  kConfigInvalidResponse,
  kConfigInvalidContentType,
  kClientMetadataHttpNotFound,
  kClientMetadataNoResponse,
  kClientMetadataInvalidResponse,
  kClientMetadataInvalidContentType,
  kAccountsHttpNotFound,
  kAccountsNoResponse,
  kAccountsInvalidResponse,
  kAccountsListEmpty,
  kAccountsInvalidContentType,
  kIdTokenHttpNotFound,
  kIdTokenNoResponse,
  kIdTokenInvalidResponse,
  kIdTokenIdpErrorResponse,
  kIdTokenCrossSiteIdpErrorResponse,
  kIdTokenInvalidContentType,
  kCanceled,
  kRpPageNotVisible,
  kSilentMediationFailure,
  kThirdPartyCookiesBlocked,
  kNotSignedInWithIdp,
  kMissingTransientUserActivation,
  kReplacedByButtonMode,
  kInvalidFieldsSpecified,
  kRelyingPartyOriginIsOpaque,
  kTypeNotMatching,
  kError,
};

struct FederatedAuthRequestIssueDetails {
  FederatedAuthRequestResult status;
};

// Represents the fetch result from a getUserInfo() call. Should
// be updated alongside FederatedAuthUserInfoRequestIssueReason in
// third_party/blink/public/devtools_protocol/browser_protocol.pdl,
// which includes all cases except for kSuccess and kUnhandledRequest.
// Do not modify or reorder existing values, as this is used in metrics
// recording.
enum FederatedAuthUserInfoRequestResult {
  kSuccess,
  kNotSameOrigin,
  kNotIframe,
  kNotPotentiallyTrustworthy,
  kNoApiPermission,
  kNotSignedInWithIdp,
  kNoAccountSharingPermission,
  kInvalidConfigOrWellKnown,
  kInvalidAccountsResponse,
  kNoReturningUserFromFetchedAccounts,
  kUnhandledRequest
};

struct FederatedAuthUserInfoRequestIssueDetails {
  FederatedAuthUserInfoRequestResult status;
};

struct BounceTrackingIssueDetails {
  array<string> tracking_sites;
};

struct CookieDeprecationMetadataIssueDetails {
  array<string> allowed_sites;
  uint32 opt_out_percentage;
  bool is_opt_out_top_level;
  CookieOperation operation;
};

enum GenericIssueErrorType {
  kFormLabelForNameError,
  kFormDuplicateIdForInputError,
  kFormInputWithNoLabelError,
  kFormAutocompleteAttributeEmptyError,
  kFormEmptyIdAndNameAttributesForInputError,
  kFormAriaLabelledByToNonExistingId,
  kFormInputAssignedAutocompleteValueToIdOrNameAttributeError,
  kFormLabelHasNeitherForNorNestedInput,
  kFormLabelForMatchesNonExistingIdError,
  kFormInputHasWrongButWellIntendedAutocompleteValueError,
  kResponseWasBlockedByORB,
};

struct GenericIssueDetails {
  GenericIssueErrorType error_type;
  string? frame_id;
  // 0 is not a valid node id and is used to indicate absence.
  int32 violating_node_id = 0;
  string? violating_node_attribute;
};

enum DeprecationIssueType {
  kPrivacySandboxExtensionsAPI,
};

struct DeprecationIssueDetails {
  DeprecationIssueType type;
  AffectedLocation affected_location;
};

// A collection of optional fields that may store additional data depending
// on the issue code.
struct InspectorIssueDetails {
  CookieIssueDetails? cookie_issue_details;
  MixedContentIssueDetails? mixed_content_issue_details;
  BlockedByResponseIssueDetails? blocked_by_response_issue_details;
  ContentSecurityPolicyIssueDetails? csp_issue_details;
  SharedArrayBufferIssueDetails? sab_issue_details;
  HeavyAdIssueDetails? heavy_ad_issue_details;
  AttributionReportingIssueDetails? attribution_reporting_issue_details;
  LowTextContrastIssue? low_text_contrast_details;
  FederatedAuthRequestIssueDetails? federated_auth_request_details;
  BounceTrackingIssueDetails? bounce_tracking_issue_details;
  CookieDeprecationMetadataIssueDetails? cookie_deprecation_metadata_issue_details;
  GenericIssueDetails? generic_issue_details;
  DeprecationIssueDetails? deprecation_issue_details;
  FederatedAuthUserInfoRequestIssueDetails? federated_auth_user_info_request_details;
  mojo_base.mojom.UnguessableToken? issue_id;
};

struct InspectorIssueInfo {
  InspectorIssueCode code;
  InspectorIssueDetails details;
};