Skip to content
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

Bikeshed cleanup #1014

Merged
merged 17 commits into from
Dec 1, 2016
Merged

Bikeshed cleanup #1014

merged 17 commits into from
Dec 1, 2016

Conversation

jakearchibald
Copy link
Contributor

Bikeshed is now building the spec without complaining, aside from the lack of privacy considerations.

I'm now going to go through a diff of this and the current spec and see if anything's broken.

I've made some intentional changes along the way, and I'll detail them here for review.

Once it's in a good place I'll merge in the changes that have been made to the spec since I started.

@jakearchibald
Copy link
Contributor Author

+@annevk and @jungkees for reviewing. Apologies in advance.

@jakearchibald
Copy link
Contributor Author

Found a few cases where the auto-linker is picking up the wrong thing. Fixing now…

@jakearchibald
Copy link
Contributor Author

Haha ok it's pretty broken, don't bother reviewing until I wave. A few markdown issues related to nested lists caught me out. It's different to github.

@jakearchibald
Copy link
Contributor Author

Ok, it's in a somewhat better shape now.

Here are the intentional (larger) changes I made

  • I removed the "storage considerations" section. It felt redundant as it's all handled by other specs.
  • I changed all the <em class="rfc2119" title="MUST"> style rfc2119 references to be plain <em>. The semantics of these terms are covered elsewhere.
  • Removed reference to sysapps "alarms" API
  • "script resource map", "scope to registration map" are now an infra maps
  • I've updated examples to use newer ES features like arrow functions
  • We had a few instances of return <a>context object</a>’s <a>relevant settings object</a> <var>client</var>, were client wasn't used. I replaced these with return <a>context object</a>’s <a>relevant settings object</a>

@jungkees
Copy link
Collaborator

Great move. Was keen to change the following:

"script resource map", "scope to registration map" are now an infra maps

I've updated examples to use newer ES features like arrow functions

I'll review.

@jungkees
Copy link
Collaborator

jungkees commented Nov 25, 2016

Three commits are missing from the master: eda15f6, c2a518b, fd1fd35 (Done in 92cdc32)

I guess rebasing seems harder than merging them manually? If so, I can help. Also shaping V1 would be a job. Wouldn't it be easier to separate it out from the Nightly when we're ready for the last WD before moving to CR?

@jungkees
Copy link
Collaborator

I removed the "storage considerations" section. It felt redundant as it's all handled by other specs.

It seems we can keep Storage Considerations with some non-normative words? People tend to ask what happens if the storage with the Cache API gets full. Yeah, I agree better wording's needed to keep it.

@annevk
Copy link
Member

annevk commented Nov 25, 2016

I guess rebasing seems harder than merging them manually?

You need to rebase if you want to land this successfully.

@jungkees
Copy link
Collaborator

Suggestion: what about changing function names to lowercase? The history they are currently uppercase for each word is that I tried to use ECMAScript internal method notation in the early days. And later we dropped the double-brackets. I think we can just move to lowercase as in the other specs.

@jungkees
Copy link
Collaborator

@annevk, do you see 100 char wrapping rule is really helpful?

@jakearchibald
Copy link
Contributor Author

@jungkees yeah, I'm aware that work on master continues as I'm working on this. Let's manually merge them once the branch is done.

When it comes to V1… hmm. I'd rather not introduce a whole new version. I'll take a look at how much effort it would be to convert V1.

@jungkees
Copy link
Collaborator

@jungkees yeah, I'm aware that work on master continues as I'm working on this. Let's manually merge them once the branch is done.

OK. The important bit would be to not loose the commit history. Let's leave the relevant description when manual merging is needed.

@annevk
Copy link
Member

annevk commented Nov 25, 2016

@jungkees wrapping tends to make diffs more readable, but sometimes not.

@jakearchibald
Copy link
Contributor Author

I'm in two minds about it. The lack of wrapping make it a lot easier to do multi-cursor editing and find/replace during this PR.

@annevk
Copy link
Member

annevk commented Nov 25, 2016

Whenever I wrap for DOM, Fetch, etc. I leave terms unwrapped to make finding and replacing them easy, but HTML follows a different convention...

I don't really understand what you mean by manually merging btw. Is the plan to keep the git history linear?

@jakearchibald
Copy link
Contributor Author

Sorry, yes, I mean "manually rebase" I guess. Intent is to remain linear.

@jakearchibald
Copy link
Contributor Author

jakearchibald commented Nov 25, 2016

I've reviewed the diff with the HTML output from 0dcd798 (the current branch point) and it looks good to me. Going to give it a second reading to be sure.

