Skip to content

Testing plan for Thenable-Curtailment (Safe Promise Resolve) #5122

Description

@mgaudet

Testing Plan for https://tc39.es/proposal-thenable-curtailment/

Setup:

  • Add a safeResolvePromise host-defined function to allow testing the proposal (which otherwise has no user access in its current shape)

Synchronous Resolve

  • Primitive values resolve synchronously
  • Object with no then property resolve synchronously
  • Object with un-callable then resolve synchronously.
  • Object with un-callable then on prototype resolves synchronously
  • Object with then setter, but no getter, resolve synchronously
  • Object with then setter, but no getter, on the prototype. resolves synchronously.
  • Object with own-property then which is not callable shadows a callable then, resolves synchronously.

Deferred Resolve & Execution of User Code

  • Resolving with a Proxy (even with empty traps) resolves deferred.
  • Resolving with a Proxy with a get trap is resolved.
    • The get trap runs in deferral.
  • Resolving an object which has a proxy on its prototype chain is deferred.
  • Resolving with a module namespace object is deferred
  • Object with callable then own-property is deferred
    • The then call is made, deferred.
  • Object with callable then prototype is deferred
    • The then call is made deferred
  • A deferred then throwing should cause the promise to be rejected.
  • Object with then getter
    • The then getter is run, deferred.
  • Object with then getter on prototype.
  • The then getter is run, deferred.
  • then getter which throws rejects promise, but deferred
  • Resolving with a revoked proxy rejects deferred
  • Callable Object.prototype.then causes object resolution to be deferred
    • unless the object has a null prototype.
  • Ensure deferred then call has correct this binding.
  • Tick count of safe resolving a promise with another native promise (resolved, unresolved).
  • Delete the callable then after a safeResolve job is enqueued but before it's processed.
  • Ensure the Get of then is run twice when

Latching behaviour

  • Attempting to resolve a deferred promise of any sort cannot overwrite or otherwise interfere with the deferred promise
  • Late rejection also fails.
  • Repeated safe resolution: Latched by first and second is no-op.
  • Attempting to safe resolve an already resolved promise is a no-op.

Edge Cases

  • (If possible) test HostObjectHasImpureLookupInternalMethods.
  • Self-resolve: (note: Spec currently will defer depending on the inspection of current promise.. but I actually think maybe we should change the spec to synchronously throw here?)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions