Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1100)

Issue 655373003: [ServiceWorker] Fix ResourceFetcher::isControlledByServiceWorker to support HTMLImports. (Closed)

Created:
6 years, 1 month ago by horo
Modified:
6 years, 1 month ago
Reviewers:
michaeln, Mike West
CC:
blink-reviews, Nate Chapin, gavinp+loader_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

[ServiceWorker] Fix ResourceFetcher::isControlledByServiceWorker to support HTMLImports. While loading the resources from the imported HTML, ResourceFetcher's m_documentLoader is NULL. In such cases whether the request is controlled by ServiceWorker or not is determined by the document loader of the frame. But in current code ResourceFetcher::isControlledByServiceWorker() always returns false. This patch fixes this by checking the document loader of the frame. BUG=427136 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=184535

Patch Set 1 #

Total comments: 2

Patch Set 2 : change assert #

Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -3 lines) Patch
M Source/core/fetch/ResourceFetcher.cpp View 1 1 chunk +7 lines, -3 lines 0 comments Download
M Source/core/fetch/ResourceLoader.cpp View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 17 (4 generated)
horo
michaeln@ Could you please review this?
6 years, 1 month ago (2014-10-27 07:14:34 UTC) #2
michaeln
The changes to ResourceFetcher::isControlledByServiceWorker() lgtm in light of how HTMLImports are loaded. But it doesn't ...
6 years, 1 month ago (2014-10-27 21:11:48 UTC) #3
horo
> The changes to ResourceFetcher::isControlledByServiceWorker() lgtm in light of > how HTMLImports are loaded. Thank ...
6 years, 1 month ago (2014-10-28 00:51:02 UTC) #4
horo
mkwst@ Could you please review this?
6 years, 1 month ago (2014-10-28 00:51:22 UTC) #6
michaeln
> I think the request mode of HTMLImports must be CORS. That the request mode ...
6 years, 1 month ago (2014-10-28 02:52:02 UTC) #8
horo
On 2014/10/28 02:52:02, michaeln wrote: > > I think the request mode of HTMLImports must ...
6 years, 1 month ago (2014-10-28 03:41:03 UTC) #9
Mike West
LGTM. https://codereview.chromium.org/655373003/diff/1/Source/core/fetch/ResourceFetcher.cpp File Source/core/fetch/ResourceFetcher.cpp (right): https://codereview.chromium.org/655373003/diff/1/Source/core/fetch/ResourceFetcher.cpp#newcode627 Source/core/fetch/ResourceFetcher.cpp:627: ASSERT(localFrame->loader().documentLoader()); Nit: I'd suggest moving this (and the ...
6 years, 1 month ago (2014-10-28 08:42:47 UTC) #10
Mike West
LGTM.
6 years, 1 month ago (2014-10-28 08:42:49 UTC) #11
horo
https://codereview.chromium.org/655373003/diff/1/Source/core/fetch/ResourceFetcher.cpp File Source/core/fetch/ResourceFetcher.cpp (right): https://codereview.chromium.org/655373003/diff/1/Source/core/fetch/ResourceFetcher.cpp#newcode627 Source/core/fetch/ResourceFetcher.cpp:627: ASSERT(localFrame->loader().documentLoader()); On 2014/10/28 08:42:47, Mike West wrote: > Nit: ...
6 years, 1 month ago (2014-10-28 14:36:37 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/655373003/40001
6 years, 1 month ago (2014-10-28 15:34:51 UTC) #14
commit-bot: I haz the power
Committed patchset #2 (id:40001) as 184535
6 years, 1 month ago (2014-10-28 16:36:19 UTC) #15
michaeln
> > > I think the request mode of HTMLImports must be CORS. > > ...
6 years, 1 month ago (2014-10-28 20:28:31 UTC) #16
horo
6 years, 1 month ago (2014-10-29 06:17:51 UTC) #17
Message was sent while issue was closed.
On 2014/10/28 20:28:31, michaeln wrote:
> > > > I think the request mode of HTMLImports must be CORS.
> > > 
> > > That the request mode is set differently depending on whether the page
> > > isControlledByServiceWorker is odd. It seems like the mode should be
> > > independent of whether a serviceworker is in the loop.
> > 
> > So the request mode of HTMLImports is always CORS regardless of whether the
> page
> > is controlled by the ServiceWorker or not.
> 
> Ah, good!
> 
> Apologies for the distracting questions. I think i'm making non sequitur
> comments here in response to a somewhat related chunk of code that's not
> directly involved in the HTMLImports loading case. This block of code from
> DocumentLoader::DocumentLoader() is what i'm wondering about. That looks like
> the it sets the request mode differently depending.
> 
>     // If the fetch request will be handled by the ServiceWorker, the
>     // FetchRequestMode of the request must be FetchRequestModeCORS or
>     // FetchRequestModeCORSWithForcedPreflight. Otherwise the ServiceWorker
can
>     // return a opaque response which is from the other origin site and the
>     // script in the page can read the content.
>     //
>     // We assume that ServiceWorker is skipped for sync requests by content/
>     // code.
>     if (m_async && !request.skipServiceWorker() &&
> m_document.fetcher()->isControlledByServiceWorker()) {
>         ResourceRequest newRequest(request);
>         // FetchRequestMode should be set by the caller. But the expected
value
>         // of FetchRequestMode is not speced yet except for XHR. So we set
here.
>         // FIXME: When we support fetch API in document, this value should not
>         // be overridden here.
>         if (options.preflightPolicy == ForcePreflight)
>            
>
newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORSWithForcedPreflight);
>         else
>            
newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS);
> 
>         m_fallbackRequestForServiceWorker = adoptPtr(new
> ResourceRequest(request));
>         m_fallbackRequestForServiceWorker->setSkipServiceWorker(true);
> 
>         loadRequest(newRequest, m_resourceLoaderOptions);
>         return;
>     }
> 
> From the looks of it, if the request is destined for processing by a
> serviceworker, the fetch mode will always be one of the two CORs variants. The
> comment suggests that this is to prevent the sw from responding to a
same-origin
> request with data sourced from another origin.

FetchRequestMode is used only when the request goes to the ServiceWorker.
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit...
So when the request will not go to the ServiceWorker we don't need to set
FetchRequestMode.

But it is better to set FetchRequestMode in the caller of
DocumentThreadableLoader regardless of whether the page is controlled by the
ServiceWorker or not.

Powered by Google App Engine
This is Rietveld 408576698