Skip to content

Commit

Permalink
Add Explainer.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradtriebwasser committed Oct 19, 2022
1 parent d5c8320 commit a46dd4f
Showing 1 changed file with 132 additions and 0 deletions.
132 changes: 132 additions & 0 deletions EXPLAINER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Multi-Screen Window Placement on the Web - Creating Fullscreen Popup Windows

## Introduction

This proposal introduces an additional way for web applications to initiate fullscreen experiences on multi-display configurations. The proposed enhancement would allow web applications to open a new window directly into fullscreen on a specified display with a single API call using the existing [window.open()](https://html.spec.whatwg.org/multipage/window-object.html#dom-open-dev) API.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Try introducing the problem here. Consider this (with other minor editorial suggestions):
"This proposal aims to reduce user and developer friction for initiating a fullscreen experience on the desired display of a multi-screen device. The proposed web platform enhancement allows web applications to open a new window in HTML fullscreen mode on a specific display with a single user gesture."


## Background

[Multi-Screen Window Placement](https://github.com/webscreens/window-placement)
is a new permission-gated web platform API that provides web applications with
information about the device's connected screens, allows them to open and
position windows or request fullscreen on any of those screens.

The HTML living standard specifies
[Tracking User Activation](https://html.spec.whatwg.org/multipage/interaction.html#tracking-user-activation),
to gate some web platform APIs on user interaction signals. The transient user
activation signal (e.g. from a mouse click) is required and consumed when web
application scripts open a popup window via `Window.open()`, and when they request

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

link Window.open() and Element.requestFullscreen() specs here

fullscreen via `Element.requestFullscreen()`.

## Problem

Web applications are limited in the ways that they can [Initiate Multi-Screen Experiences](https://github.com/w3c/window-placement/blob/main/EXPLAINER_initiating_multi_screen_experiences.md) across multi-display configurations. Specifically, opening a popup and transitioning the window to fullscreen requires two separate [user activations](https://html.spec.whatwg.org/multipage/interaction.html#tracking-user-activation), consumed by `window.open()` and `Element.requestFullscreen()` respectively. This results in a cumbersome user experience for web applications which utilize multiple displays.

Multiple partners/early adopters of the API have specifically requested this enhancement (e.g. [window.open should support the 'fullscreen' option](https://github.com/w3c/window-placement/issues/7)) and it's considered a prerequisite to at least one other feature request (e.g. [Feature request: Fullscreen support on multiple screens](https://github.com/w3c/window-placement/issues/92))

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Consider: "Multiple partners and early adopters of the Multi-Screen Window Placement API have specifically requested the ability to show one or more fullscreen popups from a single user gesture, to avoid the user friction entailed with making separate gestures to create each window and make each window fullscreen. For example: window.open should support the 'fullscreen' option, Feature Request: Initiate a multi-screen experience from a single user activation, Feature request: Fullscreen support on multiple screens."

This introduces the broader problem more clearly, even if the initial proposal only aims to solve one aspect.



This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

super minor nit: be consistent about double or single line breaks at the end of each section

## Use Cases

Some basic illustrative examples which may be achieved with this proposal are listed below:

* Video streaming app launches a video directly to fullscreen on a secondary display.
* 3D modelling app allows user to launch a preview in fullscreen on a secondary display.

Web applications may use this enhancement in conjunction with the existing [ability to enter fullscreen and open a popup from a single user gesture](https://w3c.github.io/window-placement/#usage-overview-initiate-multi-screen-experiences). By doing so, web applications can launch fullscreen experiences on the initial / primary display and a secondary display from a single user gesture. Some examples are listed below:

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

minor nit: avoid "/" here and elsewhere, use "and", "or", etc. Here, consider just "on two displays from a single"


* Financial app opens a fullscreen dashboard on the primary monitor and a fullscreen stock tracker window on a secondary display.
* Gaming app launches a fullscreen window on both primary and secondary displays for a continuous widescreen view.
* Virtual desktop app launches fullscreen windows on primary and secondary displays to mimic a remote monitor configuration.


## Goals

The goal of this document is to outline the necessary spec changes that would permit web applications to open a fullscreen window on a secondary display. It also aims to explore abuse and other security / privacy considerations. Some specific goals are as follows:

* Extend the `Window.open()` algorithm to change the behavior of the opened window based on parameters passed.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Maybe: "Extend the Window.open() API surface so scripts can request their popup windows to be shown in a fullscreen state."

This comment has been minimized.

Copy link
@bradtriebwasser

bradtriebwasser Oct 26, 2022

Author Owner

Hmm.. I'm hesitant to say "API surface" because we aren't formally changing anything in the API signature. We are just defining an algorithm to handle the somewhat arbitrary tokens passed in as features.

What about:
Extend the Window.open() algorithm so scripts can request their popup windows to be shown in a fullscreen state via a new tokenized parameter.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 26, 2022

Collaborator

Great!

* Explore the behavior of user agents when the launched window exits fullscreen.

The [Initiating Multi-Screen Experiences Explainer](https://github.com/w3c/window-placement/blob/main/EXPLAINER_initiating_multi_screen_experiences.md) covers some related goals (i.e. launching N fullscreen windows on N displays) not covered in this proposal.

## Proposal

Allow sites with the `window-placement` permission to open a fullscreen window on a secondary display from a single user gesture. When the device has multiple screens and `Window.open()` targets the secondary screen with an appropriate flag to create the window as fullscreen (via the `features` argument), the user agent should open the window as fullscreen on the display which contains the coordinates (`left`, `top`, `width`, `height`) of the new window. When the new window ultimately exits fullscreen, the window shall be restored as a popup style (bordered) window matching the coordinates originally passed to `Window.open()`.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

"on a secondary display" -> "on a specific display".

Remove or explain the requirements for multi-screen devices and specific popup dimensions. There is no obvious reason to prohibit (1) opening a fullscreen popup on a device with a single display nor (2) opening a fullscreen popup on the same display as the opener and restoring the default bounds, only the "popup,fullscreen" features are requested. We should describe these design considerations in more detail in the alternatives section, or similar. Consider:

Allow sites with the window-placement permission to open a fullscreen popup window on a specified display from a single user gesture. Scripts calling Window.open() to request a popup window could also include a new fullscreen boolean window feature.

Fullscreen popup requests could also include window bounds features (e.g. left, top, width, height), with positions specified relative to the multi-screen origin, to request that the window be made fullscreen on the screen containing those bounds, and also to be used as the popup window bounds after exiting fullscreen.



### Example Code

```js
const otherScreen = screenDetails.screens.find(s => s !== primaryScreen);
window.open(url, '_blank', `left=${otherScreen.availLeft},` +

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Include an even simpler example with just window.open(url, '_blank', 'popup,fullscreen');

`top=${otherScreen.availTop},` +
`width=${otherScreen.availWidth},` +
`height=${otherScreen.availHeight},` +
`fullscreen=true`);
```

### Spec Changes

The spec does not contain an exhaustive list of valid features in the `features` argument, however, the spec does contain procedures for determining if a [popup window is requested](https://html.spec.whatwg.org/multipage/window-object.html#popup-window-is-requested), and the specific `tokenizedFeatures` to look for. Following this model, the spec shall be updated to define a similar algorithm for checking if a **fullscreen window** is requested. A fullscreen window must also first be considered a popup window and also have `left` and `top` set in `features`. `left` and `top` determine which display the window will go fullscreen on, and the position of the popup when fullscreen is exited.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

As above, omit the left and top requirements, or rephrase to describe the meaning of their optional usage.


After [checking if a popup window is requested](https://html.spec.whatwg.org/multipage/window-object.html#popup-window-is-requested), add the following section:

To **check if a fullscreen window is requested**, given *tokenizedFeatures*:


1. If *tokenizedFeatures* is empty, then return false.
2. Let *popup* be the result of [checking if a popup window is requested](https://html.spec.whatwg.org/multipage/window-object.html#popup-window-is-requested).
3. If *popup* is false, then return false.
4. If *tokenizedFeatures*["`left`"] and *tokenizedFeatures*["`top`"] do not [exist](https://infra.spec.whatwg.org/#map-exists), then return false.
7. Let *fullscreen* be the result of [checking if a window feature is set](https://html.spec.whatwg.org/multipage/window-object.html#window-feature-is-set), given *tokenizedFeatures*, "`fullscreen`", and false.
8. If *fullscreen* is false, then return false.
9. Let *permissionState* be [request permission to use](https://w3c.github.io/permissions/#dfn-request-permission-to-use) "`window-placement`".

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Should this instead get the current permission state? Requesting is probably okay, since that algorithm permits, but does not require the user agent to prompt for permission or similar.

10. If *permissionState* is not "[granted](https://w3c.github.io/permissions/#dom-permissionstate-granted)", then throw a "[NotAllowedError](https://webidl.spec.whatwg.org/#notallowederror)" [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException).

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Hmm, I think it makes more sense to gracefully fallback to a non-fullscreen popup in this scenario, by just returning false. We could add a note that developer tools might log a warning or error or similar.

This comment has been minimized.

Copy link
@bradtriebwasser

bradtriebwasser Oct 26, 2022

Author Owner

Sounds good. I can't find any examples of specs mentioning dev tools, logging or something similar. It seems like its (implicitly) up to the user agent what they want to log and when? Do you know of any example specs that mention dev tools or logging?

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 26, 2022

Collaborator

No, so omitting that is fine, but making a note, at least in the explainer, might be helpful.

11. Return true.

### Open questions

#### Feature detection

There is no standard API for querying which features are supported in the [Widow.open()](https://html.spec.whatwg.org/multipage/window-object.html#dom-open-dev) `features` argument. There is no way for a web application to check that the user agent supports the `fullscreen` key in the `features` argument without calling the API and detecting if the resulting window is fullscreen (i.e. window boundary comparisons).

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

"without calling the API and detecting if the resulting popup window's Document.fullscreenElement is non-null." or similar.


The ability to detect supported keys of the `features` argument is out of scope for this proposal.

#### Exiting fullscreen (Restoring bounds)

The living standard algorithm for [exit fullscreen](https://fullscreen.spec.whatwg.org/#exit-fullscreen) does not specify the user agent's behavior of the restored window:

```
9. If resize is true, resize doc’s viewport to its "normal" dimensions.
```

It may be worth exploring an extension of the spec to specify that a window opened directly to fullscreen using this proposal, should be restored to the bounds originally specified in the (`left`, `top`, `width`, `height`). In the meantime, a user agent may decide how the window is restored.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

It might also be fine to adapt the window.open steps to set the window's initial bounds to those specified, and then make the window fullscreen. We don't need to dive too deep on the spec changes for that here, it would just be useful to describe the intent that when fullscreen is exited, the window is restored to the user-agent-adjusted window.open() specified bounds, or their inferred defaults.



#### Overlapping Fullscreen Windows / Invalid coordinates

This proposal & spec change does not define the behavior of the user agent when the requested coordinates (`left`, `right`) overlap an existing (fullscreen) browser window. The intention of this proposal is for web applications to launch popups on secondary displays, however that may not always happen due to user / developer errors or defects. For example, a web application creating a fullscreen window on in a single display environment with an already fullscreen browser window.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Avoid "secondary" here (like above). IIRC, Chrome (and Firefox?) exit fullscreen if a related popup is opened on the same display. This doesn't prohibit unrelated popups, nor multiple fullscreen windows being hosted on the same display simultaneously. We should explore these topics in more detail, but this section should avoid offering any prescriptive behavior at this point, and just raise these considerations.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Indeed, we'll want to consider implications of making a popup fullscreen on the same display as the opener, which may or may not be fullscreen (or even made fullscreen from the same user activation, per the fullscreen companion window feature)


Each user agent may define their own behavior and security safeguards for these scenarios. For example pre-existing protections prevent placing popups over fullscreen:
* Chrome exits fullscreen (see
[ForSecurityDropFullscreen](https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/web_contents.h?q=ForSecurityDropFullscreen))
* Firefox exits fullscreen
* Safari opens the popup in a separate fullscreen space

## Security Considerations

A notable security consideration stems from the fact that the web application may launch a fullscreen window on a display that the user is not looking at, since the [user activation](https://html.spec.whatwg.org/multipage/interaction.html#tracking-user-activation) (i.e. button click) may have occurred on another display which the user is focused on. The user may not notice the fullscreen window transition, nor the fullscreen bubble (e.g. Firefox's "\<origin\> is now full screen [Exit Full Screen (Esc)]" or Chrome's "Press [Esc] to exit full screen") which could allow for a malicious application to mimic other applications or the operating system without the user realizing that it is a browser window.

This is partially mitigated by gating this feature on the "`window-placement`" permission. Users should only grant permissions for [powerful features](https://w3c.github.io/permissions/#dfn-powerful-feature) to web applications that they trust.

This could also be mitigated further by having the user agent show the fullscreen bubble only when the user first interacts with the cross-display fullscreen window. In this scenario, there is a higher confidence that the user will see the fullscreen bubble.

## Privacy Considerations

This feature does not expose any information to sites, and there are no privacy considerations to note beyond those already documented in the Multi-Screen Window Placement [Privacy Considerations](https://www.w3.org/TR/window-placement/#privacy) section. The feature is gated behind the "`window-placement`" permission, so it does not expose any information outside what is already available from the API when permission is granted.

## Alternatives Considered

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

Let's include some potential approaches for handling popup dimension requirements and whether or not the popup targets the same display as the opener, etc. Ideally, we'll list some pros and cons for each alternative.


* Keeping the existing behavior. Web applications can create a popup, and then expand it's bounds to consume the entire display to mimic fullscreen content.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

nit: "it's" -> "its". Maybe rephrase "* Keeping the existing behavior. Web applications can create a popup window that fills the available display bounds, as a poor substitute of HTML fullscreen."

* This contains window borders and decorations not appropriate for some use cases.
* Allow a target-screen fullscreen request after opening a cross-screen popup
* This is less intuitive for the application developer and requires more complex changes to user activation signals which has a higher risk for misuse or abuse.

This comment has been minimized.

Copy link
@michaelwasserman

michaelwasserman Oct 25, 2022

Collaborator

It might be useful to extrapolate on this alternative and its complexities a little more

0 comments on commit a46dd4f

Please sign in to comment.