summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Function/internals
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Function/internals
parentInitial commit. (diff)
downloadfirefox-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/Function/internals')
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Call/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Call/class-ctor-realm.js19
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Call/class-ctor.js19
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Call/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js59
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js56
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val-realm.js31
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val.js27
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js30
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized.js27
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/Construct/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Function/internals/shell.js0
14 files changed, 268 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Function/internals/Call/browser.js b/js/src/tests/test262/built-ins/Function/internals/Call/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Call/browser.js
diff --git a/js/src/tests/test262/built-ins/Function/internals/Call/class-ctor-realm.js b/js/src/tests/test262/built-ins/Function/internals/Call/class-ctor-realm.js
new file mode 100644
index 0000000000..7deb05571d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Call/class-ctor-realm.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-call-thisargument-argumentslist
+description: >
+ Error when invoking a default class constructor, honoring the Realm
+ that the class was defined in.
+features: [cross-realm, class]
+---*/
+
+const realm = $262.createRealm();
+const C = realm.global.eval('(class {})');
+const TE = realm.global.TypeError;
+
+assert.throws(TE, function() {
+ C();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Call/class-ctor.js b/js/src/tests/test262/built-ins/Function/internals/Call/class-ctor.js
new file mode 100644
index 0000000000..0505b6fe5d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Call/class-ctor.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-call-thisargument-argumentslist
+description: Error when invoking a class constructor
+info: |
+ [...]
+ 2. If F's [[FunctionKind]] internal slot is "classConstructor", throw a
+ TypeError exception.
+features: [class]
+---*/
+
+class C {}
+
+assert.throws(TypeError, function() {
+ C();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Call/shell.js b/js/src/tests/test262/built-ins/Function/internals/Call/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Call/shell.js
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js b/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js
new file mode 100644
index 0000000000..6063f64101
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
+description: >
+ Error retrieving function realm from revoked Proxy exotic object (honoring
+ the Realm of the current execution context)
+info: |
+ [...]
+ 5. If kind is "base", then
+ a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget,
+ "%ObjectPrototype%").
+ [...]
+
+ 9.1.13 OrdinaryCreateFromConstructor
+
+ [...]
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor,
+ intrinsicDefaultProto).
+ [...]
+
+ 9.1.14 GetPrototypeFromConstructor
+
+ [...]
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+
+ 7.3.22 GetFunctionRealm
+
+ [...]
+ 2. If obj has a [[Realm]] internal slot, then
+ [...]
+ 3. If obj is a Bound Function exotic object, then
+ [...]
+ 4. If obj is a Proxy exotic object, then
+ a. If the value of the [[ProxyHandler]] internal slot of obj is null,
+ throw a TypeError exception.
+features: [cross-realm, Proxy]
+---*/
+
+var other = $262.createRealm().global;
+// Defer proxy revocation until after the `constructor` property has been
+// accessed
+var handlers = {
+ get: function() {
+ handle.revoke();
+ }
+};
+var handle = other.Proxy.revocable(function() {}, handlers);
+var f = handle.proxy;
+
+assert.sameValue(typeof f, 'function');
+
+assert.throws(TypeError, function() {
+ new f();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js b/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js
new file mode 100644
index 0000000000..59253ce0d3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
+description: Error retrieving function realm from revoked Proxy exotic object
+info: |
+ [...]
+ 5. If kind is "base", then
+ a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget,
+ "%ObjectPrototype%").
+ [...]
+
+ 9.1.13 OrdinaryCreateFromConstructor
+
+ [...]
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor,
+ intrinsicDefaultProto).
+ [...]
+
+ 9.1.14 GetPrototypeFromConstructor
+
+ [...]
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+
+ 7.3.22 GetFunctionRealm
+
+ [...]
+ 2. If obj has a [[Realm]] internal slot, then
+ [...]
+ 3. If obj is a Bound Function exotic object, then
+ [...]
+ 4. If obj is a Proxy exotic object, then
+ a. If the value of the [[ProxyHandler]] internal slot of obj is null,
+ throw a TypeError exception.
+features: [Proxy]
+---*/
+
+// Defer proxy revocation until after the `constructor` property has been
+// accessed
+var handlers = {
+ get: function() {
+ handle.revoke();
+ }
+};
+var handle = Proxy.revocable(function() {}, handlers);
+var f = handle.proxy;
+
+assert.sameValue(typeof f, 'function');
+
+assert.throws(TypeError, function() {
+ new f();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/browser.js b/js/src/tests/test262/built-ins/Function/internals/Construct/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/browser.js
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val-realm.js b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val-realm.js
new file mode 100644
index 0000000000..dce2630e18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val-realm.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
+description: >
+ Error when derived constructor returns a non-undefined value (honoring
+ the Realm of the current execution context)
+info: |
+ [...]
+ 13. If result.[[Type]] is return, then
+ a. If Type(result.[[Value]]) is Object, return
+ NormalCompletion(result.[[Value]]).
+ b. If kind is "base", return NormalCompletion(thisArgument).
+ c. If result.[[Value]] is not undefined, throw a TypeError exception.
+ [...]
+features: [cross-realm, class]
+---*/
+
+var C = $262.createRealm().global.eval(
+ '0, class extends Object {' +
+ ' constructor() {' +
+ ' return null;' +
+ ' }' +
+ '}'
+);
+
+assert.throws(TypeError, function() {
+ new C();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val.js b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val.js
new file mode 100644
index 0000000000..160f53659b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-return-val.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
+description: Error when derived constructor returns a non-undefined value
+info: |
+ [...]
+ 13. If result.[[Type]] is return, then
+ a. If Type(result.[[Value]]) is Object, return
+ NormalCompletion(result.[[Value]]).
+ b. If kind is "base", return NormalCompletion(thisArgument).
+ c. If result.[[Value]] is not undefined, throw a TypeError exception.
+ [...]
+features: [class]
+---*/
+
+class C extends Object {
+ constructor() {
+ return null;
+ }
+}
+
+assert.throws(TypeError, function() {
+ new C();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js
new file mode 100644
index 0000000000..0ef5fba16b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
+description: >
+ Error when derived constructor does not initialize the `this` binding
+ (honoring the Realm of the current execution context)
+info: |
+ [...]
+ 15. Return ? envRec.GetThisBinding().
+
+ 8.1.1.3.4 GetThisBinding ()
+
+ [...]
+ 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError
+ exception.
+features: [cross-realm, class]
+---*/
+
+var C = $262.createRealm().global.eval(
+ '(class C extends Object {' +
+ ' constructor() {}' +
+ '});'
+);
+
+assert.throws(ReferenceError, function() {
+ new C();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized.js b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized.js
new file mode 100644
index 0000000000..1d36c5cd7f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/derived-this-uninitialized.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
+description: >
+ Error when derived constructor does not initialize the `this` binding
+info: |
+ [...]
+ 15. Return ? envRec.GetThisBinding().
+
+ 8.1.1.3.4 GetThisBinding ()
+
+ [...]
+ 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError
+ exception.
+features: [class]
+---*/
+
+class C extends Object {
+ constructor() {}
+}
+
+assert.throws(ReferenceError, function() {
+ new C();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/shell.js b/js/src/tests/test262/built-ins/Function/internals/Construct/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/Construct/shell.js
diff --git a/js/src/tests/test262/built-ins/Function/internals/browser.js b/js/src/tests/test262/built-ins/Function/internals/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/browser.js
diff --git a/js/src/tests/test262/built-ins/Function/internals/shell.js b/js/src/tests/test262/built-ins/Function/internals/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/internals/shell.js