CDPotion.Domain.Preload (cdpotion v0.1.4)

Summary

Types

TODO(https://crbug.com/1384419): revisit the list of PrefetchStatus and filter out the ones that aren't necessary to the developers.

A key that identifies a preloading attempt.

Lists sources for a preloading attempt, specifically the ids of rule sets that had a speculation rule that triggered the attempt, and the BackendNodeIds of <a href> or <area href> elements that triggered the attempt (in the case of attempts triggered by a document rule). It is possible for mulitple rule sets and links to trigger a single attempt.

Preloading status values, see also PreloadingTriggeringOutcome. This status is shared by prefetchStatusUpdated and prerenderStatusUpdated.

List of FinalStatus reasons for Prerender2.

Corresponds to SpeculationRuleSet

description not provided :(

Unique id

The type of preloading attempted. It corresponds to mojom::SpeculationAction (although PrefetchWithSubresources is omitted as it isn't being used by clients).

Types

Link to this type

prefetch_status()

@type prefetch_status() ::
  :PrefetchAllowed
  | :PrefetchFailedIneligibleRedirect
  | :PrefetchFailedInvalidRedirect
  | :PrefetchFailedMIMENotSupported
  | :PrefetchFailedNetError
  | :PrefetchFailedNon2XX
  | :PrefetchFailedPerPageLimitExceeded
  | :PrefetchEvicted
  | :PrefetchHeldback
  | :PrefetchIneligibleRetryAfter
  | :PrefetchIsPrivacyDecoy
  | :PrefetchIsStale
  | :PrefetchNotEligibleBrowserContextOffTheRecord
  | :PrefetchNotEligibleDataSaverEnabled
  | :PrefetchNotEligibleExistingProxy
  | :PrefetchNotEligibleHostIsNonUnique
  | :PrefetchNotEligibleNonDefaultStoragePartition
  | :PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy
  | :PrefetchNotEligibleSchemeIsNotHttps
  | :PrefetchNotEligibleUserHasCookies
  | :PrefetchNotEligibleUserHasServiceWorker
  | :PrefetchNotEligibleBatterySaverEnabled
  | :PrefetchNotEligiblePreloadingDisabled
  | :PrefetchNotFinishedInTime
  | :PrefetchNotStarted
  | :PrefetchNotUsedCookiesChanged
  | :PrefetchProxyNotAvailable
  | :PrefetchResponseUsed
  | :PrefetchSuccessfulButNotUsed
  | :PrefetchNotUsedProbeFailed

TODO(https://crbug.com/1384419): revisit the list of PrefetchStatus and filter out the ones that aren't necessary to the developers.

Link to this type

preloading_attempt_key()

@type preloading_attempt_key() :: %{
  action: speculation_action(),
  loaderId: CDPotion.Domain.Network.loader_id(),
  targetHint: speculation_target_hint() | nil,
  url: String.t()
}

A key that identifies a preloading attempt.

The url used is the url specified by the trigger (i.e. the initial URL), and not the final url that is navigated to. For example, prerendering allows same-origin main frame navigations during the attempt, but the attempt is still keyed with the initial URL.

Link to this type

preloading_attempt_source()

@type preloading_attempt_source() :: %{
  key: preloading_attempt_key(),
  nodeIds: [CDPotion.Domain.DOM.backend_node_id()],
  ruleSetIds: [rule_set_id()]
}

Lists sources for a preloading attempt, specifically the ids of rule sets that had a speculation rule that triggered the attempt, and the BackendNodeIds of <a href> or <area href> elements that triggered the attempt (in the case of attempts triggered by a document rule). It is possible for mulitple rule sets and links to trigger a single attempt.

Link to this type

preloading_status()

@type preloading_status() ::
  :Pending | :Running | :Ready | :Success | :Failure | :NotSupported

Preloading status values, see also PreloadingTriggeringOutcome. This status is shared by prefetchStatusUpdated and prerenderStatusUpdated.

Link to this type

prerender_final_status()

@type prerender_final_status() ::
  :Activated
  | :Destroyed
  | :LowEndDevice
  | :InvalidSchemeRedirect
  | :InvalidSchemeNavigation
  | :InProgressNavigation
  | :NavigationRequestBlockedByCsp
  | :MainFrameNavigation
  | :MojoBinderPolicy
  | :RendererProcessCrashed
  | :RendererProcessKilled
  | :Download
  | :TriggerDestroyed
  | :NavigationNotCommitted
  | :NavigationBadHttpStatus
  | :ClientCertRequested
  | :NavigationRequestNetworkError
  | :MaxNumOfRunningPrerendersExceeded
  | :CancelAllHostsForTesting
  | :DidFailLoad
  | :Stop
  | :SslCertificateError
  | :LoginAuthRequested
  | :UaChangeRequiresReload
  | :BlockedByClient
  | :AudioOutputDeviceRequested
  | :MixedContent
  | :TriggerBackgrounded
  | :MemoryLimitExceeded
  | :FailToGetMemoryUsage
  | :DataSaverEnabled
  | :HasEffectiveUrl
  | :ActivatedBeforeStarted
  | :InactivePageRestriction
  | :StartFailed
  | :TimeoutBackgrounded
  | :CrossSiteRedirectInInitialNavigation
  | :CrossSiteNavigationInInitialNavigation
  | :SameSiteCrossOriginRedirectNotOptInInInitialNavigation
  | :SameSiteCrossOriginNavigationNotOptInInInitialNavigation
  | :ActivationNavigationParameterMismatch
  | :ActivatedInBackground
  | :EmbedderHostDisallowed
  | :ActivationNavigationDestroyedBeforeSuccess
  | :TabClosedByUserGesture
  | :TabClosedWithoutUserGesture
  | :PrimaryMainFrameRendererProcessCrashed
  | :PrimaryMainFrameRendererProcessKilled
  | :ActivationFramePolicyNotCompatible
  | :PreloadingDisabled
  | :BatterySaverEnabled
  | :ActivatedDuringMainFrameNavigation
  | :PreloadingUnsupportedByWebContents
  | :CrossSiteRedirectInMainFrameNavigation
  | :CrossSiteNavigationInMainFrameNavigation
  | :SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation
  | :SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation
  | :MemoryPressureOnTrigger
  | :MemoryPressureAfterTriggered
  | :PrerenderingDisabledByDevTools
  | :ResourceLoadBlockedByClient
  | :SpeculationRuleRemoved
  | :ActivatedWithAuxiliaryBrowsingContexts

List of FinalStatus reasons for Prerender2.

@type rule_set() :: %{
  backendNodeId: CDPotion.Domain.DOM.backend_node_id() | nil,
  errorMessage: String.t() | nil,
  errorType: rule_set_error_type() | nil,
  id: rule_set_id(),
  loaderId: CDPotion.Domain.Network.loader_id(),
  requestId: CDPotion.Domain.Network.request_id() | nil,
  sourceText: String.t(),
  url: String.t() | nil
}

Corresponds to SpeculationRuleSet

Link to this type

rule_set_error_type()

@type rule_set_error_type() :: :SourceIsNotJsonObject | :InvalidRulesSkipped

description not provided :(

Link to this type

rule_set_id()

@type rule_set_id() :: String.t()

Unique id

Link to this type

speculation_action()

@type speculation_action() :: :Prefetch | :Prerender

The type of preloading attempted. It corresponds to mojom::SpeculationAction (although PrefetchWithSubresources is omitted as it isn't being used by clients).

Link to this type

speculation_target_hint()

@type speculation_target_hint() :: :Blank | :Self

Corresponds to mojom::SpeculationTargetHint. See https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints

Functions

@spec disable() :: {String.t(), map()}
@spec enable() :: {String.t(), map()}