test262/test/built-ins/Promise/all
Peter Hoddie e4f4abdcb2
Compatibility with Hardened JavaScript (#4088)
This PR proposes changes to existing test262 tests to allow them to pass under Hardened JavaScript (see Secure ECMAScript proposal and Hardened JavaScript). Moddable uses Hardened JavaScript for JavaScript runtimes on resource constrained embedded devices, including those targeted by ECMA-419.

The changes fall into four groups:

1. Replace use of new Date() with new Date(1970). Scripts running inside a Compartment cannot retrieve the current time, so new Date() throws but new Date(1970) succeeds. Very few tests need the current time, but instead simply need a Date instance.
2. Use Object.defineProperty instead of setting existing built-in properties directly, such as toString and toValue. In Hardened JavaScript, prototypes of built-in objects are frozen. Consequently, setting properties of an instance that exist on the prototype throw (Hardened JavaScript is always in strict mode).
3. Eliminate use of Math.random(). Scripts running inside a Compartment cannot generate random numbers. One test identified so far uses Math.random() in a way that can easily be replaced with a counter.
4. Narrow the scope of exception tests. Consider the following

assert.throws(TypeError, () => {
  var s1 = new Date();
  s1.toString = Boolean.prototype.toString;
  s1.toString();
});

This test passes, but only because new Date() fails by throwing a TypeError. If the invocation of the Date constructor is resolved by (1) above, then the assignment to toString fails as per (2) above. The script should be modified as below to ensure that assert.throws only tests the intended statement, s1.toString(). The modified script tests the intended functionality and passes under Hardened JavaScript

var s1 = new Date(1970);
Object.defineProperty(s1, "toString", {
  value: Boolean.prototype.toString
});
assert.throws(TypeError, () => {
  s1.toString();
});

This is an initial PR to begin the process of adapting test262 for use with Hardened JavaScript. Further changes are expected, with the vast majority likely to fall into the four groups described above.

Thank you to gibson042, kriskowal, and erights for their advice on this work.
2024-07-04 08:19:23 -07:00
..
S25.4.4.1_A1.1_T1.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A2.1_T1.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A2.2_T1.js Promises: whenever evaluating checkSequence(sequence), also assert length of sequence (#2672) 2020-06-24 12:18:35 -07:00
S25.4.4.1_A2.3_T1.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A2.3_T2.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A2.3_T3.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A3.1_T1.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A3.1_T2.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A3.1_T3.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A4.1_T1.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
S25.4.4.1_A5.1_T1.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A7.1_T1.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A7.2_T1.js Promises: whenever evaluating checkSequence(sequence), also assert length of sequence (#2672) 2020-06-24 12:18:35 -07:00
S25.4.4.1_A8.1_T1.js Promises: whenever evaluating checkSequence(sequence), also assert length of sequence (#2672) 2020-06-24 12:18:35 -07:00
S25.4.4.1_A8.2_T1.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
S25.4.4.1_A8.2_T2.js Transform legacy format to harness assertions: test/built-ins/P*/**/*.js 2021-09-02 11:34:18 -07:00
call-resolve-element-after-return.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
call-resolve-element-items.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
call-resolve-element.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
capability-executor-called-twice.js Fix tests for new resolve lookup 2019-04-24 17:28:01 -04:00
capability-executor-not-callable.js Fix tests for new resolve lookup 2019-04-24 17:28:01 -04:00
capability-resolve-throws-no-close.js Remove duplicated es[56]id if esid is present 2019-08-05 10:54:37 -04:00
capability-resolve-throws-reject.js Remove duplicated es[56]id if esid is present 2019-08-05 10:54:37 -04:00
ctx-ctor-throws.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
ctx-ctor.js Add missing mandatory Promise.{all,race} argument 2018-11-08 09:37:56 +01:00
ctx-non-ctor.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
ctx-non-object.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
does-not-invoke-array-setters.js chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Promise (#3091) 2021-07-21 12:48:13 -07:00
invoke-resolve-error-close.js Remove duplicated es[56]id if esid is present 2019-08-05 10:54:37 -04:00
invoke-resolve-error-reject.js chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Promise (#3091) 2021-07-21 12:48:13 -07:00
invoke-resolve-get-error-reject.js chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Promise (#3091) 2021-07-21 12:48:13 -07:00
invoke-resolve-get-error.js Update Promise.all tests 2020-06-03 15:49:04 -04:00
invoke-resolve-get-once-multiple-calls.js Add tests for Promise.all|race resolve lookup 2019-04-24 17:28:01 -04:00
invoke-resolve-get-once-no-calls.js Remove invalid feature, fix lint 2020-04-29 17:31:45 -04:00
invoke-resolve-on-promises-every-iteration-of-custom.js Promise: use .then($DONE, $DONE) wherever possible 2020-06-24 15:47:48 -04:00
invoke-resolve-on-promises-every-iteration-of-promise.js Promise: use .then($DONE, $DONE) wherever possible 2020-06-24 15:47:48 -04:00
invoke-resolve-on-values-every-iteration-of-promise.js Promise: use .then($DONE, $DONE) wherever possible 2020-06-24 15:47:48 -04:00
invoke-resolve-return.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
invoke-resolve.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
invoke-then-error-close.js Compatibility with Hardened JavaScript (#4088) 2024-07-04 08:19:23 -07:00
invoke-then-error-reject.js Compatibility with Hardened JavaScript (#4088) 2024-07-04 08:19:23 -07:00
invoke-then-get-error-close.js Remove duplicated es[56]id if esid is present 2019-08-05 10:54:37 -04:00
invoke-then-get-error-reject.js chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Promise (#3091) 2021-07-21 12:48:13 -07:00
invoke-then.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
iter-arg-is-false-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-arg-is-null-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-arg-is-number-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-arg-is-string-resolve.js Fix various test bugs (#1502) 2018-03-22 16:36:57 -04:00
iter-arg-is-symbol-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-arg-is-true-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-arg-is-undefined-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-assigned-false-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-assigned-null-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-assigned-number-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-assigned-string-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-assigned-symbol-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-assigned-true-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-assigned-undefined-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-next-val-err-no-close.js Remove duplicated es[56]id if esid is present 2019-08-05 10:54:37 -04:00
iter-next-val-err-reject.js Remove duplicated es[56]id if esid is present 2019-08-05 10:54:37 -04:00
iter-returns-false-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-returns-null-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-returns-number-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-returns-string-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-returns-symbol-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-returns-true-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-returns-undefined-reject.js Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) 2018-03-19 14:01:36 -04:00
iter-step-err-no-close.js chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Promise (#3091) 2021-07-21 12:48:13 -07:00
iter-step-err-reject.js Remove duplicated es[56]id if esid is present 2019-08-05 10:54:37 -04:00
length.js rewrite tests to use verifyProperty 2024-03-25 12:05:06 +01:00
name.js rewrite tests to use verifyProperty 2024-03-25 12:05:06 +01:00
new-resolve-function.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
not-a-constructor.js remove some auto-generated error messages in "assert.throws" tests 2024-03-25 12:09:10 +01:00
prop-desc.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
reject-deferred.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
reject-ignored-deferred.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
reject-ignored-immed.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
reject-immed.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
resolve-before-loop-exit-from-same.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
resolve-before-loop-exit.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
resolve-element-function-extensible.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
resolve-element-function-length.js rewrite tests to use verifyProperty 2024-03-25 12:05:06 +01:00
resolve-element-function-name.js Assign "name" property to all anonymous functions (#2299) 2019-08-15 10:58:40 -04:00
resolve-element-function-nonconstructor.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
resolve-element-function-property-order.js Set function `length` and `name` in `CreateBuiltinFunction` 2021-01-29 09:45:20 -05:00
resolve-element-function-prototype.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
resolve-from-same-thenable.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
resolve-ignores-late-rejection-deferred.js Promise.all, Promise.allSettled: coverage updates (#2657) 2020-06-12 09:54:52 -07:00
resolve-ignores-late-rejection.js Promise.all, Promise.allSettled: coverage updates (#2657) 2020-06-12 09:54:52 -07:00
resolve-non-callable.js Update Promise.all tests 2020-06-03 15:49:04 -04:00
resolve-non-thenable.js Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
resolve-not-callable-reject-with-typeerror.js Promise.all, Promise.allSettled: coverage updates (#2657) 2020-06-12 09:54:52 -07:00
resolve-poisoned-then.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
resolve-thenable.js built-ins/Promise/*: make all indentation consistent (depth & character) (#1433) 2018-02-15 15:11:21 -05:00
same-reject-function.js Replace all "valid" occurences of $ERROR with Test262Error.thrower 2020-09-16 17:36:54 -04:00
species-get-error.js chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Promise (#3091) 2021-07-21 12:48:13 -07:00