Skip to content

Determine if we need to fire a terminated event in the receiving browsing context(s) #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markafoltz opened this issue Nov 21, 2016 · 2 comments

Comments

@markafoltz
Copy link
Contributor

Currently, the steps for terminating a presentation don't fire a terminated event on connections held by the receiver. If the process of closing the receiving browsing context could allow script to run, then we should consider firing this event (on the top-level or nested browsing contexts). Doing so may be redundant with the 'beforeunload' event however.

Reference material:

@markafoltz
Copy link
Contributor Author

Research notes

Using WhatWG [1] as a reference, there are three possible events that may fire during step 2 of presentation termination (unloading the presentation document).

  • onbeforeunload
  • onpagehide
  • onunload

Comparing other device specs:

  • As part of the "unload a document cleanup steps," the browser also "makes disappear" any open WebSocket objects [2], which closes the network transport but does not fire any events.
  • A MediaStreamTrack may fire an ended event [3].
  • A RTCPeerConnection does not clearly define what happens on unload. Presumably the user agent closes the peer connection, and those steps to close do not fire an event [4].
  • A BluetoothDevice does not spell out an document unload procedure, but the disconnection algorithm does fire an event [5].

[1] https://html.spec.whatwg.org/multipage/browsers.html#prompt-to-unload-a-document
[2] https://html.spec.whatwg.org/multipage/comms.html#make-disappear
[3] https://www.w3.org/TR/mediacapture-streams/#life-cycle-and-media-flow
[4] https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close
[5] https://webbluetoothcg.github.io/web-bluetooth/#clean-up-the-disconnected-device

@markafoltz
Copy link
Contributor Author

Noting that other specs are not very consistent in whether they event when closing resources on unload, and that firing a terminate event would be redundant with beforeunload for doing per-document cleanup, I'm inclined to not add a step to fire a terminate event on receiving presentation connections.

However, I do think we should set the presentation connection states to terminated before unloading the receiving browsing context so that state is available to beforeunload and other handlers.

Any other thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant