Skip to content

Conversation

@jakearchibald
Copy link
Contributor

Fixes whatwg/fetch#303 (comment).

Related fetch PR whatwg/fetch#435.

@jakearchibald
Copy link
Contributor Author

Once this lands I still need to expose service worker clients to fetch events.

Copy link
Collaborator

@jungkees jungkees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this assumes https://fetch.spec.whatwg.org/#concept-http-fetch will change to invoke Handle Fetch even if the client is a SW, right? For that, I think this patch can still land as setting the skip-service-worker flag makes it bypass the Handle Fetch. But I would like to confirm we expect add()/addAll() and importScripts() go through foreign fetch, right?

Copy link
Collaborator

@jungkees jungkees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to check if you wanted to introduce a new flag.

docs/index.bs Outdated
1. If |r|'s [=request/url=]'s [=url/scheme=] is not one of "<code>http</code>" and "<code>https</code>", then:
1. [=fetch/Terminate=] all the ongoing <a>fetches</a> initiated by |requests| with reason *fatal*.
1. Break the loop.
1. If |r|'s [=request/client=]'s [=environment settings object/global object=] is a {{ServiceWorkerGlobalScope}} object, set |request|'s [=skip-local-service-worker flag=].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you introducing a new flag here? Or did you intend to use skip-service-worker flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Missed that. I'll check that.

docs/index.bs Outdated
1. Let |serviceWorker| be |request|'s [=request/client=]'s [=environment settings object/global object=]'s [=ServiceWorkerGlobalScope/service worker=].
1. If |serviceWorker|'s <a>imported scripts updated flag</a> is unset, then:
1. Let |registration| be |serviceWorker|'s [=containing service worker registration=].
1. Set |request|'s [=skip-local-service-worker flag=].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@jungkees
Copy link
Collaborator

Also I think V1 should also take this behavior. Could you apply it to V1?

@jakearchibald
Copy link
Contributor Author

Note whatwg/fetch#435 (comment) - skip-local-service-worker is going to change to become an enum.

@jakearchibald
Copy link
Contributor Author

Yeah I'll add it to v1 too

@jungkees jungkees mentioned this pull request Dec 15, 2016
annevk pushed a commit to whatwg/fetch that referenced this pull request Feb 14, 2017
This allows certain fetches within service workers to trigger fetch events. It also makes interception of redirects by foreign fetch possible.

Tests: web-platform-tests/wpt#4518.

Related service worker PR: w3c/ServiceWorker#1025.

Fixes #303 and fixes #362.
@jakearchibald
Copy link
Contributor Author

@jungkees The tests & fetch spec part of this have merged now. Happy for this to merge too?

@jakearchibald jakearchibald merged commit 39ea8ff into master Feb 16, 2017
@jungkees jungkees deleted the sw-fetch-within-sw branch February 16, 2017 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants