From 13a3e6d48320867f53ca61f427c8ae2e7467764f Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sun, 19 May 2019 23:32:48 +0200 Subject: [PATCH] Revert "Rebase on top of the current TLA draft" This reverts commit 8415c83185762c44343c4bccc5be1d231d818cb2. https://github.com/tc39/proposal-top-level-await/pull/74 restores the property of Evaluate() that it always returns a Promise, saving some complexity in HTML. --- source | 96 +++++++++++++++++++++++----------------------------------- 1 file changed, 38 insertions(+), 58 deletions(-) diff --git a/source b/source index 4b2bb402eca..7f5d0f743d0 100644 --- a/source +++ b/source @@ -3064,7 +3064,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The IsConstructor abstract operation
  • The IsDataDescriptor abstract operation
  • The IsDetachedBuffer abstract operation
  • -
  • The IsPromise abstract operation
  • The IsSharedArrayBuffer abstract operation
  • The NewObjectEnvironment abstract operation
  • The NormalCompletion abstract operation
  • @@ -3124,9 +3123,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    User agents that support JavaScript must also implement the BigInt proposal.

    -

    User agents that support JavaScript must also implement the top-level await - proposal:

    +

    User agents that support JavaScript must also implement the top-level await proposal. + The following terms are defined there, and used in this specification:

    + @@ -88953,12 +88955,9 @@ interface ApplicationCache : EventTarget {
  • Prepare to run script given settings.

  • -
  • Let evaluationStatus be null.

  • -
  • If script's error to - rethrow is not null, then set evaluationStatus to Completion { [[Type]]: throw, - [[Value]]: script's error to - rethrow, [[Target]]: empty }.

  • + rethrow is not null, then let evaluationPromise be a promise rejected with script's error to + rethrow.

  • Otherwise:

    @@ -88968,44 +88967,26 @@ interface ApplicationCache : EventTarget { data-x="concept-script-record">record.

  • -

    Set evaluationStatus to record.Let evaluationPromise be record.Evaluate().

    This step will recursively evaluate all of the module's dependencies.

    If Evaluate fails to complete as a result of the user agent - aborting the running script, then set - evaluationStatus to Completion { [[Type]]: throw, [[Value]]: a new - "QuotaExceededError" DOMException, [[Target]]: empty - }.

    + aborting the running script, then let + evaluationPromise be a promise rejected with a new + "QuotaExceededError" DOMException.

  • -
  • -

    If evaluationStatus is an abrupt completion, then:

    - -
      -
    1. If rethrow errors is true, rethrow the exception given by - evaluationStatus.[[Value]].

    2. - -
    3. Otherwise, report the exception given by +

    4. If rethrow errors is false, then upon rejection of + evaluationPromise, report the exception given by evaluationStatus.[[Value]] for script.

    5. -
    -
  • - -
  • -

    If IsPromise(evaluationStatus) is true, then:

    - -
      -
    1. Upon rejection of evaluationStatus with reason, - report the exception given by reason for script.

    2. -
    -
  • Clean up after running script with settings.

  • -
  • Return evaluationStatus.

  • +
  • Return evaluationPromise.

  • The steps to check if we can run script with an environment settings @@ -89787,6 +89768,24 @@ document.querySelector("button").addEventListener("click", bound); +

    FlushJobs()
    + +

    When the JavaScript specification says to call the FlushJobs abstract operation, the + following algorithm must be used in place of JavaScript's FlushJobs:

    + +
      +
    1. Assert: the JavaScript execution context stack is empty

    2. + +
    3. +

      Perform a microtask checkpoint.

      + +

      Rather than simply a microtask checkpoint, + this algorithm may yield to the event loop before continuing; see discussion in issue #4400.

      +
    4. + +
    Integration with the JavaScript module system
    @@ -90071,42 +90070,23 @@ import "https://example.com/foo/../module2.mjs";

    If result is null, then:

      -
    1. Let completion be Completion { [[Type]]: throw, [[Value]]: a new - TypeError, [[Target]]: empty }.

    2. +
    3. Let promise be a promise rejected with a new TypeError.

    4. Perform FinishDynamicImport(referencingScriptOrModule, - specifier, promiseCapability, completion).

    5. + specifier, promiseCapability, promise).

    6. Return.

  • Run the module script result, with - the rethrow errors boolean set to true, and let the result be status.

  • + the rethrow errors boolean set to true, and let the result be promise.

    -
  • If running the module script throws an exception, then perform +

  • Perform FinishDynamicImport(referencingScriptOrModule, specifier, - promiseCapability, the thrown exception completion).

  • + promiseCapability, promise).

    -
  • -

    If IsPromise(status) is true, then:

    - -
      -
    1. Upon fulfillment of status with value, perform - FinishDynamicImport(referencingScriptOrModule, specifier, - promiseCapability, value).
    2. - -
    3. Upon rejection of status with reason, perform - FinishDynamicImport(referencingScriptOrModule, specifier, - promiseCapability, Completion{ [[Type]]: throw, [[Value]]: reason }).
    4. -
    -
  • - -
  • Otherwise, perform - FinishDynamicImport(referencingScriptOrModule, specifier, - promiseCapability, NormalCompletion(undefined)).

  • - -
  • Return undefined.

  • +
  • Return.