-
Notifications
You must be signed in to change notification settings - Fork 40
make cookie subscription name optional, url default to service worker… #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
index.bs
Outdated
| each member is a <dfn>cookie change subscription</dfn>. A [=cookie change subscription=] is | ||
| <span dfn-for="cookie change subscription"> | ||
| a [=tuple=] of <dfn>name</dfn> and <dfn>url</dfn>. | ||
| a [=tuple=] of an optional <dfn>name</dfn> and a <dfn>url</dfn>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really exist. I think we need to make name be a string or null or some such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried to add the types to that line
index.bs
Outdated
| 1. Let |subscription list| be |registration|'s associated [=cookie change subscription list=]. | ||
| 1. [=list/For each=] |entry| in |subscriptions|, run these steps: | ||
| 1. Let |name| be |entry|["{{CookieStoreGetOptions/name}}"]. | ||
| 1. Let |name| be the |entry|["{{CookieStoreGetOptions/name}}"] if it [=map/exists=]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesn't exist, what happens in the next step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made an if block and only attempt to normalize if name is provided
index.bs
Outdated
| 1. Let |url| be the result of [=basic URL parser|parsing=] |entry|["{{CookieStoreGetOptions/url}}"] with |settings|'s [=environment settings object/API base URL=]. | ||
| 1. Let |url| be |registration|'s [=service worker registration/scope url=]. | ||
| 1. If ["{{CookieStoreGetOptions/url}}"] [=map/exists=], then let |url| be the result of [=basic URL parser|parsing=] |entry|["{{CookieStoreGetOptions/url}}"] with |settings|'s [=environment settings object/API base URL=]. | ||
| 1. If |url| does not start with |registration|'s [=service worker registration/scope url=], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it's failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added "if |url| is failure, or ..." to the promise rejection in the next step but I can split if thats too long
|
FYI added some additional testing for a missing name and empty subscription web-platform-tests/wpt#56004 |
DCtheTall
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though I would wait until Anne also approves since he also left a review :)
index.bs
Outdated
| 1. If |url| does not start with |registration|'s [=service worker registration/scope url=], | ||
| then [=reject=] |p| with a {{TypeError}} and abort these steps. | ||
| 1. Let |name| be null. | ||
| 1. If ["{{CookieStoreGetOptions/name}}"] [=map/exists=]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You omitted |entry| here and in several cases below (also with different keys).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i think fixed
index.bs
Outdated
| 1. [=Normalize=] |name|. | ||
| 1. Let |url| be |registration|'s [=service worker registration/scope url=]. | ||
| 1. If ["{{CookieStoreGetOptions/url}}"] [=map/exists=], then set |url| to the result of [=basic URL parser|parsing=] |entry|["{{CookieStoreGetOptions/url}}"] with |settings|'s [=environment settings object/API base URL=]. | ||
| 1. If |url| is failure, or if |url| does not start with |registration|'s [=service worker registration/scope url=], then [=reject=] |p| with a {{TypeError}} and abort these steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the comma before "or" since we only have two conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, removed it
annevk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also consider linking "start with" to https://infra.spec.whatwg.org/#string-starts-with
| then [=iteration/continue=]. | ||
| 1. Let |cookieName| be the result of running [=UTF-8 decode without BOM=] on |cookie|'s [=cookie/name=]. | ||
| 1. If |cookieName| equals |subscription|'s [=cookie change subscription/name=], | ||
| 1. If |subscription|'s [=cookie change subscription/name=] is null, or if |cookieName| equals |subscription|'s [=cookie change subscription/name=], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. If |subscription|'s [=cookie change subscription/name=] is null, or if |cookieName| equals |subscription|'s [=cookie change subscription/name=], | |
| 1. If |subscription|'s [=cookie change subscription/name=] is null or |cookieName| is |subscription|'s [=cookie change subscription/name=], |
| 1. [=Normalize=] |name|. | ||
| 1. Let |url| be |registration|'s [=service worker registration/scope url=]. | ||
| 1. If |entry|["{{CookieStoreGetOptions/url}}"] [=map/exists=], then set |url| to the result of [=basic URL parser|parsing=] |entry|["{{CookieStoreGetOptions/url}}"] with |settings|'s [=environment settings object/API base URL=]. | ||
| 1. If |url| is failure or if |url| does not start with |registration|'s [=service worker registration/scope url=], then [=reject=] |p| with a {{TypeError}} and abort these steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. If |url| is failure or if |url| does not start with |registration|'s [=service worker registration/scope url=], then [=reject=] |p| with a {{TypeError}} and abort these steps. | |
| 1. If |url| is failure or |url| does not start with |registration|'s [=service worker registration/scope url=], then [=reject=] |p| with a {{TypeError}} and abort these steps. |
|
Note that before landing you'll need to adjust the commit message a bit to meet the guidelines. |
… scope
To fix #284 and #236 make the name optional and match to every available cookie in the service worker scope if it is not provided as an argument. The url of the subscription should default to be the service worker's scope url if omitted
Will add some WPTs beyond the missing/invalid url tests in https://github.com/web-platform-tests/wpt/blob/master/cookiestore/cookieStore_subscribe_arguments.https.any.js
Preview | Diff