Bug 194897

Summary: navigator.sendBeacon does not work on visibilitychange callback for document unload
Product: WebKit Reporter: Bastien Caudan <bastien.caudan>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: cdumez, code, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Macintosh   
OS: macOS 10.14   
See Also: https://bugs.webkit.org/show_bug.cgi?id=116769

Description Bastien Caudan 2019-02-21 06:22:40 PST
With the example from the beacon spec (https://w3c.github.io/beacon/):

document.addEventListener('visibilitychange', function() {
  if (document.visibilityState === 'hidden') {
    navigator.sendBeacon('/collector', data);

From manual tests on hidden cases, navigator.sendBeacon is triggered correctly when:
- the browser is minimized.
- the document is not the active tab

But navigator.sendBeacon is not triggered when:
- the browser unload the document

Other browsers that support the Beacon API allow these requests to be sent.
Comment 1 Radar WebKit Bug Importer 2019-02-21 20:49:37 PST
Comment 2 Daniel 2019-06-21 14:08:29 PDT
The visibilitychange event don’t fire at all during unload. This is a duplicate of issue #116769.