Check "Bypass for network" flag in DocumentThreadableLoader
There is a bug that CORS requests can't work at all when "Bypass for network" in DevTools is enabled. Currently the CORS logic is implemented in DocumentThreadableLoader in the renderer process. If the page is not controlled by a service worker, DocumentThreadableLoader sets the Origin header for the CORS request and sends the request to the browser process. And the browser process sends the request to the network server. But if the page is controlled by a service worker, DocumentThreadableLoader just sends the original request to the browser process. And the browser process sends the request to the service worker. If the service worker doesn't call FetchEvent.respondWith(), the browser process returns a "FallbackRequired" response to the DocumentThreadableLoader. And DocumentThreadableLoader will start the CORS logic such as setting the Origin header. When "Bypass for network" is enabled, InspectorNetworkAgent::WillSendRequest() sets the request service worker mode to None. So the browser process doesn't pass the request to the service worker. But InspectorNetworkAgent::WillSendRequest() is called just before the renderer process sends the request to the browser process. So the request which should be sent to the service worker will directly go to the network server. This CL adds a check of the bypass flag in DocumentThreadableLoader, so that the CORS logic will be correctly executed. Bug: 771742 Change-Id: I923fc9f9e2e361aea3d25ace653c138707d9a682 Reviewed-on: https://chromium-review.googlesource.com/717960Reviewed-by:Will Chen <chenwilliam@chromium.org> Reviewed-by:
Dmitry Gozman <dgozman@chromium.org> Reviewed-by:
Takeshi Yoshino <tyoshino@chromium.org> Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Cr-Commit-Position: refs/heads/master@{#509578}
Showing
Please register or sign in to comment