RESOLVED FIXED 175212
Add test coverage for sendBeacon() keepalive flag
https://bugs.webkit.org/show_bug.cgi?id=175212
Summary Add test coverage for sendBeacon() keepalive flag
Chris Dumez
Reported 2017-08-04 14:43:58 PDT
Add test coverage for sendBeacon() keepalive flag.
Attachments
Patch (3.68 KB, patch)
2017-08-04 14:46 PDT, Chris Dumez
no flags
Patch (3.70 KB, patch)
2017-08-04 15:04 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2017-08-04 14:46:09 PDT
youenn fablet
Comment 2 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/ .//
Chris Dumez
Comment 3 2017-08-04 15:04:46 PDT
youenn fablet
Comment 4 2017-08-04 15:11:04 PDT
Forgot to say, why wpt and not imported? Are you planning to upstream these?
youenn fablet
Comment 5 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?
Chris Dumez
Comment 6 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.
youenn fablet
Comment 7 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?
Chris Dumez
Comment 8 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.
Chris Dumez
Comment 9 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.
Chris Dumez
Comment 10 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>
Chris Dumez
Comment 11 2017-08-04 16:22:05 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 12 2017-08-04 16:22:53 PDT
youenn fablet
Comment 13 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.
Chris Dumez
Comment 14 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 :(
Note You need to log in before you can comment on or make changes to this bug.