Bug 175212 - Add test coverage for sendBeacon() keepalive flag
Summary: Add test coverage for sendBeacon() keepalive flag
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 147885
  Show dependency treegraph
 
Reported: 2017-08-04 14:43 PDT by Chris Dumez
Modified: 2017-08-09 09:08 PDT (History)
8 users (show)

See Also:


Attachments
Patch (3.68 KB, patch)
2017-08-04 14:46 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (3.70 KB, patch)
2017-08-04 15:04 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2017-08-04 14:43:58 PDT
Add test coverage for sendBeacon() keepalive flag.
Comment 1 Chris Dumez 2017-08-04 14:46:09 PDT
Created attachment 317294 [details]
Patch
Comment 2 youenn fablet 2017-08-04 14:59:25 PDT
Comment on attachment 317294 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=317294&action=review

> LayoutTests/http/wpt/beacon/keepalive-after-navigation.html:25
> +    }), 1000);

1000 may be too long in most cases and too short in others.
Why not trying to fetch every 50 ms until you have the correct content type and fail after a longer time like 5 seconds?

> LayoutTests/http/wpt/beacon/keepalive-after-navigation.html:35
> +    return pollResult(test, id) .then(result => {

s/ .//
Comment 3 Chris Dumez 2017-08-04 15:04:46 PDT
Created attachment 317299 [details]
Patch
Comment 4 youenn fablet 2017-08-04 15:11:04 PDT
Forgot to say, why wpt and not imported?
Are you planning to upstream these?
Comment 5 youenn fablet 2017-08-04 15:14:49 PDT
Comment on attachment 317299 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=317299&action=review

> LayoutTests/http/wpt/beacon/keepalive-after-navigation.html:15
> +function pollResult(test, id) {

Maybe I am missing something but this is not really polling in the sense that you try until you either succeed or time out?
If there is no need for polling and the fetch request will always happen after the beacon one, we just need to increase the timeout to 5000, right?
Comment 6 Chris Dumez 2017-08-04 15:17:22 PDT
This function is copied from other Beacon tests in WPT.

(In reply to youenn fablet from comment #5)
> Comment on attachment 317299 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=317299&action=review
> 
> > LayoutTests/http/wpt/beacon/keepalive-after-navigation.html:15
> > +function pollResult(test, id) {
> 
> Maybe I am missing something but this is not really polling in the sense
> that you try until you either succeed or time out?

We keep trying at regular intervals. I believe this is polling.

> If there is no need for polling and the fetch request will always happen
> after the beacon one, we just need to increase the timeout to 5000, right?

I do not understand this part. A beacon may be sent after a while, so we need to keep polling until it comes.
Comment 7 youenn fablet 2017-08-04 15:29:38 PDT
Comment on attachment 317299 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=317299&action=review

>>> LayoutTests/http/wpt/beacon/keepalive-after-navigation.html:15
>>> +function pollResult(test, id) {
>> 
>> Maybe I am missing something but this is not really polling in the sense that you try until you either succeed or time out?
>> If there is no need for polling and the fetch request will always happen after the beacon one, we just need to increase the timeout to 5000, right?
> 
> We keep trying at regular intervals. I believe this is polling.

It seems there is only one fetch being ever called with this code.
Is step_timeout expected to call fetch every 50 ms?
Comment 8 Chris Dumez 2017-08-04 15:44:10 PDT
(In reply to youenn fablet from comment #4)
> Forgot to say, why wpt and not imported?
> Are you planning to upstream these?

I will try to upstream it, yes.
Comment 9 Chris Dumez 2017-08-04 15:44:37 PDT
(In reply to youenn fablet from comment #7)
> Comment on attachment 317299 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=317299&action=review
> 
> >>> LayoutTests/http/wpt/beacon/keepalive-after-navigation.html:15
> >>> +function pollResult(test, id) {
> >> 
> >> Maybe I am missing something but this is not really polling in the sense that you try until you either succeed or time out?
> >> If there is no need for polling and the fetch request will always happen after the beacon one, we just need to increase the timeout to 5000, right?
> > 
> > We keep trying at regular intervals. I believe this is polling.
> 
> It seems there is only one fetch being ever called with this code.
> Is step_timeout expected to call fetch every 50 ms?

Yes, we need to call fetch() at regular interval to ask the server if it received the beacon.
Comment 10 Chris Dumez 2017-08-04 16:22:04 PDT
Comment on attachment 317299 [details]
Patch

Clearing flags on attachment: 317299

Committed r220304: <http://trac.webkit.org/changeset/220304>
Comment 11 Chris Dumez 2017-08-04 16:22:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Radar WebKit Bug Importer 2017-08-04 16:22:53 PDT
<rdar://problem/33734986>
Comment 13 youenn fablet 2017-08-04 16:30:39 PDT
> Yes, we need to call fetch() at regular interval to ask the server if it
> received the beacon.

Looking at step_timeout, it does not use setInterval and is calling setTimeout once.
It seems to me there will be only one fetch being called, fetch being done after waiting for 50 ms.

Also, even if fetch is called several times, it would seem better to wait for the completion of the first fetch before triggering a new fetch.
Comment 14 Chris Dumez 2017-08-04 16:32:00 PDT
(In reply to youenn fablet from comment #13)
> > Yes, we need to call fetch() at regular interval to ask the server if it
> > received the beacon.
> 
> Looking at step_timeout, it does not use setInterval and is calling
> setTimeout once.
> It seems to me there will be only one fetch being called, fetch being done
> after waiting for 50 ms.
> 
> Also, even if fetch is called several times, it would seem better to wait
> for the completion of the first fetch before triggering a new fetch.

oh, the switch to 50ms is likely going to cause flakiness then. I'll follow-up :(