summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Function/internals/Construct
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Function/internals/Construct')
-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
8 files changed, 230 insertions, 0 deletions
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