Bug 214124 - WebKit should allow beforeunload alerts from web pages with active Media Capture session regardless of interaction state
Summary: WebKit should allow beforeunload alerts from web pages with active Media Capt...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-07-08 22:40 PDT by Teodor
Modified: 2020-07-10 13:07 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Teodor 2020-07-08 22:40:48 PDT
Re: bug 169936

I believe the heuristic needs to include an active Media Capture session. When the user entrusts the site with "permanent" access to the microphone and/or camera, the site no longer requires an interaction before it can launch a Media Capture session (e.g., WebRTC call).

Under the current definition of activity a click or a keypress is required, which consequently means that if the person is participating in a WebRTC call, they can accidentally leave an active call by pressing F5 key, or closing the wrong tab, for example. Furthermore, the presence of onbeforeunload prompt will be inconsistent between sessions (the first time, user might see it because they have muted their audio prior to accidentally closing the tab, then the second time they would not see the prompt, as they haven't interacted with the page, leading them to believe that the site is at fault for not showing the prompt).

If the check for an active Media Capture session doesn't seem sufficient, session duration check may also be added. For example, a minimum session duration of 10 seconds may be used. This would allow users to quickly close the tab if they see content that they don't expect to see, while still preventing accidental reloads that may lead to loss of data. An example of such data loss is a file transfer via RTC Data Channel, when a reload would reset the download progress, potentially leading to irrecoverable loss of data, if for example the transfer was initiated by sender pasting a screenshot from the clipboard.

This proposal is cross-posted on Chromium and Firefox bug trackers.
Comment 1 Teodor 2020-07-10 04:28:22 PDT
This discussion on other bug trackers

Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1104149
Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1651962
Comment 2 Radar WebKit Bug Importer 2020-07-10 13:07:07 PDT
<rdar://problem/65359087>