From 535e285a3a7e85c7bcb181d57362c1d605c4b120 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Mon, 25 Apr 2016 20:22:08 +0900 Subject: [PATCH 1/6] Move worker's close() to dedicated worker and shared worker As WorkerGlobalScope's close() method should not be exposed to one of its derived interfaces, ServiceWorkerGlobalScope, close() needs to be moved to the derived interfaces which explicitly requires it. This commit moves close() to DedicatedWorkerGlobalScope and SharedWorkerGlobalScope. Related issue: https://github.com/slightlyoff/ServiceWorker/issues/865 --- source | 79 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/source b/source index 166544155e6..ad5a656f73d 100644 --- a/source +++ b/source @@ -96297,8 +96297,6 @@ interface WorkerGlobalScope : EventTarget { readonly attribute WorkerNavigator navigator; void importScripts(DOMString... urls); - void close(); - attribute OnErrorEventHandler onerror; attribute EventHandler onlanguagechange; attribute EventHandler onoffline; @@ -96340,9 +96338,6 @@ interface WorkerGlobalScope : EventTarget {
workerGlobal . importScripts(urls...)
Fetches each URL in urls, executes them one-by-one in the order they are passed, and then returns (or throws if something went amiss).
- -
workerGlobal . close()
-
Aborts workerGlobal.
@@ -96359,24 +96354,6 @@ interface WorkerGlobalScope : EventTarget { WorkerGlobalScope object, this is not problematic as it cannot be observed from script.

-
- -

When a script invokes the close() - method on a WorkerGlobalScope object, the user agent must run the following steps - (atomically):

- -
    - -
  1. Discard any tasks that have been added to the - WorkerGlobalScope object's event loop's task - queues.

    - -
  2. Set the worker's WorkerGlobalScope object's closing flag to true. (This prevents any further - tasks from being queued.)

  3. - -
-

@@ -96403,6 +96380,9 @@ interface WorkerGlobalScope : EventTarget {
[Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker]
 /*sealed*/ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
   void postMessage(any message, optional sequence<object> transfer = []);
+
+  void close();
+
   attribute EventHandler onmessage;
 };
@@ -96419,6 +96399,34 @@ interface WorkerGlobalScope : EventTarget { immediately invoked the method of the same name on the port, with the same arguments, and returned the same return value.

+
+
dedicatedWorkerGlobal . close()
+
Aborts dedicatedWorkerGlobal.
+
+ +
+ +

When a script invokes the close() method on a DedicatedWorkerGlobalScope object, the user + agent must run the following steps (atomically):

+ +
    + +
  1. Discard any tasks that have been added to the + DedicatedWorkerGlobalScope object's event loop's task queues.

    + +
  2. Set the worker's DedicatedWorkerGlobalScope object's closing flag to true. (This prevents any further + tasks from being queued.)

  3. + +
+ +
+ +
+

The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by objects implementing the DedicatedWorkerGlobalScope @@ -96442,6 +96450,9 @@ interface WorkerGlobalScope : EventTarget { /*sealed*/ interface SharedWorkerGlobalScope : WorkerGlobalScope { readonly attribute DOMString name; readonly attribute ApplicationCache applicationCache; // deprecated + + void close(); + attribute EventHandler onconnect; }; @@ -96459,6 +96470,10 @@ interface WorkerGlobalScope : EventTarget {

sharedWorkerGlobal . name
Returns sharedWorkerGlobal's name.
+ +
sharedWorkerGlobal . close()
+
Aborts sharedWorkerGlobal.
@@ -96468,8 +96483,26 @@ interface WorkerGlobalScope : EventTarget { data-x="concept-SharedWorkerGlobalScope-name">name. Its value represents the name that can be used to obtain a reference to the worker using the SharedWorker constructor.

+

When a script invokes the close() method on a SharedWorkerGlobalScope object, the user + agent must run the following steps (atomically):

+ +
    + +
  1. Discard any tasks that have been added to the + SharedWorkerGlobalScope object's event loop's task queues.

    + +
  2. Set the worker's SharedWorkerGlobalScope object's closing flag to true. (This prevents any further + tasks from being queued.)

  3. + +
+
+
+

The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by objects implementing the SharedWorkerGlobalScope From fd020a2c12fddaef69a297fa80b1ecc4237b7f26 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Wed, 27 Apr 2016 14:54:03 +0900 Subject: [PATCH 2/6] Extract close a worker algorithm Extract close a worker algorithm that can be invoked by the close() method of a worker. At the time of this patch, a dedicated worker and a shared worker invoke it. --- source | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/source b/source index ad5a656f73d..13f9ac9e28a 100644 --- a/source +++ b/source @@ -96409,17 +96409,20 @@ interface WorkerGlobalScope : EventTarget {

When a script invokes the close() method on a DedicatedWorkerGlobalScope object, the user - agent must run the following steps (atomically):

+ agent must close a worker with the DedicatedWorkerGlobalScope + object.

+ +

To close a worker, given a worker global scope, run these steps + (atomically):

    -
  1. Discard any tasks that have been added to the - DedicatedWorkerGlobalScope object's event loop's task queues.

    +
  2. Discard any tasks that have been added to worker + global scope's event loop's task queues.

    -
  3. Set the worker's DedicatedWorkerGlobalScope object's closing flag to true. (This prevents any further - tasks from being queued.)

  4. +
  5. Set worker global scope's closing flag to true. (This prevents any further tasks from being + queued.)

@@ -96485,19 +96488,7 @@ interface WorkerGlobalScope : EventTarget {

When a script invokes the close() method on a SharedWorkerGlobalScope object, the user - agent must run the following steps (atomically):

- -
    - -
  1. Discard any tasks that have been added to the - SharedWorkerGlobalScope object's event loop's task queues.

    - -
  2. Set the worker's SharedWorkerGlobalScope object's closing flag to true. (This prevents any further - tasks from being queued.)

  3. - -
+ agent must close a worker with the SharedWorkerGlobalScope object.

From e798194bae77d30e42c0c2c933947bcf1d10c55c Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Wed, 27 Apr 2016 17:23:46 +0900 Subject: [PATCH 3/6] Comply with the style guide --- source | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source b/source index 13f9ac9e28a..534391c4434 100644 --- a/source +++ b/source @@ -96407,9 +96407,8 @@ interface WorkerGlobalScope : EventTarget {
-

When a script invokes the close() method on a DedicatedWorkerGlobalScope object, the user - agent must close a worker with the DedicatedWorkerGlobalScope +

The close() method, when + invoked, must close a worker with this DedicatedWorkerGlobalScope object.

To close a worker, given a worker global scope, run these steps @@ -96486,9 +96485,9 @@ interface WorkerGlobalScope : EventTarget { data-x="concept-SharedWorkerGlobalScope-name">name. Its value represents the name that can be used to obtain a reference to the worker using the SharedWorker constructor.

-

When a script invokes the close() method on a SharedWorkerGlobalScope object, the user - agent must close a worker with the SharedWorkerGlobalScope object.

+

The close() method, when + invoked, must close a worker with this SharedWorkerGlobalScope + object.

From c80d871798a267a8f6bbb4435d6ef73f85224f99 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Wed, 27 Apr 2016 18:33:13 +0900 Subject: [PATCH 4/6] Reorder blocks and rename a variable --- source | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/source b/source index 534391c4434..ed5a765ee33 100644 --- a/source +++ b/source @@ -96394,24 +96394,27 @@ interface WorkerGlobalScope : EventTarget {

All messages received by that port must immediately be retargeted at the DedicatedWorkerGlobalScope object.

-

The postMessage() - method on DedicatedWorkerGlobalScope objects must act as if, when invoked, it - immediately invoked the method of the same name - on the port, with the same arguments, and returned the same return value.

-
+
dedicatedWorkerGlobal . postMessage(message [, transfer ])
+
Clones message and transmits it to the Worker object associated with + the worker that is represented by this dedicatedWorkerGlobal object. + transfer can be passed as a list of objects that are to be transfered rather than + cloned.
+
dedicatedWorkerGlobal . close()
Aborts dedicatedWorkerGlobal.
-
+

The postMessage() + method on DedicatedWorkerGlobalScope objects must act as if, when invoked, it + immediately invoked the method of the same name + on the port, with the same arguments, and returned the same return value.

-

The close() method, when - invoked, must close a worker with this DedicatedWorkerGlobalScope - object.

+
-

To close a worker, given a worker global scope, run these steps +

To close a worker, given a workerGlobal, run these steps (atomically):

    @@ -96419,12 +96422,15 @@ interface WorkerGlobalScope : EventTarget {
  1. Discard any tasks that have been added to worker global scope's event loop's task queues.

    -
  2. Set worker global scope's closing flag to true. (This prevents any further tasks from being - queued.)

  3. +
  4. Set workerGlobal's closing + flag to true. (This prevents any further tasks from being queued.)

+

The close() method, when + invoked, must close a worker with this DedicatedWorkerGlobalScope + object.

+

From 048da21c2b60f90760a864d34913e8c238e99faf Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Wed, 27 Apr 2016 23:40:26 +0900 Subject: [PATCH 5/6] Remove atomically word; rename a variable --- source | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source b/source index ed5a765ee33..579d21e551e 100644 --- a/source +++ b/source @@ -96398,9 +96398,8 @@ interface WorkerGlobalScope : EventTarget {
dedicatedWorkerGlobal . postMessage(message [, transfer ])
Clones message and transmits it to the Worker object associated with - the worker that is represented by this dedicatedWorkerGlobal object. - transfer can be passed as a list of objects that are to be transfered rather than - cloned.
+ dedicatedWorkerGlobal. transfer can be passed as a list of objects that are + to be transfered rather than cloned.
dedicatedWorkerGlobal . close()
@@ -96414,13 +96413,13 @@ interface WorkerGlobalScope : EventTarget {
-

To close a worker, given a workerGlobal, run these steps - (atomically):

+

To close a worker, given a workerGlobal, run these steps:

    -
  1. Discard any tasks that have been added to worker - global scope's event loop's task queues.

    +
  2. Discard any tasks that have been added to + workerGlobal's event loop's task + queues.

  3. Set workerGlobal's closing flag to true. (This prevents any further tasks from being queued.)

  4. From 933c8b27ab13df1acfedfdc02a3f870a65130476 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Thu, 28 Apr 2016 00:00:30 +0900 Subject: [PATCH 6/6] Fix markup alignment --- source | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/source b/source index 579d21e551e..98b8381fe6d 100644 --- a/source +++ b/source @@ -96395,14 +96395,15 @@ interface WorkerGlobalScope : EventTarget { DedicatedWorkerGlobalScope object.

    -
    dedicatedWorkerGlobal . postMessage(message [, transfer ])
    +
    dedicatedWorkerGlobal . postMessage(message [, + transfer ])
    Clones message and transmits it to the Worker object associated with dedicatedWorkerGlobal. transfer can be passed as a list of objects that are to be transfered rather than cloned.
    -
    dedicatedWorkerGlobal . close()
    +
    dedicatedWorkerGlobal . close()
    Aborts dedicatedWorkerGlobal.
    @@ -96416,14 +96417,12 @@ interface WorkerGlobalScope : EventTarget {

    To close a worker, given a workerGlobal, run these steps:

      -
    1. Discard any tasks that have been added to workerGlobal's event loop's task queues.

    2. Set workerGlobal's closing flag to true. (This prevents any further tasks from being queued.)

    3. -

    The close() method, when @@ -96478,8 +96477,8 @@ interface WorkerGlobalScope : EventTarget {

    Returns sharedWorkerGlobal's name.
    -
    sharedWorkerGlobal . close()
    +
    sharedWorkerGlobal . close()
    Aborts sharedWorkerGlobal.