diff --git a/index.html b/index.html index b24d151..a943b33 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ github: "WICG/manifest-incubations", shortName: "manifest-incubations", xref: { - specs: ["appmanifest"], + specs: ["appmanifest", "dom"], profile: "web-platform", }, }; @@ -278,5 +278,609 @@
+ There are multiple ways that the installation process can be triggered: +
++ In any case, the user agent MUST NOT present an install prompt + if the document is not installable. +
++ The user agent MAY, at any time (only if the document is installable), run the steps to + notify that an install prompt is available at any time, giving the + site the opportunity to show a site-triggered install prompt + without the user needing to interact with the user agent UI. +
++ To present + an install prompt: +
++ The steps to notify that an install prompt is available are + given by the following algorithm: +
++ The steps to install the web application are given by the + following algorithm: +
+appinstalled
+ at the the {{Window}} object of the top-level browsing
+ context for which the installation took place.
+ + By design, this specification does not provide developers with an + explicit API to "install" a web application. Instead, a + manifest can serve as an installability signal to a + user agent that a web application can be installed. +
++ Examples of installability signals for a web application: +
+name
member and a suitable icon.
+ + This list is not exhaustive and some installability signals + might not apply to all user agents. How a user agent makes use of + these installability signals to determine if a web application + can be installed is left to implementers. +
++ Installation events and supporting the {{BeforeInstallPrompt}} is + OPTIONAL. +
++ DOM events fired by this specification use the application + life-cycle task source. +
++ [Exposed=Window] + interface BeforeInstallPromptEvent : Event { + constructor(DOMString type, optional EventInit eventInitDict = {}); + Promise<PromptResponseObject> prompt(); + }; + + dictionary PromptResponseObject { + AppBannerPromptOutcome userChoice; + }; + + enum AppBannerPromptOutcome { + "accepted", + "dismissed" + }; ++
+ The BeforeInstallPromptEvent is dispatched when the site is + allowed to present a site-triggered install prompt, or prior + to the user agent presenting an automated install prompt. It + allows the site to cancel the automated install prompt, as + well as manually present the site-triggered install prompt. +
++ The PromptResponseObject contains the result of calling + {{BeforeInstallPromptEvent/prompt()}}. It contains one member, + userChoice, which + states the user's chosen outcome. +
++ An instance of a {{BeforeInstallPromptEvent}} has the following + internal slots: +
+false
. Represents whether this
+ event was used to present an install prompt to the end-user.
+ prompt()
method
+ + The prompt method, when called, runs the following + steps: +
+false
, reject
+ this.{{BeforeInstallPromptEvent/[[userResponsePromise]]}}
+ with {{"NotAllowedError"}}, optionally informing the developer
+ that untrusted events can't call prompt()
.
+ false
, set
+ this.{{BeforeInstallPromptEvent/[[didPrompt]]}} to
+ true
, then in parallel, request to
+ present an install prompt with this event. Wait, possibly
+ indefinitely, for the end-user to make a choice.
+ + To request to present an install prompt + with BeforeInstallPromptEvent event: +
++ This example shows how one might prevent an automated install + prompt from showing until the user clicks a button to show a + site-triggered install prompt. In this way, the site can + leave installation at the user's discretion (rather than prompting + at an arbitrary time), whilst still providing a prominent UI to do + so. +
++ window.addEventListener("beforeinstallprompt", event => { + // Suppress automatic prompting. + event.preventDefault(); + + // Show the (disabled-by-default) install button. This button + // resolves the installButtonClicked promise when clicked. + installButton.disabled = false; + + // Wait for the user to click the button. + installButton.addEventListener("click", async e => { + // The prompt() method can only be used once. + installButton.disabled = true; + + // Show the prompt. + const { userChoice } = await event.prompt(); + console.info(`user choice was: ${userChoice}`); + }); + }); ++
AppBannerPromptOutcome
enum
+ + The AppBannerPromptOutcome enum's values represent the + outcomes from presenting an install prompt. +
+Window
object
+
+ The following extensions to the Window
object specify
+ the event handler idl attribute on which events relating to
+ the installation of a web application are fired.
+
+ partial interface Window { + attribute EventHandler onappinstalled; + attribute EventHandler onbeforeinstallprompt; + }; ++
+ function handleInstalled(ev) { + const date = new Date(ev.timeStamp / 1000); + console.log(`Yay! Our app got installed at ${date.toTimeString()}.`); + } + + // Using the event handler IDL attribute + window.onappinstalled = handleInstalled; + + // Using .addEventListener() + window.addEventListener("appinstalled", handleInstalled); ++
onappinstalled
attribute
+
+ The onappinstalled is an event handler IDL
+ attribute for the "appinstalled" event type. The
+ interface used for these events is the Event
+ interface [[DOM]]. This event is dispatched as a result of a
+ successful installation (see the steps to install the web
+ application).
+
onbeforeinstallprompt
attribute
+ + The onbeforeinstallprompt is an event handler IDL + attribute for the "beforeinstallprompt" event type. + The interface used for these events is the + BeforeInstallPromptEvent interface (see the steps to + notify that an install prompt is available). +
+
+ A resource is said to be associated with a manifest if the
+ resource representation, an HTML document, has a manifest
link relationship.
+
+ The manifest
keyword can be used with a [[HTML]]
+ [^link^] element. This keyword creates an external resource
+ link.
+
+ Link type + | ++ Effect on... + | ++ Brief description + | +|
---|---|---|---|
+ link
+ |
+
+ a and area
+ |
+ ||
+ manifest
+ |
+ + External Resource Link + | ++ not allowed + | ++ Imports or links to a manifest. + | +
+ In cases where more than one [^link^] element with a
+ manifest
link type appears in a {{Document}}, the user
+ agent uses the first [^link^] element in tree order and ignores all
+ subsequent [^link^] elements with a manifest
link type
+ (even if the first element was erroneous). See the steps for
+ obtaining a manifest.
+
+ To obtain a manifest, the user agent MUST run the steps for + obtaining a manifest. The + appropriate time to obtain the manifest is left up to + implementations. A user agent MAY opt to delay fetching a manifest + until after the document and its other resources have been fully + loaded (i.e., to not delay the availability of content and scripts + required by the document). +
++ A manifest is obtained and applied regardless of the + {{HTMLLinkElement/media}} attribute of the [^link^] element matches + the environment or not. +
++ This section defines algorithms for obtaining, + processing, and applying a + manifest. +
++ The steps + for obtaining a manifest are given by the following algorithm. + The algorithm, if successful, returns a processed manifest and + the manifest URL; otherwise, it aborts prematurely and + returns nothing. In the case of nothing being returned, the user + agent MUST ignore the manifest declaration. In running these steps, a + user agent MUST NOT delay the load event. +
+manifest
.
+ null
, then abort
+ these steps.
+ href
attribute's value
+ is the empty string, then abort these steps.
+ href
attribute,
+ relative to the element's base URL. If parsing fails, then
+ abort these steps.
+ + A user agent MUST support [[CSP3]]. +
+
+ The manifest-src and default-src directives govern
+ the origins from which a user agent can fetch a manifest.
+ As with other directives, by default the manifest-src
+ directive is *
, meaning that a user agent can,
+ [[FETCH]]'s CORS permitting, fetch the manifest
+ cross-domain. Remote origins (e.g., a CDN) wanting to host manifests
+ for various web applications will need to include the appropriate
+ CORS response header in their HTTP response (e.g.,
+ Access-Control-Allow-Origin: https://example.com
).
+