diff --git a/source b/source index c186fbd895a..c26da05bd40 100644 --- a/source +++ b/source @@ -84603,6 +84603,45 @@ interface NavigatorOnLine {
  • Asynchronously complete this algorithm with script.
  • +

    To fetch a classic worker script given a url, a referrer, a + settings object, and a boolean is shared, run these steps. The algorithm + will asynchronously complete with either null (on failure) or a new classic script + (on success).

    + +
      +
    1. Let request be a new request whose + url is url, client is settings object, type is "script", destination is "sharedworker" if is shared is true and "worker" otherwise, referrer is + referrer, mode is "same-origin", credentials + mode is "same-origin", and whose use-URL-credentials + flag is set.

    2. + + +
    3. Fetch request.

    4. + +
    5. Return from this algorithm, and run the remaining steps as part of the fetch's + process response for the response + response.

    6. + +
    7. If response's type is "error", or response's status is not an ok status, asynchronously + complete this algorithm with null, and abort these steps.

    8. + +
    9. Let source text be the result of UTF-8 + decoding response's body.

    10. + +
    11. Let script be the result of creating a classic script using + source text and settings object.

    12. + +
    13. Asynchronously complete this algorithm with script.
    14. +
    +

    To fetch a module script tree given a url, a credentials mode, and a settings object, run these steps. The algorithm will asynchronously complete with either null (on failure) or a new module script (on success).

    @@ -93986,8 +94025,9 @@ interface WorkerGlobalScope : EventTarget { SharedWorker object worker, URL url, URL referrer, MessagePort outside port, list of relevant Document objects to add docs, possible - WorkerGlobalScope parent worker global scope, and a boolean flag is - shared, it must run the following steps:

    + WorkerGlobalScope parent worker global scope, a boolean flag is + shared, and a WorkerOptions dictionary options, it must run the + following steps:

      @@ -94001,36 +94041,6 @@ interface WorkerGlobalScope : EventTarget { -
    1. Let request be a new request whose - url is url, client is settings object, type is "script", destination is "sharedworker" if is shared is true and "worker" otherwise, referrer is - referrer, synchronous flag is set, mode is "same-origin", credentials mode is "same-origin", and whose use-URL-credentials flag is set.

    2. - -
    3. Let response be the result of fetching request.

    4. - -
    5. - -

      If response's status is an - ok status, then let source be the result of running the UTF-8 - decode algorithm on response's body.

      - -

      As with script elements, the MIME type of the script is ignored. - Unlike with script elements, there is no way to override the type. It's always - assumed to be JavaScript.

      - -
    6. - -
    7. Otherwise, queue a task to fire a simple event named - error at worker. Abort these steps.

    8. Call the JavaScript WorkerGlobalScope : EventTarget {

    9. Set up a worker environment settings object with realm execution context, and let settings object be the result.

    10. +
    11. +

      Obtain script by switching on the value of options's type member:

      + +
      +
      "classic"
      +
      Fetch a classic worker script given url, referrer, + settings object, and is shared.
      + +
      "module"
      +
      +
        +
      1. +

        Let credentials mode be determined by switching on the value of the + crossOrigin member of options:

        + +
        +
        null
        +
        "omit"
        + +
        "anonymous"
        +
        "same-origin"
        + +
        "use-credentials"
        +
        "include"
        +
        +
      2. + +
      3. Fetch a module script tree given url, credentials + mode, and settings object.

      4. +
      +
      + +

      If the algorithm asynchronously completes with null, queue a task to fire + a simple event named error at worker, and + abort these steps. Otherwise, continue the rest of these steps after the algorithm's + asynchronous completion, with script being the asynchronous completion value.

      +
    12. +
    13. Associate worker with worker global scope.

    14. Create a new MessagePort object whose WorkerGlobalScope : EventTarget { -

    15. Let script be the result of creating a classic script using - source and settings object.

    16. -
    17. -

      Run the classic script script.

      +

      Perform either the run a classic script or run a module script + algorithms on script, depending on whether it is a classic script or + module script.

      In addition to the usual possibilities of returning a value or failing due to an exception, this could be prematurely aborted by the "kill a worker" or @@ -94412,13 +94460,22 @@ interface AbstractWorker {

      Dedicated workers and the Worker interface
      -
      [Constructor(DOMString scriptURL), Exposed=(Window,Worker)]
      +  
      [Constructor(DOMString scriptURL, optional WorkerOptions options), Exposed=(Window,Worker)]
       interface Worker : EventTarget {
         void terminate();
       
         void postMessage(any message, optional sequence<Transferable> transfer);
         attribute EventHandler onmessage;
       };
      +
      +dictionary WorkerOptions {
      +  WorkerType type = "classic";
      +  WorkerCrossOriginMode? crossOrigin = null;
      +};
      +
      +enum WorkerType { "classic", "module" };
      +enum WorkerCrossOriginMode { "anonymous", "use-credentials" };
      +
       Worker implements AbstractWorker;

      The terminate() method, when invoked, must @@ -94459,8 +94516,9 @@ interface Worker : EventTarget {


      -

      When the Worker(scriptURL) constructor - is invoked, the user agent must run the following steps:

      +

      When the Worker(scriptURL, + options) constructor is invoked, the user agent must run the following + steps:

        @@ -94503,7 +94561,7 @@ interface Worker : EventTarget {
      1. Run a worker given worker, worker URL, the incumbent settings object's creation URL, outside port, - docs, parent worker global scope, and false.

      2. + docs, parent worker global scope, false, and options.

      @@ -94511,7 +94569,7 @@ interface Worker : EventTarget {
      Shared workers and the SharedWorker interface
      -
      [Constructor(DOMString scriptURL, optional DOMString name = ""), Exposed=(Window,Worker)]
      +  
      [Constructor(DOMString scriptURL, optional DOMString name = "", optional WorkerOptions options), Exposed=(Window,Worker)]
       interface SharedWorker : EventTarget {
         readonly attribute MessagePort port;
       };
      @@ -94521,8 +94579,9 @@ interface SharedWorker : EventTarget {
         it was assigned by the object's constructor. It represents the MessagePort for
         communicating with the shared worker.

      -

      When the SharedWorker(scriptURL, name) constructor is invoked, the user agent must run the following - steps:

      +

      When the SharedWorker(scriptURL, + name, options) constructor is invoked, the user agent must run + the following steps:

        @@ -94661,7 +94720,7 @@ interface SharedWorker : EventTarget {
      1. Run a worker given worker, parsed scriptURL, the incumbent settings object's creation URL, outside port, - docs, parent worker global scope, and true.

      2. + docs, parent worker global scope, true, and options.