Bug 179498 - Add support for service worker generated redirections
Summary: Add support for service worker generated redirections
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-09 11:34 PST by youenn fablet
Modified: 2017-11-29 15:04 PST (History)
10 users (show)

See Also:


Attachments
Patch (25.50 KB, patch)
2017-11-09 11:43 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (27.78 KB, patch)
2017-11-09 23:45 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (30.22 KB, patch)
2017-11-14 20:10 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (2.81 MB, application/zip)
2017-11-14 21:13 PST, Build Bot
no flags Details
Archive of layout-test-results from ews116 for mac-elcapitan (2.87 MB, application/zip)
2017-11-14 21:50 PST, Build Bot
no flags Details
Patch (30.16 KB, patch)
2017-11-15 09:38 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (27.60 KB, patch)
2017-11-15 13:35 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (27.46 KB, patch)
2017-11-15 14:27 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (31.36 KB, patch)
2017-11-17 13:33 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (32.31 KB, patch)
2017-11-29 13:54 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Rebasing (26.26 KB, patch)
2017-11-29 13:59 PST, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2017-11-09 11:34:16 PST
Add support for service worker generated redirections
Comment 1 youenn fablet 2017-11-09 11:43:48 PST
Created attachment 326472 [details]
Patch
Comment 2 youenn fablet 2017-11-09 23:45:58 PST
Created attachment 326567 [details]
Patch
Comment 3 youenn fablet 2017-11-14 20:10:58 PST
Created attachment 326962 [details]
Patch
Comment 4 Build Bot 2017-11-14 21:12:59 PST
Comment on attachment 326962 [details]
Patch

Attachment 326962 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/5240757

New failing tests:
http/tests/workers/service/service-worker-redirection-fetch.https.html
Comment 5 Build Bot 2017-11-14 21:13:00 PST
Created attachment 326967 [details]
Archive of layout-test-results from ews107 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 6 Build Bot 2017-11-14 21:50:51 PST
Comment on attachment 326962 [details]
Patch

Attachment 326962 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/5240916

New failing tests:
fast/parser/xml-error-adopted.xml
Comment 7 Build Bot 2017-11-14 21:50:53 PST
Created attachment 326968 [details]
Archive of layout-test-results from ews116 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 8 youenn fablet 2017-11-15 09:38:41 PST
Created attachment 326992 [details]
Patch
Comment 9 youenn fablet 2017-11-15 13:35:36 PST
Created attachment 327016 [details]
Patch
Comment 10 youenn fablet 2017-11-15 14:27:28 PST
Created attachment 327026 [details]
Patch
Comment 11 Alex Christensen 2017-11-16 18:18:23 PST
Comment on attachment 327026 [details]
Patch

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

> Source/WebCore/platform/network/ResourceRequestBase.cpp:130
> +ResourceRequest ResourceRequestBase::redirectedRequest(const ResourceResponse& redirectResponse) const

This feels really hacky and fragile to me, kind of like synthesizeRedirectResponseIfNecessary but worse.  I don't think it's designed well.  Is there a relevant specification?
Comment 12 youenn fablet 2017-11-16 18:40:29 PST
(In reply to Alex Christensen from comment #11)
> Comment on attachment 327026 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=327026&action=review
> 
> > Source/WebCore/platform/network/ResourceRequestBase.cpp:130
> > +ResourceRequest ResourceRequestBase::redirectedRequest(const ResourceResponse& redirectResponse) const
> 
> This feels really hacky and fragile to me, kind of like
> synthesizeRedirectResponseIfNecessary but worse.  I don't think it's
> designed well.  Is there a relevant specification?

The closest spec is https://fetch.spec.whatwg.org/#http-redirect-fetch.
We could centralize the handling of redirections currently done in various ResourceHandle/NetworkDataTask places.
Comment 13 youenn fablet 2017-11-17 13:33:25 PST
Created attachment 327224 [details]
Patch
Comment 14 youenn fablet 2017-11-17 13:33:57 PST
Improved a little bit the computation of redirection response based on CFNetwork code.
Comment 15 Darin Adler 2017-11-22 11:42:24 PST
Comment on attachment 327224 [details]
Patch

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

> Source/WebCore/platform/network/ResourceRequestBase.h:176
> +    WEBCORE_EXPORT static bool compare(const ResourceRequest&, const ResourceRequest&);

A function named "compare" is confusing. What does "true" mean for "compare"?

> Source/WebCore/platform/network/ResourceResponseBase.h:50
> +    static bool isRedirectionStatusCode(int httpStatusCode) { return httpStatusCode == 301 || httpStatusCode == 302 || httpStatusCode == 303 || httpStatusCode == 307 || httpStatusCode == 308; }

I think the argument could just be named "code" and this line would be a lot shorter. And if HTTP is important then it should be in the function name; not just the argument name.

> Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp:133
> +        m_redirectionStatus = RedirectionStatus::None;
> +        ASSERT_NOT_REACHED();

I suggest putting ASSERT_NOT_REACHED first.
Comment 16 youenn fablet 2017-11-29 13:53:45 PST
Comment on attachment 327224 [details]
Patch

Thanks for the review.

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

>> Source/WebCore/platform/network/ResourceRequestBase.h:176
>> +    WEBCORE_EXPORT static bool compare(const ResourceRequest&, const ResourceRequest&);
> 
> A function named "compare" is confusing. What does "true" mean for "compare"?

Will change to equal.
We should probably change platformCompare as well at some point.

>> Source/WebCore/platform/network/ResourceResponseBase.h:50
>> +    static bool isRedirectionStatusCode(int httpStatusCode) { return httpStatusCode == 301 || httpStatusCode == 302 || httpStatusCode == 303 || httpStatusCode == 307 || httpStatusCode == 308; }
> 
> I think the argument could just be named "code" and this line would be a lot shorter. And if HTTP is important then it should be in the function name; not just the argument name.

"code" is indeed fine.

>> Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp:133
>> +        ASSERT_NOT_REACHED();
> 
> I suggest putting ASSERT_NOT_REACHED first.

OK
Comment 17 youenn fablet 2017-11-29 13:54:27 PST
Created attachment 327898 [details]
Patch for landing
Comment 18 WebKit Commit Bot 2017-11-29 13:55:30 PST
Comment on attachment 327898 [details]
Patch for landing

Rejecting attachment 327898 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-02', 'apply-attachment', '--no-update', '--non-interactive', 327898, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
ing file LayoutTests/ChangeLog
Hunk #1 succeeded at 1 with fuzz 3.
patching file LayoutTests/http/tests/workers/service/resources/service-worker-redirection-fetch-worker.js
patching file LayoutTests/http/tests/workers/service/service-worker-redirection-fetch.https-expected.txt
patching file LayoutTests/http/tests/workers/service/service-worker-redirection-fetch.https.html

Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Full output: http://webkit-queues.webkit.org/results/5408289
Comment 19 youenn fablet 2017-11-29 13:59:20 PST
Created attachment 327900 [details]
Rebasing
Comment 20 WebKit Commit Bot 2017-11-29 15:03:53 PST
Comment on attachment 327900 [details]
Rebasing

Clearing flags on attachment: 327900

Committed r225297: <https://trac.webkit.org/changeset/225297>
Comment 21 WebKit Commit Bot 2017-11-29 15:03:55 PST
All reviewed patches have been landed.  Closing bug.
Comment 22 Radar WebKit Bug Importer 2017-11-29 15:04:41 PST
<rdar://problem/35758489>