Re: [w3c/ServiceWorker] Use right value for Resolve Job Promise (#1054)

domenic approved this pull request.

I don't understand the context of these algorithms very well but this looks quite good in terms of event loop stuff. I left a minor nit about the exception object creation, but it's probably OK.

>        : Output
       :: none
 
-      1. If |job|'s [=job/client=] is not null, <a>queue a task</a> to reject |job|'s [=job/job promise=] with |reason| on |job|'s [=job/client=]'s <a>responsible event loop</a> using the <a>DOM manipulation task source</a> as the <a>task source</a>.
-      1. For each |equivalentJob| in |job|'s <a>list of equivalent jobs</a>:
-          1. If |equivalentJob|'s [=job/client=] is not null, <a>queue a task</a> to reject |equivalentJob|'s [=job/job promise=] with |reason| on |equivalentJob|'s [=job/client=]'s <a>responsible event loop</a> using the <a>DOM manipulation task source</a> as the <a>task source</a>.
+      1. If |job|'s [=job/client=] is not null, [=queue a task=], on |job|'s [=job/client=]'s [=responsible event loop=] using the [=DOM manipulation task source=], to reject |job|'s [=job/job promise=] with an exception that is a copy of |reason|, in |job|'s [=job/client=]'s [=environment settings object/Realm=].

"A copy of" is a bit imprecise, but it's probably OK. I guess the truly rigorous way to do this would be to just have the reason be the type of the exception (plus maybe any data necessary to construct a good message string, but that's kind of out of scope for the spec). Then you actually create the exception object during the queued task.

This assumes _reason_ is only ever UA-created. If it is user-code-created, then we have a bigger problem.

>        1. For each |equivalentJob| in |job|'s <a>list of equivalent jobs</a>:
-          1. If |equivalentJob|'s [=job/client=] is not null, <a>queue a task</a> to resolve |equivalentJob|'s [=job/job promise=] with |value| on |equivalentJob|'s [=job/client=]'s <a>responsible event loop</a> using the <a>DOM manipulation task source</a> as the <a>task source</a>.
+          1. If |equivalentJob|'s [=job/client=] is null, continue to the next iteration of the loop.

Feel free to use `[=iteration/continue=]` instead of "continue to the next iteration of the loop"

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1054#pullrequestreview-46607415

Received on Tuesday, 27 June 2017 16:38:28 UTC