Testing plan for Thenable-Curtailment (Safe Promise Resolve)

Open
#5,122 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
testing-qa

Research direction

Start by reading the Thenable-Curtailment proposal at https://tc39.es/proposal-thenable-curtailment/ and determine how the test262 setup can expose a safeResolvePromise host-defined function. Work through the listed synchronous, deferred, latching, and edge-case scenarios. Done means the setup and listed behaviors are covered by conformance tests, including rejection, deferral, and promise-latching behavior.

Written by the indexing model from the issue text.

Description

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?)
Dominant language
JavaScript
Stars
2.9k
Forks
571
Avg merge
1d 22h
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tc39/test262

All issues in tc39/test262

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.