├── .github └── workflows │ └── auto-publish.yml ├── .pr-preview.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── Makefile ├── README.md ├── build └── tidyconfig.txt ├── images ├── interoperability-1ua.png ├── interoperability-2ua.png ├── uc-multiplayer-game-player-alice.png ├── uc-multiplayer-game-player-bob.png └── uc-multiplayer-game-poker-table.png ├── index.html ├── interoperability.md ├── releases ├── FPWD.html └── WD.html ├── uc-req.md └── w3c.json /.github/workflows/auto-publish.yml: -------------------------------------------------------------------------------- 1 | name: Build, Validate, Deploy and Publish 2 | on: 3 | pull_request: {} 4 | push: 5 | branches: [main] 6 | jobs: 7 | main: 8 | name: Build and validate spec, then deploy and publish (only if push to main branch) 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: w3c/spec-prod@v2 13 | with: 14 | GH_PAGES_BRANCH: gh-pages 15 | W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN }} 16 | W3C_WG_DECISION_URL: https://lists.w3.org/Archives/Public/public-secondscreen/2022Apr/0007.html 17 | W3C_BUILD_OVERRIDE: | 18 | specStatus: CRD -------------------------------------------------------------------------------- /.pr-preview.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_file": "index.html", 3 | "type": "respec" 4 | } 5 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | All documentation, code and communication under this repository are covered by the [W3C Code of Ethics and Professional Conduct](https://www.w3.org/Consortium/cepc/). 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | Please refer to the group's [Work Mode](https://www.w3.org/wiki/Second_Screen/Work_Mode). 4 | 5 | Contributions to this repository are intended to become part of Recommendation-track documents governed by the 6 | [W3C Patent Policy](http://www.w3.org/Consortium/Patent-Policy-20040205/) and 7 | [Software and Document License](http://www.w3.org/Consortium/Legal/copyright-software). 8 | To make substantive contributions to specifications, you must either participate 9 | in the relevant W3C Working Group or make a non-member patent licensing commitment. 10 | 11 | If you are not the sole contributor to a contribution (pull request), please identify all 12 | contributors in the pull request comment. 13 | 14 | To add a contributor (other than yourself, that's automatic), mark them one per line as follows: 15 | 16 | ``` 17 | +@github_username 18 | ``` 19 | 20 | If you added a contributor by mistake, you can remove them in a comment with: 21 | 22 | ``` 23 | -@github_username 24 | ``` 25 | 26 | If you are making a pull request on behalf of someone else but you had no part in designing the 27 | feature, you can remove yourself with the above syntax. 28 | 29 | # Tests 30 | 31 | For normative changes, a corresponding 32 | [web-platform-tests](https://github.com/web-platform-tests/wpt) PR is highly appreciated. Typically, 33 | both PRs will be merged at the same time. Note that a test change that contradicts the spec should 34 | not be merged before the corresponding spec change. If testing is not practical, please explain why 35 | and if appropriate [file a web-platform-tests issue](https://github.com/web-platform-tests/wpt/issues/new) 36 | to follow up later. Add the `type:untestable` or `type:missing-coverage` label as appropriate. 37 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | All documents in this Repository are licensed by contributors 2 | under the 3 | [W3C Software and Document License](http://www.w3.org/Consortium/Legal/copyright-software). 4 | 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TIDY ?= tidy-html5 2 | 3 | tidy: index.html build/tidyconfig.txt 4 | $(TIDY) -ashtml -config build/tidyconfig.txt -o $< $< 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Presentation API 2 | 3 | This repository contains the 4 | [Presentation API](https://w3c.github.io/presentation-api/) 5 | specification that is being worked on in the 6 | [W3C Second Screen Working Group](http://www.w3.org/2014/secondscreen/). 7 | 8 | Please refer to the group's [Work Mode](https://www.w3.org/wiki/Second_Screen/Work_Mode) 9 | for instructions on how to contribute. 10 | 11 | ### Useful Resources 12 | 13 | * [Specification](https://w3c.github.io/presentation-api/) 14 | * [Issue Tracker](https://github.com/w3c/presentation-api/issues) 15 | * [Mailing List](http://lists.w3.org/Archives/Public/public-secondscreen/) -------------------------------------------------------------------------------- /build/tidyconfig.txt: -------------------------------------------------------------------------------- 1 | char-encoding: utf8 2 | doctype: html5 3 | drop-proprietary-attributes: no 4 | warn-proprietary-attributes: no 5 | indent: yes 6 | indent-spaces: 2 7 | preserve-entities: yes 8 | wrap: 80 9 | tidy-mark: no 10 | quiet: yes 11 | -------------------------------------------------------------------------------- /images/interoperability-1ua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/presentation-api/7c6c9f7cdddd24653d25cfb62ea36f0748884f84/images/interoperability-1ua.png -------------------------------------------------------------------------------- /images/interoperability-2ua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/presentation-api/7c6c9f7cdddd24653d25cfb62ea36f0748884f84/images/interoperability-2ua.png -------------------------------------------------------------------------------- /images/uc-multiplayer-game-player-alice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/presentation-api/7c6c9f7cdddd24653d25cfb62ea36f0748884f84/images/uc-multiplayer-game-player-alice.png -------------------------------------------------------------------------------- /images/uc-multiplayer-game-player-bob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/presentation-api/7c6c9f7cdddd24653d25cfb62ea36f0748884f84/images/uc-multiplayer-game-player-bob.png -------------------------------------------------------------------------------- /images/uc-multiplayer-game-poker-table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/presentation-api/7c6c9f7cdddd24653d25cfb62ea36f0748884f84/images/uc-multiplayer-game-poker-table.png -------------------------------------------------------------------------------- /interoperability.md: -------------------------------------------------------------------------------- 1 | # Assess interoperability of Presentation API implementations 2 | 3 | This document discusses the interoperability of potential Presentation API 4 | implementations; in particular, interoperability between user agents in case of 5 | [2-UA implementations][2ua] and between user agents and presentation displays in 6 | case of [1-UA implementations][1ua]. For this, state of the art technologies 7 | and standards that may be useful to implement the Presentation API will be 8 | considered. 9 | 10 | ## Interoperability between user agents (2-UA) 11 | 12 | The following diagram shows an overview of the main components for the 2-UA 13 | implementation. Each of the user agents implements part of the Presentation API 14 | (for controlling browsing context or presenting browsing context). 15 | 16 | 17 | ![2-UA implementation][2ua-img] 18 | 19 | To ensure interoperability between user agents running on controller devices and 20 | user agents running on presentation devices the following aspects should be 21 | considered: 22 | 23 | - **Discovery**: To discover presentation devices, the controlling user agent 24 | should use the same technology as the presenting user agent uses to advertise 25 | itself. 26 | - **Potential technologies**: [SSDP](http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/), [mDNS/DNS-SD](http://www.dns-sd.org/) or [Bluetooth Low Energy](http://www.bluetooth.com/Pages/low-energy-tech-info.aspx). 27 | - **Launch**: after discovery, the controlling user agent should know how to 28 | launch a new presentation or join an existing one. Common message formats 29 | should be also used. 30 | - **Potential technologies**: [DIAL](http://www.dial-multiscreen.org/dial-protocol-specification) (uses SSDP for discovery), [Google Cast](https://developers.google.com/cast/?hl=en) (part of it), HBBTv 2.0 (see https://github.com/w3c/presentation-api/issues/67). 31 | - **Communication**: also for communication both user agents should use same 32 | technologies/protocols to ensure interoperability. 33 | - **Potential technologies**: [WebSockets](https://tools.ietf.org/html/rfc6455), [WebRTC](http://www.webrtc.org/), Raw Socket, Google Cast (part of it). 34 | - **Signaling**: Common language and message formats (e.g. using JSON or XML) 35 | should be used to exchange signaling information between the two user agents. 36 | - **Security**: Means of authenticatating the presenting user agent to the 37 | controlling user agent (and vice versa), and ensuring privacy of communication. 38 | - **Potential technologies**: [TLS](https://tools.ietf.org/html/rfc5246), [DTLS-SRTP](https://tools.ietf.org/html/rfc5764), [X.509 Certificates](https://tools.ietf.org/html/rfc5280). 39 | 40 | 41 | ## Interoperability between user agents and presentation displays (1-UA) 42 | 43 | The following diagram shows an overview of the main components for the 1-UA 44 | implementation. There are fewer requirements than the 2-UA case for 45 | interoperability between controlling user agents and presentation displays. The 46 | controlling user agent implements the Presentation API for both controlling and 47 | presenting browsing contexts and the presentation page is rendered in silent 48 | mode (not visible for the user). The controlling user agent captures the UI 49 | output of the presentation page and sends the frames to a presentation device 50 | like a projector or wireless display. 51 | 52 | ![1-UA implementation][1ua-img] 53 | 54 | The controlling user agent and the presentation device must implement a common 55 | streaming technology to interoperate. More than likely, the user agent will use 56 | system APIs offered by the OS to show content on the presentation device. But 57 | other technologies not offered directly by the OS are also possible; for 58 | example, the Google Cast extension for Chrome supports mirroring tabs to 59 | Chromecast using WebRTC. 60 | 61 | **Potential Technologies**: [HDMI](http://www.hdmi.org/), [Intel WiDi](http://www.intel.com/content/www/us/en/architecture-and-technology/intel-wireless-display.html), [Miracast](http://www.wi-fi.org/discover-wi-fi/wi-fi-certified-miracast), [Airplay](http://www.apple.com/airplay/), [MHL](http://www.mhlconsortium.org/), WebRTC. 62 | 63 | [1ua]: http://w3c.github.io/presentation-api/#1-ua 64 | [2ua]: http://w3c.github.io/presentation-api/#2-ua 65 | [1ua-img]: ./images/interoperability-1ua.png 66 | [2ua-img]: ./images/interoperability-2ua.png 67 | -------------------------------------------------------------------------------- /releases/FPWD.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 7 | 9 |15 | This document has been published as a W3C First 17 | Public Working Draft 17 February 2015. 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /releases/WD.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |127 | Copyright 128 | © 2015 W3C® (MIT, ERCIM, 129 | Keio, Beihang). W3C liability, 130 | trademark 131 | and document 132 | use rules apply. 133 |
134 |141 | This specification defines an API to enable web content to access 142 | external presentation-type displays and use them for presenting web 143 | content. 144 |
145 |151 | This section describes the status of this document at the time of 152 | its publication. Other documents may supersede this document. A list of 153 | current W3C publications and the latest revision of this technical 154 | report can be found in the W3C 155 | technical reports index at http://www.w3.org/TR/. 156 |
157 |158 | This document was published by the Second Screen Presentation 159 | Working Group as a Working Draft. If you wish to make comments 160 | regarding this document, please send them to public-secondscreen@w3.org 161 | (subscribe, 162 | archives). 163 | All comments are welcome. 164 |
165 |166 | This document is a work in progress and is subject to change. 167 | Some sections are still incomplete or underspecified. Security and privacy 168 | considerations need to be adjusted based on feedback and 169 | experience. Some open issues are noted inline; please check the group's 170 | issue 171 | tracker on GitHub for all open issues. Feedback from early 172 | experimentations is encouraged to allow the Second Screen Presentation 173 | Working Group to evolve the specification based on implementation 174 | issues. 175 |
176 |177 | Publication as a Working Draft does not imply endorsement by the W3C 178 | Membership. This is a draft document and may be updated, replaced or 179 | obsoleted by other documents at any time. It is inappropriate to cite 180 | this document as other than work in progress. 181 |
182 |183 | This document was produced by a group operating under the 5 February 2004 184 | W3C Patent Policy. W3C maintains a public list of any patent disclosures made in 185 | connection with the deliverables of the group; that page also includes 186 | instructions for disclosing a patent. An individual who has actual 187 | knowledge of a patent which the individual believes contains Essential 188 | Claim(s) must disclose the information in accordance with section 189 | 6 of the W3C Patent Policy. 190 |
191 |192 | This document is governed by the 1 August 2014 W3C Process Document. 193 |
194 |PresentationSession
241 |
242 | Availability
257 |
258 | NavigatorPresentation
270 |
271 | DefaultSessionStart
307 | 343 | This specification aims to make presentation displays such 344 | as projectors or connected TVs, available to the Web and takes into 345 | account displays that are attached using wired (HDMI, DVI, or similar) 346 | and wireless technologies (Miracast, Chromecast, DLNA, AirPlay, or 347 | similar). 348 |
349 |350 | Devices with limited screen size lack the ability to show content to a 351 | larger audience, for example, a group of colleagues in a conference 352 | room, or friends and family at home. Showing content on an external 353 | large presentation display helps to improve the perceived 354 | quality and impact of the presented content. 355 |
356 |357 | At its core, this specification enables an exchange of messages between 358 | a page that acts as the controller and another page that 359 | represents the presentation shown in the 360 | presentation display. How the messages are transmitted is 361 | left to the UA in order to allow the use of presentation 362 | display devices that can be attached in a wide variety of ways. 363 | For example, when a presentation display device is 364 | attached using HDMI or Miracast, the same UA that acts as the 365 | controller renders the presentation. Instead 366 | of displaying the presentation in another window on the 367 | same device, however, it can use whatever means the operating system 368 | provides for using the external presentation displays. In 369 | such a case, both the controller and 370 | presentation run on the same UA and the operating system 371 | is used to route the presentation display output to the 372 | presentation display. This specification imposes no 373 | requirements on the presentation display devices connected 374 | in such a manner. 375 |
376 |377 | If the presentation display is able to render HTML 378 | documents and communicate with the controller, the 379 | controller does not need to render the 380 | presentation. In this case, the UA acts as a proxy that 381 | requests the presentation display to show and render the 382 | presentation itself. This way of attaching to displays 383 | could be enhanced in the future by defining a standard protocol for 384 | delivering these types of messages that display devices could choose to 385 | implement. 386 |
387 |388 | The API defined here is intended to be used with UAs that attach to 389 | presentation display devices through any of the above 390 | means. 391 |
392 |404 | All diagrams, examples, and notes in this specification are 405 | non-normative, as are all sections explicitly marked non-normative. 406 | Everything else in this specification is normative. 407 |
408 |409 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 410 | "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 411 | "OPTIONAL" in this document are to be interpreted as described in RFC 412 | 2119. For readability, these words do not appear in all uppercase 413 | letters in this specification. [RFC2119] 414 |
415 |416 | Requirements phrased in the imperative as part of algorithms (such as 417 | "strip any leading space characters" or "return false and terminate 418 | these steps") are to be interpreted with the meaning of the key word 419 | ("must", "should", "may", etc.) used in introducing the algorithm. 420 |
421 |422 | Conformance requirements phrased as algorithms or specific steps may be 423 | implemented in any manner, so long as the result is equivalent. (In 424 | particular, the algorithms defined in this specification are intended 425 | to be easy to follow, and not intended to be performant.) 426 |
427 |433 | The terms browsing context, 434 | event handlers, event handler 435 | event types, firing an event, navigate, queuing a task are defined in 436 | [HTML5]. 437 |
438 |439 | The term DOMException is defined 440 | in [WEBIDL]. 441 |
442 |443 | This document provides interface definitions using the 444 | [WEBIDL] standard. The terms 445 | Promise, ArrayBuffer, and ArrayBufferView are defined in [WEBIDL]. 446 |
447 |448 | The terms resolving a Promise, and rejecting a Promise 449 | are used as explained in [PROMGUIDE]. 450 |
451 |452 | The term URL is defined in the 453 | WHATWG URL standard [URL]. 454 |
455 |456 | The term Blob is defined in the 457 | File API specification [FILEAPI]. 458 |
459 |460 | The term RTCDataChannel is 461 | defined in the WebRTC API specification [WEBRTC]. 462 |
463 |
469 | This section shows example codes that highlight the usage of main
470 | features of the Presentation API. In these examples,
471 | controller.html
implements the controller and
472 | presentation.html
implements the presentation. Both pages
473 | are served from the domain http://example.org
474 | (http://example.org/controller.html
and
475 | http://example.org/presentation.html
). Please refer to the
476 | comments in the code examples for further details.
477 |
<!-- controller.html --> 483 | <button id="castBtn" style="display: none;">Cast</button> 484 | <script> 485 | // it is also possible to use relative presentation URL e.g. "presentation.html" 486 | var presUrl = "http://example.com/presentation.html"; 487 | // the cast button is visible if at least one presentation display is available 488 | var castBtn = document.getElementById("castBtn"); 489 | // show or hide cast button depending on display availability 490 | var handleAvailabilityChange = function(available) { 491 | castBtn.style.display = available ? "inline" : "none"; 492 | }; 493 | // Promise is resolved as soon as the presentation display availability is known. 494 | navigator.presentation.getAvailability(presUrl).then(function(availability) { 495 | // availability.value may be kept up-to-date by the UA as long as the availability 496 | // object is alive. It is advised for the web developers to discard the object 497 | // as soon as it's not needed. 498 | handleAvailabilityChange(availability.value); 499 | availability.onchange = function() { handleAvailabilityChange(this.value); }; 500 | }.catch(function() { 501 | // Availability monitoring is not supported by the platform, discovery of presentation 502 | // displays will happen only after startSession() call. Pretend the devices are 503 | // available for simplicity (one could implement the third state for the button). 504 | handleAvailabilityChange(true); 505 | }); 506 | </script> 507 |508 |
<!-- controller.html --> 514 | <script> 515 | // it is also possible to use relative presentation URL e.g. "presentation.html" 516 | var presUrl = "http://example.com/presentation.html"; 517 | // Start new session. 518 | navigator.presentation.startSession(presUrl) 519 | // the new started session will be passed to setSession on success 520 | .then(setSession) 521 | // user cancels the selection dialog or an error is occurred 522 | .catch(endSession); 523 | </script> 524 |525 |
<!-- controller.html --> 531 | <script> 532 | // read presId from localStorage if exists 533 | var presId = localStorage && localStorage["presId"] || null; 534 | // presId is mandatory for joinSession. 535 | presId && navigator.presentation.joinSession(presUrl, presId) 536 | // The joined session will be passed to setSession on success 537 | .then(setSession) 538 | // no session found for presUrl and presId or an error is occurred 539 | .catch(endSession); 540 | </script> 541 |542 |
<!-- controller.html --> 548 | <head> 549 | <!-- the link element with rel='default-presentation' allows the page to specify --> 550 | <!-- the presentation URL and id for when the UA initiates a presentation session --> 551 | <link href="http://example.com/presentation.html" rel="default-presentation" > 552 | </head> 553 | <script> 554 | navigator.presentation.ondefaultsessionstart = function (evt) { 555 | setSession(evt.session); 556 | }; 557 | </script> 558 | 559 |560 |
<!-- controller.html --> 566 | <script> 567 | var session; 568 | var setSession = function (theSession) { 569 | // end existing session, if any 570 | endSession(); 571 | // set the new session 572 | session = theSession; 573 | if (session) { 574 | // save presId in localStorage 575 | localStorage && (localStorage["presId"] = session.id); 576 | // monitor session's state 577 | session.onstatechange = function () { 578 | if (this == session && this.state == "disconnected") 579 | endSession(); 580 | }; 581 | // register message handler 582 | session.onmessage = function (evt) { 583 | console.log("receive message", evt.data); 584 | }; 585 | // send message to presentation page 586 | session.send("say hello"); 587 | } 588 | }; 589 | var endSession = function () { 590 | // close old session if exists 591 | session && session.close(); 592 | // remove old presId from localStorage if exists 593 | localStorage && delete localStorage["presId"]; 594 | }; 595 | </script> 596 | 597 |598 |
<!-- presentation.html --> 599 | <script> 600 | var addSession = function(session) { 601 | session.onstatechange = function () { 602 | // session.state is either 'connected' or 'disconnected' 603 | console.log("session's state is now", session.state); 604 | }; 605 | session.onmessage = function (evt) { 606 | if (evt.data == "say hello") 607 | session.send("hello"); 608 | } 609 | }); 610 | navigator.presentation.getSession().then(addSession); 611 | navigator.presentation.onsessionavailable = function(evt) { 612 | navigator.presentation.getSessions().then(function(sessions) { 613 | addSession(sessions[sessions.length-1]); 614 | }); 615 | }; 616 | </script> 617 | 618 |619 |
630 | A presentation display refers to an external screen 631 | available to the user agent via an implementation specific connection 632 | technology. 633 |
634 |635 | A presentation session is an object relating a 636 | controlling browsing context to its presenting 637 | browsing context and enables two-way-messaging between them. 638 | Each presentation session has a presentation 639 | session state, a presentation session identifier to 640 | distinguish it from other presentation sessions, and a 641 | presentation session URL that is a URL used to create or resume the presentation 642 | session. A valid presentation session identifier 643 | consists of alphanumeric ASCII characters only, is at least 16 644 | characters long, and is unique within the set of 645 | presentations. 646 |
647 |
648 | A controlling browsing context (or controller
649 | for short) is a browsing
650 | context that has initiated or resumed a presentation
651 | session by calling startSession()
or
652 | joinSession()
or received a
653 | presentation session via
654 | ondefaultsessionstart
event.
655 |
657 | The presenting browsing context (or 658 | presentation for short) is the browsing context 659 | responsible for rendering to a presentation display. A 660 | presenting browsing context can reside in the same user 661 | agent as the controlling browsing context or a different 662 | one. 663 |
664 |665 | The set of presentations, initially empty, contains the 666 | presentation sessions created by the controlling 667 | browsing contexts for the user agent (or a specific user 668 | profile within the user agent). The set of presentations 669 | is represented by a list of tuples, where each tuple consists of a 670 | presentation session URL, a presentation session 671 | identifier, and the presentation session itself. 672 | The presentation session URL and presentation 673 | session identifier uniquely identify the presentation 674 | session. 675 |
676 |PresentationSession
680 |
682 | Each presentation session is represented by a
683 | PresentationSession
object.
684 |
enum PresentationSessionState { "connected", "disconnected" /*, "resumed" */ }; 686 | enum BinaryType { "blob", "arraybuffer" }; 687 | 688 | interface PresentationSession : EventTarget { 689 | readonly DOMString? id; 690 | readonly attribute PresentationSessionState state; 691 | void close(); 692 | attribute EventHandler onstatechange; 693 | 694 | // Communication 695 | attribute BinaryType binaryType; 696 | EventHandler onmessage; 697 | void send (DOMString message); 698 | void send (Blob data); 699 | void send (ArrayBuffer data); 700 | void send (ArrayBufferView data); 701 | }; 702 |703 |
704 | The id
attribute specifies the
705 | presentation session's presentation session
706 | identifier.
707 |
709 | The state
attribute represents the
710 | presentation session's current state. It can take one of
711 | the values of PresentationSessionState
712 | depending on connection state.
713 |
715 | When the send()
method is called on a
716 | PresentationSession
object with a message
,
717 | the user agent must run the algorithm to send a message through a
718 | PresentationSession
.
719 |
721 | When the close()
method is called on a
722 | PresentationSession
, the user agent must run the
723 | algorithm to close a presentation
724 | session with PresentationSession
.
725 |
PresentationSession
729 |
731 | No specific transport for the connection between the
732 | controlling browsing context and the presenting
733 | browsing context is mandated, except that for multiple calls
734 | to send()
it has to be ensured that
735 | messages are delivered to the other end reliably and in sequence.
736 | The transport should function equivalently to an
737 | RTCDataChannel
738 | in reliable mode.
739 |
741 | Let presentation message data be the payload data to be
742 | transmitted between two browsing contexts. Let presentation
743 | message type be the type of that data, one of
744 | text
and binary
.
745 |
747 | When the user agent is to send a
748 | message through a PresentationSession
S, it must
749 | run the following steps:
750 |
state
property of
753 | PresentationSession
is "disconnected"
,
754 | throw an InvalidStateError
exception.
755 | binary
if data
is one of
758 | ArrayBuffer
, ArrayBufferView
, or
759 | Blob
. Let messageType be text
if
760 | data
is of type DOMString
)
761 | send()
is called in the presenting browsing
766 | context.
767 | send()
is called from the controlling
770 | browsing context.
771 | data
argument as presentation
776 | message data and presentation message type
777 | messageType to the destination browsing context
778 | side.
779 | PresentationSession
785 | 787 | When the user agent has received a transmission from the remote 788 | side consisting of presentation message data and 789 | presentation message type, it must run the following 790 | steps: 791 |
792 |state
property of
794 | PresentationSession
is "disconnected"
,
795 | abort these steps.
796 | MessageEvent
interface, with the event type
799 | message
, which does not bubble, is not cancelable, and
800 | has no default action.
801 | text
, then initialize event's
806 | data
attribute to the contents of
807 | presentation message data of type
808 | DOMString
.
809 | binary
, and binaryType
is set to
812 | blob
, then initialise event's
813 | data
attribute to a new Blob
object
814 | that represents presentation message data as its
815 | raw data.
816 | binary
, and binaryType
is set to
819 | arraybuffer
, then initialise event's
820 | data
attribute to a new ArrayBuffer
821 | object whose contents are presentation message
822 | data.
823 | PresentationSession
.
831 | PresentationSession
837 | 839 | When the user agent is to close a 840 | presentation session using session, it must run the 841 | following steps: 842 |
843 |connected
, then abort these steps.
846 | disconnected
.
849 | statechange
at session.
865 | 874 | ISSUE 875 | 35: Refine how to do session teardown/disconnect/closing 876 |
877 |
883 | The following are the event handlers (and their corresponding event
884 | handler event types) that must be supported, as event handler IDL
885 | attributes, by objects implementing the
886 | PresentationSession
interface:
887 |
892 | Event handler 893 | | 894 |895 | Event handler event type 896 | | 897 |
---|---|
902 | onmessage
903 | |
904 |
905 | message
906 | |
907 |
910 | onstatechange
911 | |
912 |
913 | statechange
914 | |
915 |
Availability
923 | interface Availability : EventTarget {
925 | readonly attribute boolean value;
926 | attribute EventHandler onchange;
927 | };
928 |
929 |
930 |
931 | An Availability
object is associated with a
932 | presentation display and represents its
933 | presentation display availability.
934 |
936 | The value
attribute must return the last value it was
937 | set to. The value is updated by the monitor the list of
938 | available presentation displays algorithm.
939 |
941 | The onchange
attribute is an event handler whose
942 | corresponding event handler event
943 | type is change
.
944 |
946 | When the user agent is to signal a presentation display 947 | availability change using availability object, the 948 | user agent must run the following steps: 949 |
950 |change
at availability
955 | object.
956 |
963 | The user agent must keep track of the set of availability
964 | objects requested through the getAvailability()
965 | method. The set of availability objects is represented
966 | as a set of tuples (A, availabilityUrl, P), initially
967 | empty, where:
968 |
Availability
object;
972 | availabilityUrl
975 | passed to getAvailability()
to create A.
976 | getAvailability()
when
980 | A was created.
981 | 989 | The user agent must keep a list of available presentation 990 | displays. This current list of presentation 991 | displays that may be used for starting new presentations, 992 | and is populated based on an implementation specific discovery 993 | mechanism. It is set to the most recent result of the algorithm to 994 | monitor the list of available presentation displays. 995 |
996 |
997 | While there are live Availability
objects, the user
998 | agent may monitor the list of available presentation
999 | displays continuously, so that pages can use the
1000 | value
property of an Availability
object
1001 | to offer presentation only when there are available displays.
1002 | However, the user agent may not support continuous availability
1003 | monitoring; for example, because of platform or power consumption
1004 | restrictions. In this case the Promise returned by
1005 | getAvailability()
is rejected and the
1006 | algorithm to monitor the list of available presentation
1007 | displays will only run as part of the session start algorithm.
1008 |
1010 | When there are no live Availability
objects (that is,
1011 | the set of availability objects is empty), user agents
1012 | should not monitor the list of available presentation
1013 | displays to satisfy the
1014 | power saving non-functional requirement. To further save power,
1015 | the UA may also keep track of whether the page holding an
1016 | Availability
object is in the foreground. Using this
1017 | information, implementation specific discovery of presentation displays can be resumed
1018 | or suspended.
1019 |
1021 | Some presentation displays may only be able to display 1022 | a subset of Web content because of functional, security or hardware 1023 | limitations. Examples are set-top boxes, smart TVs or networked 1024 | speakers capable of rendering only audio. We say that such a 1025 | display is a compatible presentation display for a 1026 | display availability URL if the user agent can 1027 | reasonably guarantee that the presentation of the URL on that 1028 | display will succeed. 1029 |
1030 |1036 | If set of availability objects is non-empty, or there 1037 | is a pending request to start a 1038 | session, the user agent must monitor the list of 1039 | available presentation displays by running the following 1040 | steps. 1041 |
1042 |value
property.
1056 | true
if
1058 | newDisplays is not empty and at least one display in
1059 | newDisplays is a compatible presentation
1060 | display for availabilityUrl. Otherwise, set
1061 | newAvailability to false
.
1062 | value
property to
1064 | newAvailability.
1065 |
1080 | When an Availability
object is no longer alive (i.e.,
1081 | is eligible for garbage collection), the user agent should run the
1082 | following steps:
1083 |
1096 | The mechanism used to monitor presention displays 1097 | availability and determine the compatibility of a 1098 | presentation display with a given URL is left to the 1099 | user agent. 1100 |
1101 |NavigatorPresentation
1106 | partial interface Navigator { 1108 | readonly attribute NavigatorPresentation presentation; 1109 | }; 1110 |1111 |
1112 | The presentation
attribute is
1113 | used to retrieve an instance of the
1114 | NavigatorPresentation
interface.
1115 |
interface NavigatorPresentation : EventTarget { 1117 | // This API used by controlling browsing context. 1118 | Promise<PresentationSession> startSession(DOMString url); 1119 | Promise<PresentationSession> joinSession(DOMString url, DOMString presentationId); 1120 | Promise<Availability> getAvailability(DOMString url); 1121 | attribute EventHandler ondefaultsessionstart; 1122 | 1123 | // This API used by presenting browsing context. 1124 | Promise<PresentationSession> getSession(); 1125 | Promise<PresentationSession[]> getSessions(); 1126 | attribute EventHandler onsessionavailable; 1127 | }; 1128 |1129 |
1134 | When the startSession(presentationUrl)
1135 | method is called, the user agent must run the following steps:
1136 |
presentationUrl
, the presentation session
1143 | URL
1144 | presentationUrl
;
1175 | "NotFoundError"
.
1184 | PresentationSession
1204 | S.
1205 | disconnected
.
1210 | presentationUrl
in it.
1217 | "OperationError"
.
1241 | "AbortError"
.
1255 | 1262 | The details of implementing the permission request and display 1263 | selection are left to the user agent; for example it may show the 1264 | user a dialog and allow the user to select an available display 1265 | (granting permission), or cancel the selection (denying 1266 | permission). 1267 |
1268 |
1269 | The presentationUrl
should name a resource accessible
1270 | to the local or a remote user agent. This specification defines
1271 | behavior for presentationUrl
using the
1272 | http
or https
schemes; behavior for other
1273 | schemes is not defined by this specification.
1274 |
1276 | ISSUE: Do we want to distinguish the permission-denied outcome from
1277 | the no-screens-available outcome? Developers would be able to infer
1278 | it anyway from getAvailability()
.
1279 |
1286 | When the joinSession(presentationUrl,
1287 | presentationId)
method is called, the user agent must run
1288 | the following steps:
1289 |
presentationUrl
, the presentation session
1296 | URL
1297 | presentationId
, the presentation session
1300 | identifier
1301 | presentationUrl
, and
1323 | the presentation session identifier of
1324 | known session is equal to
1325 | presentationId
, run the following steps:
1326 | "NotFoundError"
.
1347 | 1352 | ISSUE: If no matching presentation is found, we could leave the 1353 | Promise pending in case a matching presentation is started in the 1354 | future. 1355 |
1356 |1363 | When the user agent is to establish a presentation 1364 | connection using a presentation session 1365 | S, it must run the following steps: 1366 |
1367 |connected
, then:
1370 | connected.
1384 | statechange
at s.
1400 |
1411 | The mechanism that is used to present on the remote display and
1412 | connect the controlling browsing context with the
1413 | presented document is an implementation choice of the user agent.
1414 | The connection must provide a two-way messaging abstraction capable
1415 | of carrying DOMString
payloads in a reliable and
1416 | in-order fashion as described in the Send Message and
1417 | Receive Message steps below.
1418 |
1420 | If T does not complete successfully, the user agent may 1421 | choose to re-execute the Presentation Connection algorithm at a 1422 | later time. 1423 |
1424 |1425 | ISSUE: Do we want to notify the caller of a failure to connect, 1426 | i.e. with an "error" onstatechange? 1427 |
1428 |1429 | ISSUE: Do we want to pass the new state as a property of the 1430 | statechange event? 1431 |
1432 |
1439 | When the getAvailability(availabilityUrl)
1440 | method is called, the user agent must run the following steps:
1441 |
availabilityUrl
, a display availability
1448 | URL
1449 | Availability
1473 | object with its value
property set to
1474 | false
.
1475 | 1490 | ISSUE 1491 | 19: Specify behavior when multiple controlling pages are connected 1492 | to the session 1493 |
1494 |
1495 | When a new presenting browsing context has been
1496 | created and navigated to the presentationUrl
on a
1497 | user-selected presentation display, the user agent
1498 | must run the following steps:
1499 |
1515 | When the user agent is to start monitoring incoming 1516 | presentation sessions in a presenting browsing 1517 | context from controlling browsing 1518 | contexts, it must run the following steps: 1519 |
1520 |PresentationSession
S.
1531 | connected
.
1546 | undefined
, presentation
1548 | session identifier of S, S) to the
1549 | set of presentations.
1550 | sessionavailable
at
1555 | NavigatorPresentation
.
1556 |
1567 | When the getSession()
method is called, the user agent
1568 | must run the following steps:
1569 |
1594 | If the set of presentations is empty, we leave the
1595 | Promise pending until
1596 | connecting request arrives from the controlling browsing
1597 | context. If the first controlling browsing
1598 | context disconnects after initial connection, then the
1599 | Promise returned to
1600 | subsequent calls to getSession()
will resolve with a
1601 | presentation session that has its presentation
1602 | session state set to disconnected
.
1603 |
1611 | When the getSessions()
method is called, the user
1612 | agent must run the following steps:
1613 |
1645 | The following are the event handlers (and their corresponding
1646 | event handler event types) that must be supported, as event handler
1647 | IDL attributes, by objects implementing the
1648 | NavigatorPresentation
interface:
1649 |
1654 | Event handler 1655 | | 1656 |1657 | Event handler event type 1658 | | 1659 |
---|---|
1664 | ondefaultsessionstart
1665 | |
1666 |
1667 | defaultsessionstart
1668 | |
1669 |
1672 | onsessionavailable
1673 | |
1674 |
1675 | sessionavailable
1676 | |
1677 |
DefaultSessionStart
1685 | [Constructor(DOMString type, optional DefaultSessionStartEventInit eventInitDict)]
1687 | interface DefaultSessionStartEvent : Event {
1688 | readonly attribute PresentationSession session;
1689 | };
1690 |
1691 | dictionary DefaultSessionStartEventInit : EventInit {
1692 | PresentationSession session;
1693 | };
1694 |
1695 |
1696 |
1697 | An event named defaultsessionstart
is fired when the UA
1698 | initiates a presentation on behalf of the page. It is fired at the
1699 | NavigatorPresentation
object, using the
1700 | DefaultSessionStartEvent
interface, with the
1701 | session
attribute set to the
1702 | PresentationSession
object provided by the
1703 | UA.
1704 |
1712 | ISSUE 45: 1713 | Security and privacy considerations section 1714 |
1715 |
1719 | The change
event fired on the Availability
1720 | object reveals one bit of information about the presence (or
1721 | non-presence) of a presentation screen typically
1722 | discovered through the local area network. This could be used in
1723 | conjunction with other information for fingerprinting the user.
1724 | However, this information is also dependent on the user's local network
1725 | context, so the risk is minimized.
1726 |
1728 | If we allow the page to filter the set of presentation screens based on 1729 | capabilities, then more bits of more information would be revealed. 1730 | This feature, if implemented, should take privacy into consideration. 1731 | See ISSUE 9: 1732 | How to filter available screens according to the content being 1733 | presented? 1734 |
1735 |1736 | We do not want to require user permission before disclosing the 1737 | presence of a presentation display, as it is counter to the initial 1738 | purpose of improving the user experience. See ISSUE 10: Is user 1739 | permission required to prompt for screen availability information? 1740 |
1741 |1745 | A presentation session is allowed to be accessed across 1746 | origins; the presentation URL and presentation ID used to create the 1747 | presentation are the only information needed to join a session from any 1748 | origin in that user agent. In other words, a presentation is not tied 1749 | to a particular opening origin. 1750 |
1751 |1752 | This design allows controlling contexts from different domains to 1753 | connect to a shared presentation resource. The security of the 1754 | presentation ID prevents arbitrary pages from connecting to an existing 1755 | presentation. 1756 |
1757 |1758 | This specification does not prohibit a user agent from publishing 1759 | information about its set of presentations. The group 1760 | envisions a user agent on a another device (distinct from the 1761 | controller or presentation) becoming authorized to join the 1762 | presentation, either by user action or by discovering the 1763 | presentation's URL and id. 1764 |
1765 |1766 | This section should provide informative guidance as to what constitutes 1767 | a reasonable context for a Web page to become authorized to control a 1768 | presentation session. 1769 |
1770 |1774 | The presentation API abstracts away what "local" means for displays, 1775 | meaning that it exposes network-accessible displays as though they were 1776 | local displays. The Presentation API requires user permission for a 1777 | page to access any display to mitigate issues that could arise, such as 1778 | showing unwanted content on a display viewable by others. 1779 |
1780 |1784 | The presentation URL and presentation ID can be used to connect to a 1785 | presentation session from another browsing context. They can be 1786 | intercepted if an attacker can inject content into the controlling 1787 | page. 1788 |
1789 |1790 | Should we restrict the API to some extent in non secure contexts? 1791 |
1792 |1796 | The content displayed on the presentation is different from the 1797 | controller. In particular, if the user is logged in in both contexts, 1798 | then logs out of the controlling browsing context, she will not be 1799 | automatically logged out from the presenting browsing context. 1800 | Applications that use authentication should pay extra care when 1801 | communicating between devices. 1802 |
1803 |1804 | The set of presentations known to the user agent should be cleared when 1805 | the user requests to "clear browsing data." 1806 |
1807 |1808 | The spec should specify any restrictions on the presenting browsing 1809 | context when the opening browsing context is in "incognito" mode. See 1810 | ISSUE 14: 1811 | Define user agent context for rendering the presentation 1812 |
1813 |1814 | The spec should clarify what is to happen to the set of known 1815 | presentations in "incognito" (private browsing context) mode. 1816 |
1817 |1821 | This spec will not mandate communication protocols, but it should set 1822 | some guarantees of message confidentiality and authenticity. 1823 |
1824 |1825 | ISSUE 80: 1826 | Define security requirements for messaging channel between secure 1827 | origins 1828 |
1829 |1862 | Thanks to Wayne Carr, Louay Bassbouss, Anssi Kostiainen, 闵洪波 (Hongbo 1863 | Min), Anton Vayvod, and Mark Foltz for help with editing, reviews and 1864 | feedback to this draft. 1865 |
1866 |