diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Promise/withResolvers | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Promise/withResolvers')
8 files changed, 137 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/browser.js b/js/src/tests/test262/built-ins/Promise/withResolvers/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/browser.js diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-ctor.js b/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-ctor.js new file mode 100644 index 0000000000..c13c68fa9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-ctor.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Peter Klecha. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Promise.withResolvers produces instances of the receiver +esid: sec-promise.withresolvers +features: [promise-with-resolvers] +---*/ + +class SubPromise extends Promise {} + +var instance = Promise.withResolvers.call(SubPromise); + +assert.sameValue(instance.promise.constructor, SubPromise); +assert.sameValue(instance.promise instanceof SubPromise, true); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-non-ctor.js b/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-non-ctor.js new file mode 100644 index 0000000000..b5364593b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-non-ctor.js @@ -0,0 +1,14 @@ +// Copyright (C) 2023 Peter Klecha. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Promise.withResolvers errors when the receiver is not a constructor +esid: sec-promise.withresolvers +features: [promise-with-resolvers] +---*/ + +assert.throws(TypeError, function() { + Promise.withResolvers.call(eval); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-non-object.js b/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-non-object.js new file mode 100644 index 0000000000..3be318a003 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/ctx-non-object.js @@ -0,0 +1,34 @@ +// Copyright (C) 2023 Peter Klecha. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Promise.withResolvers errors when the receiver is not an object +esid: sec-promise.withresolvers +features: [promise-with-resolvers] +---*/ + +assert.throws(TypeError, function() { + Promise.withResolvers.call(undefined); +}); + +assert.throws(TypeError, function() { + Promise.withResolvers.call(null); +}); + +assert.throws(TypeError, function() { + Promise.withResolvers.call(86); +}); + +assert.throws(TypeError, function() { + Promise.withResolvers.call('string'); +}); + +assert.throws(TypeError, function() { + Promise.withResolvers.call(true); +}); + +assert.throws(TypeError, function() { + Promise.withResolvers.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/promise.js b/js/src/tests/test262/built-ins/Promise/withResolvers/promise.js new file mode 100644 index 0000000000..7a58ecef14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/promise.js @@ -0,0 +1,17 @@ +// Copyright (C) 2023 Peter Klecha. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Promise.withResolvers return value has a property called "promise" which is a Promise +esid: sec-promise.withresolvers +features: [promise-with-resolvers] +---*/ + + +var instance = Promise.withResolvers(); + +assert.sameValue(instance.promise.constructor, Promise); +assert.sameValue(instance.promise instanceof Promise, true); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/resolvers.js b/js/src/tests/test262/built-ins/Promise/withResolvers/resolvers.js new file mode 100644 index 0000000000..8a0606870a --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/resolvers.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Peter Klecha. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Promise.withResolvers return value has properties called "resolve" and "reject" which are unary functions +esid: sec-promise.withresolvers +features: [promise-with-resolvers] +---*/ + + +var instance = Promise.withResolvers(); + +assert.sameValue(typeof instance.resolve, 'function', 'type of resolve property'); +assert.sameValue(instance.resolve.length, 1, 'length of resolve property'); +assert.sameValue(typeof instance.reject, 'function', 'type of reject property'); +assert.sameValue(instance.reject.length, 1, 'length of reject property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/result.js b/js/src/tests/test262/built-ins/Promise/withResolvers/result.js new file mode 100644 index 0000000000..0679dfaf31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/result.js @@ -0,0 +1,36 @@ +// Copyright (C) 2023 Peter Klecha. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Promise.withResolvers result is an object with keys "promise", "reject", and "resolve" +esid: sec-promise.withresolvers +includes: [propertyHelper.js] +features: [promise-with-resolvers] +---*/ + + +var instance = Promise.withResolvers(); + +assert.sameValue(typeof instance, "object"); +assert.notSameValue(instance, null); +assert(instance instanceof Object); + +verifyProperty(instance, "promise", { + writable: true, + configurable: true, + enumerable: true, +}) + +verifyProperty(instance, "resolve", { + writable: true, + configurable: true, + enumerable: true, +}) + +verifyProperty(instance, "reject", { + writable: true, + configurable: true, + enumerable: true, +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/withResolvers/shell.js b/js/src/tests/test262/built-ins/Promise/withResolvers/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/withResolvers/shell.js |