Btw, temporarily re-adding the "storage considerations" section makes the diff a lot more readable.

@jungkees
Copy link
Collaborator

@jakearchibald, I rebased it onto master and fixed some minor errors. I still encounters one bikeshed error though:

FATAL ERROR: Multiple declarations of the '' algorithm.

Do you have any clue? I think the current snapshot seems good-to-go after resolving the above issue. Re V1, do you have any suggestion how to shape it?

@annevk
Copy link
Member

annevk commented Nov 29, 2016

You can find out the line for an error with bikeshed spec -l: https://tabatkins.github.io/bikeshed/#cli-spec.

@annevk
Copy link
Member

annevk commented Nov 29, 2016

No, those ! indicate the abstract operation does not throw. They have meaning and should probably not be removed. Curious that Service Workers plays with ArrayBuffer though.

@jakearchibald
Copy link
Contributor Author

@annevk oops. TIL.

Going to try to get bikeshed working locally so I can investigate that error. However, it seems to be failing with commits that I'm pretty certain it was working with a few days ago, so it might be a bikeshed issue.

@jakearchibald
Copy link
Contributor Author

Yeah this is a bikeshed regression speced/bikeshed#884

Copy link
Collaborator

@mkruisselbrink mkruisselbrink left a comment

Choose a reason for hiding this comment

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

Awesome cleanup. Thanks for cleaning up my mess :) I haven't quite made it through the entire thing yet, but it looks good I think. Just some random ideas for possible future improvements.


<p>The <a href="#dfn-service-worker">service worker</a> is designed first to redress this balance by providing a Web Worker context, which can be started by a runtime when navigations are about to occur. This event-driven worker is registered against an origin and a path (or pattern), meaning it can be consulted when navigations occur to that location. Events that correspond to network requests are dispatched to the worker and the responses generated by the worker may override default network stack behavior. This puts the <a href="#dfn-service-worker">service worker</a>, conceptually, between the network and a document renderer, allowing the <a href="#dfn-service-worker">service worker</a> to provide content for documents, even while offline.</p>
The <a for="/">service worker</a> is designed first to redress this balance by providing a Web Worker context, which can be started by a runtime when navigations are about to occur. This event-driven worker is registered against an origin and a path (or pattern), meaning it can be consulted when navigations occur to that location. Events that correspond to network requests are dispatched to the worker and the responses generated by the worker may override default network stack behavior. This puts the <a for="/">service worker</a>, conceptually, between the network and a document renderer, allowing the <a for="/">service worker</a> to provide content for documents, even while offline.
Copy link
Collaborator

Choose a reason for hiding this comment

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

depending on how shorthand-rather-than-html you want to go, all these "<a for="/">service worker</a>" bits could be written as [=/service worker=].

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like it! [=/service worker=], [=ServiceWorkerGlobalScope/service worker=] work fine and are shorter to type.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Replaced all the <a for="thing">a dfn for thing</a> style anchors with [=thing/a dfn for thing=] style shorthands. I didn't change the existing <a>to dfn</a> (without for attribute) occurrences yet. Would it be better to change all of them to [=to dfn=]?

</ol>
The <dfn method for="ServiceWorker"><code>postMessage(|message|, |transfer|)</code></dfn> method *must* run these steps:

1. If the {{ServiceWorker/state}} attribute value of the <a>context object</a> is "<code>redundant</code>", <a>throw</a> an "{{InvalidStateError}}" exception and abort these steps.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"<code>redundant</code>" could also be written as {{"redundant"}} (or {{ServiceWorkerState/"redundant"}} to get proper cross-references for enum values.

Copy link
Collaborator

Choose a reason for hiding this comment

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

{{ServiceWorkerState/"redundant"}} would be nice.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Changed them to {{"enumvalue"}} style. I didn't put ServiceWorkerState/ within the spec. Also I left them "<code>string</code>" when they represent just a string.


A <a for="/">service worker</a> has an associated <dfn export id="dfn-service-worker-global-object" for="service worker">global object</dfn> (a {{ServiceWorkerGlobalScope}} object or null).

A <a for="/">service worker</a> is dispatched a set of <dfn export id="dfn-lifecycle-events">lifecycle events</dfn>, <a event for="ServiceWorkerGlobalScope">install</a> and <a event for="ServiceWorkerGlobalScope">activate</a>, and <dfn export id="dfn-functional-events">functional events</dfn> including <a event for="ServiceWorkerGlobalScope">fetch</a>.
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're a bit inconsistent with how you link to event types. Here you use the full <a ...> syntax, while in other places you would have written this as {{install!!event}} (or {{ServiceWorkerGlobalScope/install!!event}} if you want to be explicit about which install event you're talking about).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use {{install!!event}}. I think it'd not be ambiguous without the event target within the spec.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Done.


