diff --git a/source b/source index b8c59eac9a8..000ecd9931f 100644 --- a/source +++ b/source @@ -12743,7 +12743,6 @@ interface DOMStringMap {
A head element followed by a body element.
Content attributes:
Global attributes
-
manifest
Accessibility considerations:
For authors.
@@ -12767,32 +12766,6 @@ interface HTMLHtmlElement : HTMLElement { determine what pronunciations to use, translation tools to determine what rules to use, and so forth.

-

The manifest - attribute gives the address of the document's application cache manifest, if there is one. If the attribute is present, - the attribute's value must be a valid non-empty URL potentially surrounded by - spaces.

- -

The manifest attribute is part of the - legacy "offline web applications" feature, which is in the process of being - removed from the web platform. (This is a long process that takes many years.) Using the manifest attribute at this time is highly discouraged. Use - service workers instead.

- -

The manifest attribute only has an effect during the early stages of document load. - Changing the attribute dynamically thus has no effect (and thus, no DOM API is provided for this - attribute).

- -

For the purposes of application cache - selection, later base elements cannot affect the parsing of URLs in manifest attributes, as - the attributes are processed before those elements are seen.

- -

The window.applicationCache IDL - attribute provides scripted access to the offline application cache mechanism.

- -

The html element in the following example declares that the document's language @@ -31371,10 +31344,6 @@ interface HTMLObjectElement : HTMLElement { document until the task that is queued by the networking task source once the resource has been fetched (defined next) has been run.

- -

For the purposes of the application cache networking model, this fetch - operation is not for a child browsing context (though it might end up being used - for one after all, as defined below).

  • If the resource is not yet available (e.g. because the resource was not available in the @@ -31623,16 +31592,6 @@ interface HTMLObjectElement : HTMLElement {

    The object element represents its nested browsing context.

    -

    In certain situations, e.g., if the resource was fetched from an - application cache but it is an HTML file with a manifest attribute that points to a different application cache manifest, the navigation of the browsing context will be restarted - so as to load the resource afresh from the network or a different application - cache. Even if the resource is then found to have a different type, it is still used - as part of a browsing context: only the navigate algorithm is - restarted, not this object algorithm.

    - @@ -78691,7 +78650,6 @@ interface Window : EventTarget { // the user agent readonly attribute Navigator navigator; - [SecureContext] readonly attribute ApplicationCache applicationCache; readonly attribute boolean originIsolated; // user prompts @@ -84367,31 +84325,6 @@ interface Location { // but see also GET`, and there are - relevant application caches that are - identified by a URL with the same origin as the URL in question, and that have - this URL as one of their entries, excluding entries marked as foreign, and whose mode is fast, and the user agent is not in a mode where it - will avoid using application caches - -
    -

    Fetch resource from the most - appropriate application cache of those that match.

    - -

    For example, imagine an HTML page with an associated application cache - displaying an image and a form, where the image is also used by several other application - caches. If the user right-clicks on the image and chooses "View Image", then the user agent - could decide to show the image from any of those caches, but it is likely that the most useful - cache for the user would be the one that was used for the aforementioned HTML page. On the - other hand, if the user submits the form, and the form does a POST submission, then the user - agent will not use an application cache at all; the submission will be made to the - network.

    - -

    This still needs to be integrated with the Fetch standard.

    -
    -
    If resource is a request whose url's scheme is a fetch scheme
    @@ -84651,63 +84584,6 @@ interface Location { // but see also
    location URL and browsingContext, and return.

  • -
  • -

    Fallback in prefer-online mode: If response was not fetched from - an application cache, and was to be fetched using `GET`, and - there are relevant application caches that are - identified by a URL with the same origin as the URL in question, and that have this - URL as one of their entries, excluding entries marked as foreign, and whose mode is prefer-online, and the user didn't cancel - the navigation attempt during the earlier step, and response is either a network - error or its status is not an ok - status, then:

    - -

    Let candidate be the response identified by the URL in question from the - most appropriate application cache of those that - match.

    - -

    If candidate is not marked as foreign, then the user agent must discard the failed - load and instead continue along these steps using candidate as response. - The user agent may indicate to the user that the original page load failed, and that the page - used was a previously cached response.

    -
  • - -
  • -

    Fallback for fallback entries: If response was not fetched from - an application cache, and was to be fetched using `GET`, and - its URL matches the fallback namespace - of one or more relevant application caches, and - the most appropriate application cache of those - that match does not have an entry in its online - safelist that has the same origin as response's URL and that is a - prefix match for response's URL, and the user didn't cancel the - navigation attempt during the earlier step, and response is either a network error or - its status is not an ok status, - then:

    - - -

    Let candidate be the fallback - response specified for the fallback - namespace in question. If multiple application caches match, the user agent must use the - fallback of the most appropriate application - cache of those that match.

    - -

    If candidate is not marked as foreign, then the user agent must discard the failed - load and instead continue along these steps using candidate as response. - The document's URL, if appropriate, will still be the - originally requested URL, not the fallback URL, but the user agent may indicate to the user that - the original page load failed, that the page used was a fallback response, and what the URL of - the fallback response actually is.

    -
  • -
  • Let navigationParams be a new navigation params whose request is request, response is response, Location { // but see also text/cache-manifest"

    "text/css"
    "text/plain"
    "text/vtt"
    @@ -85387,9 +85262,6 @@ new PaymentRequest(…); // Allowed to use before the parser stops, the user agent must update the session history with the new page given navigationParams.

    -

    Application cache selection happens in the HTML parser.

    -

    Page load processing model for XML files

    @@ -85412,28 +85284,6 @@ new PaymentRequest(…); // Allowed to use encoding is established, the document's character encoding must be set to that character encoding.

    -

    If the document element, as parsed according to XML cited - above, is found to be an html element with an attribute manifest whose value is not the empty string, then, as soon as - the element is inserted into the document, - the user agent must parse the value of that attribute relative - to that element's node document, and if that is successful, must apply the URL serializer algorithm to the resulting URL - record with the exclude fragment flag set to obtain manifest URL, and - then run the application cache selection algorithm - with manifest URL as the manifest URL, passing in the newly-created - Document. Otherwise, if the attribute is absent, its value is the empty string, or - parsing its value fails, then as soon as the document element is inserted into the document, the user agent must run the application cache selection algorithm with no manifest, and - passing in the Document.

    - -

    Because the processing of the manifest - attribute happens only once the document element is parsed, any URLs referenced by - processing instructions before the document element (such as <?xml-stylesheet?> PIs) will be fetched from the network and cannot be - cached.

    -

    Then, with the newly created Document, the user agent must update the session history with the new page given navigationParams. User agents may do this before the complete document has been parsed (thus achieving incremental rendering), @@ -85473,10 +85323,6 @@ new PaymentRequest(…); // Allowed to use

    The document's character encoding must be set to the character encoding used to decode the document.

    -

    Upon creation of the Document object, the user agent must run the application cache selection algorithm with no manifest, and - passing in the newly-created Document.

    - @@ -85574,10 +85420,6 @@ new PaymentRequest(…); // Allowed to use

    Then, the user agent must act as if it had stopped parsing.

    -

    Upon creation of the Document object, the user agent must run the application cache selection algorithm with no manifest, and - passing in the newly-created Document.

    -

    After creating the Document object, but potentially before the page has finished fully loading, the user agent must update the session history with the new page given navigationParams.

    @@ -85623,10 +85465,6 @@ new PaymentRequest(…); // Allowed to use

    Then, the user agent must act as if it had stopped parsing.

    -

    Upon creation of the Document object, the user agent must run the application cache selection algorithm with no manifest, and - passing in the newly-created Document.

    -

    After creating the Document object, but potentially before the page has finished fully loading, the user agent must update the session history with the new page given navigationParams.

    @@ -85683,10 +85521,6 @@ new PaymentRequest(…); // Allowed to use

    Once the page has been set up, the user agent must act as if it had stopped parsing.

    -

    Upon creation of the Document object, the user agent must run the application cache selection algorithm with no manifest, - passing in the newly-created Document.

    -

    After creating the Document object, but potentially before the page has been completely set up, the user agent must update the session history with the new page given navigationParams.

    @@ -85943,8 +85777,8 @@ new PaymentRequest(…); // Allowed to use
  • -
  • Set the active document of the browsing - context to newDocument.

  • +
  • Set the active document of the browsing context to + newDocument.

  • If entry's browsing context name is not null, @@ -86799,2878 +86633,546 @@ interface BeforeUnloadEvent : Event { -

    Offline web applications

    - -

    This feature is in the process of being removed from the web platform. (This - is a long process that takes many years.) Using any of the offline web application features at - this time is highly discouraged. Use service workers instead.

    - - +

    Scripting

    Introduction

    - - -

    In order to enable users to continue interacting with web applications and documents even when - their network connection is unavailable — for instance, because they are traveling outside - of their ISP's coverage area — authors can provide a manifest which lists the files that are - needed for the web application to work offline and which causes the user's browser to keep a copy - of the files for use offline.

    - -

    To illustrate this, consider a simple clock applet consisting of an HTML page "clock1.html", a CSS style sheet "clock.css", and a - JavaScript script "clock.js".

    - -

    Before adding the manifest, these three files might look like this:

    - -
    EXAMPLE offline/clock/clock1.html
    -
    EXAMPLE offline/clock/clock.css
    -
    EXAMPLE offline/clock/clock.js
    - -

    If the user tries to open the "clock1.html" page while offline, though, - the user agent (unless it happens to have it still in the local cache) will fail with an - error.

    - -

    The author can instead provide a manifest of the three files, say "clock.appcache":

    - -
    EXAMPLE offline/clock/clock.appcache
    - -

    With a small change to the HTML file, the manifest (served as text/cache-manifest) - is linked to the application:

    - -
    EXAMPLE offline/clock/clock2.html
    - -

    Now, if the user goes to the page, the browser will cache the files and make them available - even when the user is offline.

    - -

    Authors are encouraged to include the main page in the manifest also, but in - practice the page that referenced the manifest is automatically cached even if it isn't explicitly - mentioned.

    - -

    With the exception of "no-store" directive, HTTP cache headers and restrictions on - caching pages served over TLS (encrypted, using https:) are - overridden by manifests. Thus, pages will not expire from an application cache before the user - agent has updated it, and even applications served over TLS can be made to work offline.

    - -

    View this example online.

    +

    Various mechanisms can cause author-provided executable code to run in the context of a + document. These mechanisms include, but are probably not limited to:

    + -

    Legacy applications, however, tend to be designed so that the user data and the logic are mixed - together in the HTML, with each operation resulting in a new HTML page from the server.

    +

    Agents and agent clusters

    -
    +
    Integration with the JavaScript agent formalism
    -

    For example, consider a news application. The typical architecture of such an application, - when not using the application cache feature, is that the user fetches the main page, and the - server returns a dynamically-generated page with the current headlines and the user interface - logic mixed together.

    +

    JavaScript defines the concept of an agent. This section gives the mapping of that + language-level concept on to the web platform.

    -

    A news application designed for the application cache feature, however, would instead have the - main page just consist of the logic, and would then have the main page fetch the data separately - from the server, e.g. using XMLHttpRequest.

    +
    +

    Conceptually, the agent concept is an architecture-independent, idealized + "thread" in which JavaScript code runs. Such code can involve multiple globals/realms that can synchronously access each other, and + thus needs to run in a single execution thread.

    +

    Two Window objects having the same agent does not indicate + they can directly access all objects created in each other's realms. They would have to be + same origin-domain; see IsPlatformObjectSameOrigin.

    -

    The mixed-content model does not work well with the application cache feature: since the - content is cached, it would result in the user always seeing the stale data from the previous time - the cache was updated.

    +

    The following types of agents exist on the web platform:

    -

    While there is no way to make the legacy model work as fast as the separated model, it - can at least be retrofitted for offline use using the prefer-online application cache mode. To do so, list all the static - resources used by the HTML page you want to have work offline in an application cache manifest, use the manifest attribute to select that manifest from the HTML file, - and then add the following line at the bottom of the manifest:

    +
    +
    Similar-origin window agent
    +
    +

    Contains various Window objects which can potentially reach each other, either + directly or by using document.domain.

    -
    SETTINGS:
    -prefer-online
    -NETWORK:
    -*
    +

    If the encompassing agent cluster's cross-origin isolated is true, + then all the Window objects will be same origin, can reach each other + directly, and document.domain will no-op.

    -

    This causes the application cache to only be used for primary entries when the user is offline, and causes the - application cache to be used as an atomic HTTP cache (essentially pinning resources listed in the - manifest), while allowing all resources not listed in the manifest to be accessed normally when - the user is online.

    +

    Two Window objects that are same origin can be in + different similar-origin window agents, for + instance if they are each in their own browsing context group.

    +
    +
    Dedicated worker agent
    +

    Contains a single DedicatedWorkerGlobalScope.

    +
    Shared worker agent
    +

    Contains a single SharedWorkerGlobalScope.

    -
    Events summary
    +
    Service worker agent
    +

    Contains a single ServiceWorkerGlobalScope.

    - +
    Worklet agent
    +
    +

    Contains a single WorkletGlobalScope object.

    -

    When the user visits a page that declares a manifest, the browser will try to update the cache. - It does this by fetching a copy of the manifest and, if the manifest has changed since the user - agent last saw it, redownloading all the resources it mentions and caching them anew.

    +

    Although a given worklet can have multiple realms, each such realm needs its own + agent, as each realm can be executing code independently and at the same time as the others.

    +
    +
    -

    As this is going on, a number of events get fired on the ApplicationCache object - to keep the script updated as to the state of the cache update, so that the user can be notified - appropriately. The events are as follows:

    +

    Only shared and dedicated worker agents allow the use of JavaScript Atomics APIs to + potentially block.

    - - - - +
    -
    - - - - - - - - - - -
    Event name - Interface - Fired when... - Next events -
    checking - Event - The user agent is checking for an update, or attempting to download the manifest for the - first time. This is always the first event in the sequence. - noupdate, downloading, obsolete, error +

    To create an agent, given a boolean canBlock:

    -
    noupdate - Event - The manifest hadn't changed. - Last event in sequence. +
      +
    1. Let signifier be a new unique internal value.

    2. -
    downloading - Event - The user agent has found an update and is fetching it, or is downloading the resources - listed by the manifest for the first time. - progress, error, cached, updateready - -
    progress - ProgressEvent - The user agent is downloading resources listed by the manifest. - The event object's total attribute returns the total number of files to be downloaded. - The event object's loaded attribute returns the number of files processed so far. - progress, error, cached, updateready - -
    cached - Event - The resources listed in the manifest have been downloaded, and the application is now cached. - Last event in sequence. +
  • Let candidateExecution be a new candidate execution.

  • -
    updateready - Event - The resources listed in the manifest have been newly redownloaded, and the script can use - swapCache() to switch to the new cache. - Last event in sequence. +
  • Let agent be a new agent whose [[CanBlock]] is + canBlock, [[Signifier]] is signifier, [[CandidateExecution]] is + candidateExecution, and [[IsLockFree1]], [[IsLockFree2]], and [[LittleEndian]] are set + at the implementation's discretion.

  • -
    obsolete - Event - The manifest was found to have become a 404 or 410 page, so the application cache is being deleted. - Last event in sequence. +
  • Set agent's event loop to a new + event loop.

  • -
    error - Event - The manifest was a 404 or 410 page, so the attempt to cache the application has been aborted. - Last event in sequence. +
  • Return agent.

  • + -
    The manifest hadn't changed, but the page referencing the manifest failed to download properly. +

    The relevant agent for a platform object + platformObject is platformObject's relevant Realm's agent. This pointer is not yet defined in the JavaScript specification; see tc39/ecma262#1357.

    -
    A fatal error occurred while fetching the resources listed in the manifest. +

    The agent equivalent of the current Realm Record is the + surrounding agent.

    -
    The manifest changed while the update was being run. - The user agent will try fetching the files again momentarily. + -
    +
    Integration with the JavaScript agent cluster formalism
    -

    These events are cancelable; their default action is for the user agent to show download - progress information. If the page shows its own update UI, canceling the events will prevent the - user agent from showing redundant progress information.

    +

    JavaScript also defines the concept of an agent cluster, which this standard maps + to the web platform by placing agents appropriately when they are created using the + obtain a similar-origin window agent or + obtain a worker/worklet agent + algorithms.

    +

    The agent cluster concept is crucial for defining the JavaScript memory model, and + in particular among which agents the backing data of + SharedArrayBuffer objects can be shared.

    +

    Conceptually, the agent cluster concept is an + architecture-independent, idealized "process boundary" that groups together multiple "threads" + (agents). The agent clusters + defined by the specification are generally more restrictive than the actual process boundaries + implemented in user agents. By enforcing these idealized divisions at the specification level, we + ensure that web developers see interoperable behavior with regard to shared memory, even in the + face of varying and changing user agent process models.

    -

    Application caches

    - -

    An application cache is a set of cached resources consisting of:

    - -
      - -
    • -

      One or more resources (including their out-of-band metadata, such as HTTP headers, if any), - identified by URLs, each falling into one (or more) of the following categories:

      - -
      -
      Primary entries +

      An agent cluster has an associated cross-origin isolated (a boolean), + which is initially false.

      -

      These are documents that were added to the cache because a browsing - context was navigated to that document and the document - indicated that this was its cache, using the manifest - attribute.

      +

      An agent cluster has an associated origin-isolated (a boolean), which + is initially false.

      +
      -
      The manifest +

      The following defines the allocation of the agent clusters + of similar-origin window agents.

      -

      This is the resource corresponding to the URL that was given in a primary - entry's html element's manifest attribute. - The manifest is fetched and processed during the application cache download - process. All the primary entries have the - same origin as the manifest.

      +

      An agent cluster key is a site or tuple origin. Without web developer action to achieve origin isolation, it will be a site.

      +

      An equivalent formulation is that an agent cluster key can be a + scheme-and-host or an origin.

      -
      Explicit entries +

      To obtain a similar-origin window agent, + given an origin origin, a browsing context group + group, and a boolean requestsOI, run these steps:

      -

      These are the resources that were listed in the cache's manifest in an explicit section.

      +
        +
      1. Let site be the result of obtaining a site + with origin.

      2. +
      3. Let key be site.

      4. -
        Fallback entries +
      5. If group's cross-origin + isolated is true, then set key to origin.

      6. -

        These are the resources that were listed in the cache's manifest in a fallback section.

        +
      7. Otherwise, if group's historical agent cluster key + map[origin] exists, then set key to + group's historical agent cluster key map[origin].

      8. -
      +
    • +

      Otherwise:

      -

      Explicit entries and Fallback entries can be marked as foreign, which means that they have a manifest attribute but that it doesn't point at this cache's - manifest.

      +
        +
      1. If requestsOI is true, then set key to origin.

      2. -

        A URL in the list can be flagged with multiple different types, and thus an - entry can end up being categorized as multiple entries. For example, an entry can be a manifest - entry and an explicit entry at the same time, if the manifest is listed within the manifest.

        +
      3. Set group's historical agent cluster key map[origin] + to key.

      4. +
    • -

      Zero or more fallback namespaces, each of - which is mapped to a fallback entry.

      - -

      These are URLs used as prefix - match patterns for resources that are to be fetched from the network if possible, or to - be replaced by the corresponding fallback entry - if not. Each namespace URL has the same origin as the manifest.

      -
    • +

      If group's agent cluster map[key] does not exist, then:

      -
    • -

      Zero or more URLs that form the online - safelist namespaces.

      +
        +
      1. Let agentCluster be a new agent cluster.

      2. -

        These are used as prefix match patterns, and declare URLs for which the user - agent will ignore the application cache, instead fetching them normally (i.e. from the network - or local HTTP cache as appropriate).

        - +
      3. Set agentCluster's cross-origin isolated to group's + cross-origin isolated.

      4. -
      5. -

        An online safelist wildcard - flag, which is either open or blocking.

        +
      6. Set agentCluster's origin-isolated to true if key + equals origin; otherwise false.

      7. -

        The open state indicates that any URL not listed as cached is to - be implicitly treated as being in the online - safelist namespaces; the blocking state indicates that URLs not listed - explicitly in the manifest are to be treated as unavailable.

        - +
      8. Add the result of creating an agent, given false, + to agentCluster.

      9. -
      10. -

        A cache mode flag, which is either in the fast state or the prefer-online state.

        +
      11. Set group's agent cluster map[key] to + agentCluster.

      12. +
    • -
    +
  • Return the single similar-origin window agent contained in group's + agent cluster map[key].

  • + -

    Each application cache has a completeness flag, which is either complete or - incomplete.

    +

    This means that there is only one similar-origin window agent per + browsing context agent cluster. (However, dedicated + worker and worklet agents might be in the same + cluster.)


    -

    An application cache group is a group of application - caches, identified by the absolute URL of a resource manifest which is used to populate the caches in the - group.

    - -

    An application cache is newer than - another if it was created after the other (in other words, application caches in an application cache group have a chronological - order).

    +

    The following defines the allocation of the agent clusters + of all other types of agents.

    -

    Only the newest application cache in an application cache group can - have its completeness flag set to - incomplete; the others are always all complete.

    +

    To obtain a worker/worklet agent, given an + environment settings object or null outside settings, a boolean + isTopLevel, and a boolean canBlock, run these steps:

    -

    Each application cache group has an update - status, which is one of the following: idle, checking, downloading.

    +
      +
    1. Let agentCluster be null. -

      A relevant application cache is an application cache that is the newest in its group to be complete.

      +
    2. +

      If isTopLevel is true, then:

      -

      Each application cache group has a list of pending primary entries. Each entry in this - list consists of a resource and a corresponding Document object. It is used during - the application cache download process to ensure that new primary entries are cached - even if the application cache download process was already running for their - application cache group when they were loaded.

      +
        +
      1. Set agentCluster to a new agent cluster.

      2. -

        An application cache group can be marked as obsolete, meaning that it must be ignored when looking at - what application cache groups exist.

        +
      3. +

        Set agentCluster's origin-isolated to true.

        -
        +

        These workers can be considered to be origin-isolated. However, this is not + exposed through any APIs (in the way that originIsolated exposes the origin-isolation state for + windows).

        +
      4. +
      +
    3. -

      A cache host is a Document object.

      +
    4. +

      Otherwise:

      -

      Each cache host has an associated ApplicationCache object.

      +
        +
      1. Assert: outside settings is not null.

      2. -

        Each cache host initially is not associated with an application - cache, but can become associated with one early during the page load process, when steps in the parser and in the navigation - sections cause cache selection to occur.

        +
      3. Let ownerAgent be outside settings's Realm's agent.

      4. -
        +
      5. Set agentCluster to the agent cluster which contains + ownerAgent.

      6. +
      +
    5. -

      Multiple application caches in different application cache groups can contain the same resource, - e.g. if the manifests all reference that resource. If the user agent is to select an application cache from a list of relevant application caches that contain a resource, the - user agent must use the application cache that the user most likely wants to see the resource - from, taking into account the following:

      +
    6. Let agent be the result of creating an + agent given canBlock.

    7. -
    -
  • which application cache was being used to display the resource from which the user decided to - look at the new resource, and +

    To obtain a dedicated/shared worker agent, given an environment settings + object outside settings and a boolean isShared, return the result of + obtaining a worker/worklet agent given outside settings, + isShared, and true.

    -
  • which application cache the user prefers. +

    To obtain a worklet agent, given an environment settings object + outside settings, return the result of obtaining a worker/worklet agent + given outside settings, false, and false.

    - +

    To obtain a service worker agent, return the result of obtaining a + worker/worklet agent given null, true, and false.


    -

    A URL matches a fallback namespace if - there exists a relevant application cache whose manifest's URL has the same origin as the - URL in question, and that has a fallback - namespace that is a prefix match for the URL being examined. If multiple - fallback namespaces match the same URL, the longest one is the one that matches. A URL looking for - a fallback namespace can match more than one application cache at a time, but only matches one - namespace in each cache.

    - -
    - -

    If a manifest https://example.com/app1/manifest declares that https://example.com/resources/images is a fallback namespace, and the user - navigates to https://example.com:80/resources/images/cat.png, then the user - agent will decide that the application cache identified by https://example.com/app1/manifest contains a namespace with a match for that - URL.

    - - - -
    -
  • +
    +

    The following pairs of global objects are each within the same agent cluster, and + thus can use SharedArrayBuffer instances to share memory with each other:

    + -# these are files that need to be cached they can either be listed -# first, or a "CACHE:" header could be put before them, as is done -# lower down. -images/sound-icon.png -images/background.png -# note that each file has to be put on its own line +

    The following pairs of global objects are not within the same agent + cluster, and thus cannot share memory:

    -# here is a file for the online safelist -- it isn't cached, and -# references to this file will bypass the cache, always hitting the -# network (or trying to, if the user is offline). -NETWORK: -comm.cgi +
    -
    +
    -

    Offline application cache manifests can use absolute paths or even absolute URLs:

    +

    Realms and their counterparts

    + +

    The JavaScript specification introduces the realm + concept, representing a global environment in which script is run. Each realm comes with an + implementation-defined global object; much of this specification is + devoted to defining that global object and its properties.

    -
    CACHE MANIFEST
    +  

    For web specifications, it is often useful to associate values or algorithms with a + realm/global object pair. When the values are specific to a particular type of realm, they are + associated directly with the global object in question, e.g., in the definition of the + Window or WorkerGlobalScope interfaces. When the values have utility + across multiple realms, we use the environment settings object concept.

    -/main/home -/main/app.js -/settings/home -/settings/app.js -https://img.example.com/logo.png -https://img.example.com/check.png -https://img.example.com/cross.png
    +

    Finally, in some cases it is necessary to track associated values before a + realm/global object/environment settings object even comes into existence (for example, during + navigation). These values are tracked in the + environment concept.

    -
    +
    Environments
    -
    +

    An environment is an object that identifies the settings of a current or + potential execution environment. An environment has the following fields:

    -

    The following manifest defines a catch-all error page that is displayed for any page on the - site while the user is offline. It also specifies that the online safelist wildcard flag is open, meaning that accesses to resources on other sites will not be blocked. - (Resources on the same site are already not blocked because of the catch-all fallback - namespace.)

    +
    +
    An id
    +

    An opaque string that uniquely identifies this environment.

    -

    So long as all pages on the site reference this manifest, they will get cached locally as they - are fetched, so that subsequent hits to the same page will load the page immediately from the - cache. Until the manifest is changed, those pages will not be fetched from the server again. When - the manifest changes, then all the files will be redownloaded.

    +
    A creation URL
    +
    +

    A URL that represents the location of the resource with which this + environment is associated.

    -

    Subresources, such as style sheets, images, etc, would only be cached using the regular HTTP - caching semantics, however.

    +

    In the case of an environment settings object, this URL might be + distinct from the environment settings object's responsible + document's URL, due to mechanisms such as + history.pushState().

    +
    -
    CACHE MANIFEST
    -FALLBACK:
    -/ /offline.html
    -NETWORK:
    -*
    +
    A top-level creation URL
    +

    Null or a URL that represents the creation URL of the "top-level" + environment. It is null for workers and worklets.

    -
    +
    A top-level origin
    +
    +

    A for now implementation-defined value, null, + or an origin. For a "top-level" potential execution environment it is null (i.e., + when there is no response yet); otherwise it is the "top-level" environment's origin. For a dedicated worker or worklet it is + the top-level origin of its creator. For a shared or service worker it is an + implementation-defined value.

    +

    This is distinct from the top-level creation URL's origin when sandboxing, workers, and worklets are + involved.

    +
    +
    A target browsing context
    +

    Null or a target browsing context for a navigation request.

    -
    Writing cache manifests
    +
    An active service worker
    +

    Null or a service worker that controls the environment.

    -

    Manifests must be served using the text/cache-manifest MIME type. All - resources served using the text/cache-manifest MIME type must follow the - syntax of application cache manifests, as described in this section.

    +
    An execution ready flag
    +

    A flag that indicates whether the environment setup is done. It is initially + unset.

    + -

    An application cache manifest is a text file, whose text is encoded using UTF-8. Data in - application cache manifests is line-based. Newlines must be represented by U+000A LINE FEED (LF) - characters, U+000D CARRIAGE RETURN (CR) characters, or U+000D CARRIAGE RETURN (CR) U+000A LINE - FEED (LF) pairs.

    +

    Specifications may define environment discarding steps for environments. The + steps take an environment as input.

    -

    This is a willful violation of RFC 2046, which requires all text/* types to only allow CRLF line breaks. This requirement, however, is - outdated; the use of CR, LF, and CRLF line breaks is commonly supported and indeed sometimes CRLF - is not supported by text editors.

    +

    The environment discarding + steps are run for only a select few environments: the ones that will + never become execution ready because, for example, they failed to load.

    -

    The first line of an application cache manifest must consist of the string "CACHE", a single - U+0020 SPACE character, the string "MANIFEST", and either a U+0020 SPACE character, a U+0009 - CHARACTER TABULATION (tab) character, a U+000A LINE FEED (LF) character, or a U+000D CARRIAGE - RETURN (CR) character. The first line may optionally be preceded by a U+FEFF BYTE ORDER MARK (BOM) - character. If any other text is found on the first line, it is ignored.

    +
    Environment settings objects
    -

    Subsequent lines, if any, must all be one of the following:

    +

    An environment settings object is an environment that + additionally specifies algorithms for:

    -
    A blank line -
    -

    Blank lines must consist of zero or more U+0020 SPACE and - U+0009 CHARACTER TABULATION (tab) characters only.

    +
    A realm execution + context
    -
    A comment
    -

    Comment lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) - characters, followed by a single U+0023 NUMBER SIGN character (#), followed by zero or more - characters other than U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) characters.

    +

    A JavaScript execution context shared by all + scripts that use this settings object, i.e. all scripts in a given + JavaScript realm. When we run a classic script or run a module + script, this execution context becomes the top of the JavaScript execution context + stack, on top of which another execution context specific to the script in question is + pushed. (This setup ensures ParseScript and Source + Text Module Record's Evaluate know which Realm to + use.)

    +
    -

    Comments need to be on a line on their own. If they were to be included on a - line with a URL, the "#" would be mistaken for part of a fragment.

    +
    A module map
    -
    A section header
    -

    Section headers change the current section. There are four possible section headers: - -

    -
    CACHE: -
    Switches to the explicit section. +

    A module map that is used when importing JavaScript modules.

    +
    -
    FALLBACK: -
    Switches to the fallback section. +
    A responsible document
    -
    NETWORK: -
    Switches to the online safelist section. +
    +

    A Document that is assigned responsibility for actions taken by the scripts that + use this environment settings object.

    -
    SETTINGS: -
    Switches to the settings section. -
    +

    For example, the URL of the + responsible document is used to set the URL of the Document after it has been reset + using document.open().

    -

    Section header lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER - TABULATION (tab) characters, followed by one of the names above (including the U+003A COLON - character (:)) followed by zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) - characters.

    +

    If the responsible event loop is not a window event loop, then the + environment settings object has no responsible document.

    +
    -

    Ironically, by default, the current section is the explicit section.

    +
    An API URL character encoding
    -
    Data for the current section
    -

    The format that data lines must take depends on the current section.

    +

    A character encoding used to encode URLs by APIs called by scripts that use this environment + settings object.

    +
    -

    When the current section is the explicit - section, data lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER - TABULATION (tab) characters, a valid URL string identifying a resource other than - the manifest itself, and then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) - characters.

    +
    An API base URL
    + +
    +

    A URL used by APIs called by scripts that use this environment settings + object to parse URLs.

    +
    -

    When the current section is the fallback - section, data lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER - TABULATION (tab) characters, a valid URL string identifying a resource other than - the manifest itself, one or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters, - another valid URL string identifying a resource other than the manifest itself, and - then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters.

    +
    An origin
    -

    When the current section is the online - safelist section, data lines must consist of zero or more U+0020 SPACE and U+0009 - CHARACTER TABULATION (tab) characters, either a single U+002A ASTERISK character (*) or a valid URL string identifying a - resource other than the manifest itself, and then zero or more U+0020 SPACE and U+0009 CHARACTER - TABULATION (tab) characters.

    +
    +

    An origin used in security checks.

    +
    -

    When the current section is the settings - section, data lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER - TABULATION (tab) characters, a setting, - and then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters.

    +
    A referrer policy
    -

    Currently only one setting is - defined:

    +

    The default referrer policy for fetches + performed using this environment settings object as a request client. -

    -
    The cache mode setting
    +
    An embedder policy
    -
    This consists of the string "prefer-online". It sets the cache mode to prefer-online. (The cache mode defaults to fast.)
    -
    +

    An embedder policy used by cross-origin resource policy checks for fetches + performed using this environment settings object as a request client.

    -

    Within a settings section, each setting must occur no more than once.

    +
    A cross-origin isolated capability
    - +

    A boolean representing whether scripts that use this environment settings + object are allowed to use APIs that require cross-origin isolation.

    -

    Manifests may contain sections more than once. Sections may be empty.

    - -

    URLs that are to be fallback pages associated with fallback namespaces, and those namespaces themselves, - must be given in fallback sections, with - the namespace being the first URL of the data line, and the corresponding fallback page being the - second URL. All the other pages to be cached must be listed in explicit sections.

    +

    An environment settings object also has an outstanding rejected promises + weak set and an about-to-be-notified rejected promises list, used to track + unhandled promise rejections. The outstanding + rejected promises weak set must not create strong references to any of its members, and + implementations are free to limit its size, e.g. by removing old entries from it when new ones + are added.

    -

    Fallback namespaces and fallback entries must have the same origin - as the manifest itself. Fallback namespaces - must also be in the same path as the manifest's URL.

    +

    An environment settings object's responsible event loop is its global + object's relevant agent's event + loop.

    -

    A fallback namespace must not be listed more - than once.

    +
    Realms, settings objects, and global objects
    -

    Namespaces that the user agent is to put into the online safelist must all be specified in online safelist sections. (This is needed for - any URL that the page is intending to use to communicate back to the server.) To specify that all - URLs are automatically safelisted in this way, a U+002A ASTERISK character (*) may be specified - as one of the URLs.

    +

    A global object is a JavaScript object that is the [[GlobalObject]] field of + a JavaScript realm.

    -

    Authors should not include namespaces in the online safelist for which another namespace in - the online safelist is a prefix - match.

    +

    In this specification, all JavaScript + realms are created with global objects that are either Window or + WorkerGlobalScope objects.

    -

    Relative URLs must be given relative to the manifest's own - URL. All URLs in the manifest must have the same scheme as - the manifest itself (either explicitly or implicitly, through the use of relative URLs).

    +

    There is always a 1-to-1-to-1 mapping between JavaScript + realms, global objects, and environment settings objects:

    -

    URLs in manifests must not have fragments (i.e. the - U+0023 NUMBER SIGN character isn't allowed in URLs in manifests).

    +

    To create a new JavaScript realm in an agent agent, optionally with instructions to create a global object or @@ -96261,6 +93763,71 @@ interface Navigator {

    + + +
    interface mixin NavigatorOnLine {
    +  readonly attribute boolean onLine;
    +};
    + +
    +
    self . navigator . onLine
    + +
    +

    Returns false if the user agent is definitely offline (disconnected from the network). + Returns true if the user agent might be online.

    + +

    The events online and offline are fired when the value of this attribute changes.

    +
    +
    + +
    + +

    The navigator.onLine attribute must return + false if the user agent will not contact the network when the user follows links or when a script + requests a remote page (or knows that such an attempt would fail), and must return true + otherwise.

    + +

    When the value that would be returned by the navigator.onLine attribute of a Window or + WorkerGlobalScope global changes from true to false, the user agent must + queue a global task on the networking task source given + global to fire an event named offline at global.

    + +

    On the other hand, when the value that would be returned by the navigator.onLine attribute of a Window or + WorkerGlobalScope global changes from false to true, the user agent must + queue a global task on the networking task source given + global to fire an event named online at the Window or WorkerGlobalScope + object.

    + +
    + +

    This attribute is inherently unreliable. A computer can be connected to a network + without having Internet access.

    + +
    +

    In this example, an indicator is updated as the browser goes online and offline.

    + +
    <!DOCTYPE HTML>
    +<html lang="en">
    + <head>
    +  <title>Online status</title>
    +  <script>
    +   function updateIndicator() {
    +     document.getElementById('indicator').textContent = navigator.onLine ? 'online' : 'offline';
    +   }
    +  </script>
    + </head>
    + <body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()">
    +  <p>The network is: <span id="indicator">(state unknown)</span>
    + </body>
    +</html>
    +
    +
    Custom scheme handlers: the registerProtocolHandler() method
    @@ -101290,9 +98857,6 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope onmessageerror messageerror -

    For the purposes of the application cache networking model, a dedicated worker is - an extension of the cache host from which it was created.

    -
    Shared workers and the SharedWorkerGlobalScope interface
    @@ -110320,36 +107884,6 @@ document.body.appendChild(text); Document as the intended parent. Append it to the Document object. Put this element in the stack of open elements.

    -

    If the Document is being loaded as part of navigation of a browsing context and - Document's relevant settings object is a secure context, - then:

    - -
      -
    1. If the result of running match service worker - registration for the document's URL is - non-null, run the application cache selection - algorithm passing the Document object with no manifest.

    2. - -
    3. -

      Otherwise, run these substeps:

      - -
        -
      1. If the newly created element has a manifest - attribute whose value is not the empty string, then parse the value of that attribute, relative to the newly created element's - node document, and if that is successful, run the application cache selection algorithm passing the - Document object with the result of applying the URL serializer algorithm to the resulting URL - record with the exclude fragment flag set.

      2. - -
      3. Otherwise, run the application cache selection - algorithm passing the Document object with no manifest.

      4. -
      -
    4. -
    -

    Switch the insertion mode to "before head".

    @@ -110370,11 +107904,6 @@ document.body.appendChild(text); it to the Document object. Put this element in the stack of open elements.

    -

    If the Document is being loaded as part of navigation of a browsing context, then: run the application cache selection algorithm with no manifest, - passing it the Document object.

    -

    Switch the insertion mode to "before head", then reprocess the token.

    @@ -113711,13 +111240,6 @@ document.body.appendChild(text); -
  • If the Document has any pending application cache download process - tasks, then queue each such task in the order they were added to the list of pending - application cache download process tasks, and then empty the list of pending - application cache download process tasks. The task source for these tasks is the networking task source.

  • -
  • If the Document's print when loaded flag is set, then run the printing steps.

  • @@ -118175,6 +115697,9 @@ if (s = prompt('What is your name?')) {
    profile on head elements

    Unnecessary. Omit it altogether.

    +
    manifest on html elements
    +

    Use service workers instead.

    +
    version on html elements

    Unnecessary. Omit it altogether.

    @@ -119795,92 +117320,6 @@ interface External { XML MIME type.

    -

    text/cache-manifest

    - -

    This registration is for community review and will be submitted - to the IESG for review, approval, and registration with IANA.

    - - - -
    -
    Type name:
    -
    text
    -
    Subtype name:
    -
    cache-manifest
    -
    Required parameters:
    -
    No parameters
    -
    Optional parameters:
    -
    -
    -
    charset
    -
    -

    The charset parameter may be provided. The parameter's value must be - "utf-8". This parameter serves no purpose; it is only allowed for - compatibility with legacy servers.

    -
    -
    -
    -
    Encoding considerations:
    -
    8bit (always UTF-8)
    - -
    Security considerations:
    -
    -

    Cache manifests themselves pose no immediate risk unless - sensitive information is included within the - manifest. Implementations, however, are required to follow - specific rules when populating a cache based on a cache manifest, - to ensure that certain origin-based restrictions are - honored. Failure to correctly implement these rules can result in - information leakage, cross-site scripting attacks, and the - like.

    -
    - -
    Interoperability considerations:
    -
    - Rules for processing both conforming and non-conforming content - are defined in this specification. -
    -
    Published specification:
    -
    - This document is the relevant specification. -
    -
    Applications that use this media type:
    -
    - Web browsers. -
    -
    Additional information:
    -
    -
    -
    Magic number(s):
    -
    Cache manifests begin with the string "CACHE - MANIFEST", followed by either a U+0020 SPACE character, a - U+0009 CHARACTER TABULATION (tab) character, a U+000A LINE FEED - (LF) character, or a U+000D CARRIAGE RETURN (CR) character.
    -
    File extension(s):
    -
    "appcache"
    -
    Macintosh file type code(s):
    -
    No specific Macintosh file type codes are recommended for this type.
    -
    -
    -
    Person & email address to contact for further information:
    -
    Ian Hickson <ian@hixie.ch>
    -
    Intended usage:
    -
    Common
    -
    Restrictions on usage:
    -
    No restrictions apply.
    -
    Author:
    -
    Ian Hickson <ian@hixie.ch>
    -
    Change controller:
    -
    W3C
    -
    - -

    Fragments have no meaning with - text/cache-manifest resources.

    - -

    text/ping

    This registration is for community review and will be submitted to the IESG for review, @@ -122977,11 +120416,6 @@ interface External { meter High limit of low range Valid floating-point number* - - manifest - html - Application cache manifest - Valid non-empty URL potentially surrounded by spaces max input @@ -124543,7 +121977,7 @@ INSERT INTERFACES HERE selection from the document - error + error Event or ErrorEvent Global scope objects, Worker objects, elements, networking-related objects Fired when unexpected errors occur (e.g. networking errors, script errors, decoding errors) @@ -124713,9 +122147,8 @@ INSERT INTERFACES HERE -

    See also media element events, application cache events, and drag-and-drop - events.

    +

    See also media element events and drag-and-drop events.

    @@ -124783,9 +122216,6 @@ INSERT INTERFACES HERE
    multipart/x-mixed-replace
    Streaming server push
    -
    text/cache-manifest
    -
    Offline application cache manifests
    -
    text/css
    CSS