From cfb20f5ace19e753d773877d76204bf9217214ef Mon Sep 17 00:00:00 2001
From: Noam Rosenthal RequestCredentials
enumerationRequestDestination
enumerationfetch()
method
If el's href
attribute's value is the
- empty string, then return.
Parse a URL given el's href
- attribute, relative to el's node document. If that fails, then return.
- Otherwise, let url be the resulting URL record.
Let corsAttributeState be the current state of el's crossorigin
content attribute.
Let request be the result of creating a link
element request given el.
Let request be the result of creating a potential-CORS request given - url, the empty string, and corsAttributeState.
If request is null, then return.
Set request's synchronous flag.
Set request's client to - el's node document's relevant settings object.
Set request's cryptographic - nonce metadata to the current value of el's [[CryptographicNonce]] - internal slot.
Set request's integrity
- metadata to the current value of el's integrity
content attribute.
Set request's
- referrer policy to the current state of
- el's referrerpolicy
attribute.
Run the linked resource fetch setup steps, given el and request. If the result is false, then return.
To create a link
element request
+ given a link
element el and an optional string destination
+ (default the empty string):
If el's href
attribute's value is the
+ empty string, then return null.
Parse a URL given el's href
+ attribute, relative to el's node document. If that fails, then return
+ null. Otherwise, let url be the resulting URL record.
Let corsAttributeState be the current state of el's crossorigin
content attribute.
Let request be the result of creating a potential-CORS request given url, destination, + and corsAttributeState.
Set request's client to + el's node document's relevant settings object.
Set request's cryptographic + nonce metadata to the current value of el's + [[CryptographicNonce]] internal slot.
Set request's integrity
+ metadata to the current value of el's integrity
content attribute.
Set request's referrer
+ policy to the current state of el's referrerpolicy
content attribute.
Return request.
User agents may opt to only try to fetch and process such resources when they are needed, instead of pro-actively fetching all the external resources that are not applied.
@@ -25425,24 +25442,89 @@ document.body.appendChild(wbr); elements. This keyword creates an external resource link. This keyword is body-ok. -The preload
keyword indicates that the user agent must
+
The preload
keyword indicates that the user agent will
preemptively fetch and cache the specified resource according
to the potential destination given by the
as
attribute (and the priority associated with the corresponding destination), as it is highly likely that the user
- will require this resource for the current navigation. User agents must implement
- the processing model of the preload
keyword described in
- Preload, as well as in this specification's fetch and process the linked
- resource algorithm.
There is no default type for resources given by the preload
keyword.
The linked resource fetch setup steps for this type of linked resource, given a
- link
element el and request
- request, are:
A Document
has a map of preloaded resources, which is a
+ map, initially empty.
A preload key is a struct. It has the following items:
+ +same-origin
", "cors
", or
+ "no-cors
"
+
+ A preload entry is a struct. It has the following items:
+ +To consume a preloaded resource for Window
window,
+ given a URL url, a string destination, a string
+ mode, a string credentialsMode, a string integrityMetadata, and
+ onResponseAvailable, which is an algorithm accepting a response:
Let key be a preload key whose URL is url, destination is + destination, integrity metadata is + integrityMetadata, mode is mode, and + credentials mode is + credentialsMode.
Let preloads be window's associated Document
's map of
+ preloaded resources.
If key does not exist in preloads, + then return false.
Let entry be preloads[key].
Remove preloads[key].
If entry response is null, then set + entry's on response available to + onResponseAvailable.
Otherwise, call onResponseAvailable with entry's response.
Return true.
The fetch and process the linked resource steps for this type of linked resource,
+ given a link
element el, are:
Let as be the current state of el's If as does not represent a state, return false. Set request's destination to
- the result of translating
- as. Let request be the result of creating a If request is null, then return. If as is "
link
element request given el and the result
+ of translating
+ as.image
", then:
Return true.
Let preloadKey be a preload key whose URL is request's URL, destination is request's destination, integrity metadata is request's integrity metadata, mode is request's mode, and + credentials mode is request's credentials mode.
Let preloadEntry be a new preload entry.
Set el's node document's map + of preloaded resources[preloadKey] to preloadEntry.
Fetch request, with processResponseEndOfBody set to the following steps given + response response and null or byte + sequence bytesOrNull:
+ +If bytesOrNull is a byte sequence, then set response's + body to the first return value of safely extracting bytesOrNull.
+ +By using processResponseEndOfBody, we + have extracted the entire body. This is necessary to ensure the preloader loads + the entire body from the network, regardless of whether the preload will be consumed (which + is uncertain at this point). This step then resets the request's body to a new body + containing the same bytes, so that other specifications can read from it at the time of + actual consumption, despite us having already done so once.
+Otherwise, set response to a network error.
Finalize and report timing with response, given el's
+ relevant global object and "link
".
Fire an event named load
at el.
If preloadEntry's on response + available is null, then set preloadEntry's response to response.
Otherwise, call preloadEntry's on response available with response.