<p class="example">In the example in section 3.1.1, the value of <code>registration.scope</code>, obtained from <code>navigator.serviceWorker.ready.then(function(registration) { console.log(registration.scope); })</code> for example, will be "<code>https://example.com/</code>".</p>
<div class="example">
In the example in section 3.1.1, the value of <code>registration.scope</code>, obtained from <code>navigator.serviceWorker.ready.then(registration => console.log(registration.scope))</code> for example, will be "<code>https://example.com/</code>".
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe change section 3.1.1 to [[#service-worker-url]] to get auto-linking to that section? Although not sure if having the section title in the resulting link will make it more or less readable here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Changed it. Enabling a link seems better.

1. Run the following substeps <a>in parallel</a>:
1. Let |array| be an empty array.
1. <a for="map">For each</a> |key| → |value| of <a>scope to registration map</a>:
1. If the <a for="environment settings object">origin</a> of the result of <a lt="URL parser">parsing</a> |key| is the <a lt="same origin">same</a> as |client|'s <a for="environment settings object">origin</a>, and |value|'s <a>uninstalling flag</a> is unset, add the {{ServiceWorkerRegistration}} object associated with |value| to the |array|.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The first origin here should be <a for="url"> as it's referring to the origin of a url rather than that of a settings object (I know, I made quite a mess about linking to the correct origin definition whenever an origin was used).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Addressed.

@@ -765,7 +716,7 @@ spec: rfc7231; urlPrefix: https://tools.ietf.org/html/rfc7231
<tr>
<td><dfn event id="service-worker-container-controllerchange-event"><code>controllerchange</code></dfn></td>
<td>{{Event}}</td>
<td>The <a for="ServiceWorkerContainer">service worker client</a>'s <a>active service worker</a> changes. (See step 9.2 of the <a href="#activation-algorithm">Activate</a> algorithm. The <a href="#dfn-skip-waiting-flag">skip waiting flag</a> of a <a href="#dfn-service-worker">service worker</a> causes <a href="#activation-algorithm">activation</a> of the <a href="#dfn-service-worker-registration">service worker registration</a> to occur while <a href="#dfn-service-worker-client">service worker clients</a> are <a href="#dfn-use">using</a> the <a href="#dfn-service-worker-registration">service worker registration</a>, {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the <a href="#dfn-active-worker">active worker</a> as the <a href="#dfn-service-worker">service worker</a> that <a href="#dfn-control">controls</a> the <a href="#dfn-service-worker-client">service worker client</a>.)</td>
<td>The <a for="ServiceWorkerContainer">service worker client</a>'s <a>active service worker</a> changes. (See step 9.2 of the <a>Activate</a> algorithm. The <a>skip waiting flag</a> of a <a for="/">service worker</a> causes <a lt="activate">activation</a> of the <a for="/">service worker registration</a> to occur while <a for="/">service worker clients</a> are <a>using</a> the <a for="/">service worker registration</a>, {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the <a>active worker</a> as the <a for="/">service worker</a> that <a>controls</a> the <a for="/">service worker client</a>.)</td>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tabatkins hmm, would be nice if bikeshed provided a way to link to specific steps in an algorithm that would get rendered as "step 9.2", but wouldn't require hard-coding and manually keeping up to date the numbering (like it already sort of supports for sections).

Copy link
Member

Choose a reason for hiding this comment

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

Yup, that's tracked as speced/bikeshed#796 already. ^_^

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, this will help a lot for both discussion and writing.

@jungkees
Copy link
Collaborator

@mkruisselbrink, your comments are great. I'll address them.

@jungkees
Copy link
Collaborator

@jakearchibald, I'm working on V1.

@jakearchibald
Copy link
Contributor Author

Haha I'm running out of things to do on my flight home. Thanks for taking a look, let me know if there's anything I can do.

@jungkees
Copy link
Collaborator

Haha, that's OK. I just uploaded a patch having merged the changes to V1. Please review and merge this PR if it looks good.

@jakearchibald jakearchibald merged commit bec528d into master Dec 1, 2016
@jakearchibald jakearchibald deleted the bikeshed-cleanup branch December 1, 2016 08:57
@jakearchibald
Copy link
Contributor Author

Aaaaand we're merged! Thank you @jungkees @mkruisselbrink and @annevk.

@jungkees jungkees changed the title (WIP) Bikeshed cleanup Bikeshed cleanup Dec 1, 2016
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.

5 participants