michaelwasserman/window-placement-demo

Request: Please provide minimal working example and add-on to documentation

Closed this issue · 1 comments

Thank you for this great repository, which is very helpful. The window placement, the fullscreen request to another screen, and the capabilities delegation are well documented and I can use them in my own work. However, I fail to understand one aspect: How could I, from one window and in a single user interaction,

  1. Open another window and
  2. make this window fullscreen

Example 1:

<html><head></head><body>
  <button id="go">GO</button>
  <script>
    document.getElementById ("go").addEventListener ("click",() => 
      window.open ("popup.html", "_blank", "left=100,top=100,width=300,height=300")
        .postMessage("msg", {targetOrigin: "https://" + window.location.host, delegate: "fullscreen"}) );
  </script>
</body></html>

throws delegation is not allowed without transient user activation.

Example 2:

<html><head></head><body>
  <button id="go">GO</button>
  <script>
    let win = window.open ("popup.html", "_blank", "left=100,top=100,width=300,height=300");
    document.getElementById ("go").addEventListener ("click",() => win.postMessage("msg", {targetOrigin: "https://" + window.location.host, delegate: "fullscreen"}) );
  </script>
</body></html>

opens the window before the user interaction, which is not what I want.

Popup is as expected:

<html><head></head><body>I am POPUP
<script>window.addEventListener ("message", () => {document.body.requestFullscreen();});</script>
</body>
</html>

Your extensive example does something else and in a sense is not a minimal working demo of the companion window feature. I seem unable to distill the core idea of your work in a way that enables me to achieve my described goal.

So either I misunderstand your README or it lacks crucial information on opening companion windows. The linked documents on companion windows also did not help me solve this problem, as they only describe the implementation in terms of internal slots and not in terms of programmer-accessible API calls.

See the new explainer and chromestatus feature for opening fullscreen popup windows, which is otherwise not possible. I'll update the demo as that becomes available for testing.

The fullscreen companion window feature simply allows script to request fullscreen for an existing window on a specific screen of a multi-screen device and then also open a popup window with a single user gesture. It's not currently possible to make the popup fullscreen from the same gesture. This spec section attempts to explain that intent and usage. Apologies for unclear or overly technical wording there.