When the start
method is called, the user agent MUST run the following steps to start a presentation:
- Input
- presentationRequest, the
PresentationRequest
object - presentationUrls, the presentation request URLs
- Output
- A Promise
- If the algorithm isn't allowed to show a popup, return a Promise rejected with an
InvalidAccessError
exception and abort these steps. - Using the document's settings object, run the prohibits mixed security contexts algorithm.
- If the result of the algorithm is
"Prohibits Mixed Security Contexts"
and presentationUrl is an a priori unauthenticated URL, then return a Promise rejected with aSecurityError
and abort these steps. - If the document object's active sandboxing flag set has the sandboxed presentation browsing context flag set, then return a Promise rejected with a
SecurityError
and abort these steps. - If there is already an unsettled Promise from a previous call to
start
for the same controlling browsing context, return a Promise rejected with anOperationError
exception and abort all remaining steps. - Let P be a new Promise.
- Return P, but continue running these steps in parallel.
- If the user agent is not monitoring the list of available presentation displays, run the steps to monitor the list of available presentation displays in parallel.
- Request user permission for the use of a presentation display and selection of one presentation display.
- If either of the following is true:
- The list of available presentation displays is empty and will remain so before the request for user permission is completed.
- No member in the list of available presentation displays is a compatible presentation display for any member of presentationUrls.
- Reject P with a
NotFoundError
exception. - Abort all remaining steps.
- If the user denied permission to use a display, reject P with an
NotAllowedError
exception, and abort all remaining steps. - Otherwise, the user granted permission to use a display; let D be that display and U the user agent connected to D.
- Let I be a new valid presentation identifier unique among all presentation identifiers for known presentation connections in the set of controlled presentations. To avoid fingerprinting, it is recommended that the presentation identifier be set to a UUID generated by following the forms 4.4 or 4.5 of [rfc4122].
- Create a new
PresentationConnection
S. - Set the presentation identifier of S to I.
- Set the presentation URL for S to the first presentationUrl in presentationUrls for which there exists an entry (presentationUrl, D) in the list of available presentation displays.
- Set the presentation connection state of S to
connecting
. - Add S to the set of controlled presentations.
- Resolve P with S.
- Queue a task to fire a trusted event with the name
connectionavailable
, that uses thePresentationConnectionAvailableEvent
interface, with theconnection
attribute initialized to S, at presentationRequest. The event must not bubble, must not be cancelable, and has no default action. - If any of the following steps fails, abort all remaining steps and close the presentation connection S with
error
as closeReason, and a human readable message describing the failure as closeMessage. - Using an implementation specific mechanism, tell U to create a receiving browsing context with D, presentationUrl, and I as parameters.
- Establish a presentation connection with S.
Note: The details of implementing the permission request and display selection are left to the user agent; for example it may show the user a dialog and allow the user to select an available display (granting permission), or cancel the selection (denying permission). Implementers are encouraged to show the user whether an available display is currently in use, to facilitate presentations that can make use of multiple displays.
Note: The presentationUrl should name a resource accessible to the local or a remote user agent. This specification defines behavior for presentationUrl using the http
or https
schemes; behavior for other schemes is not defined by this specification.