summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Reflect/set
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Reflect/set
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Reflect/set')
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/call-prototype-property-set.js48
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/creates-a-data-descriptor.js80
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/different-property-descriptors.js70
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/length.js24
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/name.js25
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/receiver-is-not-object.js46
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-property-key.js27
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-result.js32
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/return-false-if-receiver-is-not-writable.js34
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/return-false-if-target-is-not-writable.js44
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor-with-receiver.js54
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor.js47
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/set-value-on-data-descriptor.js55
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/set.js20
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/symbol-property.js38
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/target-is-not-object-throws.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/set/target-is-symbol-throws.js19
20 files changed, 749 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Reflect/set/browser.js b/js/src/tests/test262/built-ins/Reflect/set/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/browser.js
diff --git a/js/src/tests/test262/built-ins/Reflect/set/call-prototype-property-set.js b/js/src/tests/test262/built-ins/Reflect/set/call-prototype-property-set.js
new file mode 100644
index 0000000000..39f11387f6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/call-prototype-property-set.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Call accessor's set from target's prototype.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 4. If ownDesc is undefined, then
+ a. Let parent be O.[[GetPrototypeOf]]().
+ b. ReturnIfAbrupt(parent).
+ c. If parent is not null, then
+ i. Return parent.[[Set]](P, V, Receiver).
+ ...
+ 11. Return true.
+features: [Reflect, Reflect.set]
+---*/
+
+var args;
+var count = 0;
+var _this;
+var proto = {};
+Object.defineProperty(proto, 'p', {
+ set: function() {
+ _this = this;
+ args = arguments;
+ count++;
+ }
+});
+
+var target = Object.create(proto);
+var result = Reflect.set(target, 'p', 42);
+assert.sameValue(result, true, 'returns true');
+assert.sameValue(args.length, 1, 'prototype `set` called with 1 argument');
+assert.sameValue(args[0], 42, 'prototype `set` called with 42');
+assert.sameValue(_this, target, 'prototype `set` called with target as `this`');
+assert.sameValue(count, 1, 'prototype `set` called once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/creates-a-data-descriptor.js b/js/src/tests/test262/built-ins/Reflect/set/creates-a-data-descriptor.js
new file mode 100644
index 0000000000..10a80f2dcf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/creates-a-data-descriptor.js
@@ -0,0 +1,80 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Creates a property data descriptor.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 4. If ownDesc is undefined, then
+ a. Let parent be O.[[GetPrototypeOf]]().
+ b. ReturnIfAbrupt(parent).
+ c. If parent is not null, then
+ i. Return parent.[[Set]](P, V, Receiver).
+ d. Else,
+ ii. Let ownDesc be the PropertyDescriptor{[[Value]]: undefined,
+ [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}.
+ 5. If IsDataDescriptor(ownDesc) is true, then
+ a. If ownDesc.[[Writable]] is false, return false.
+ b. If Type(Receiver) is not Object, return false.
+ c. Let existingDescriptor be Receiver.[[GetOwnProperty]](P).
+ d. ReturnIfAbrupt(existingDescriptor).
+ e. If existingDescriptor is not undefined, then
+ i. If IsAccessorDescriptor(existingDescriptor) is true, return false.
+ ii. If existingDescriptor.[[Writable]] is false, return false.
+ iii. Let valueDesc be the PropertyDescriptor{[[Value]]: V}.
+ iv. Return Receiver.[[DefineOwnProperty]](P, valueDesc).
+ f. Else Receiver does not currently have a property P,
+ i. Return CreateDataProperty(Receiver, P, V).
+ 6. Assert: IsAccessorDescriptor(ownDesc) is true.
+ 7. Let setter be ownDesc.[[Set]].
+ 8. If setter is undefined, return false.
+ ...
+ 11. Return true.
+includes: [propertyHelper.js]
+features: [Reflect, Reflect.set]
+---*/
+
+var o1 = {};
+var result = Reflect.set(o1, 'p', 42);
+assert.sameValue(result, true, 'returns true on a successful setting');
+var desc = Object.getOwnPropertyDescriptor(o1, 'p');
+assert.sameValue(
+ desc.value, 42,
+ 'sets a data descriptor to set a new property'
+);
+verifyWritable(o1, 'p');
+verifyEnumerable(o1, 'p');
+verifyConfigurable(o1, 'p');
+
+var o2 = {};
+var receiver = {};
+result = Reflect.set(o2, 'p', 43, receiver);
+assert.sameValue(
+ result, true,
+ 'returns true on a successful setting with a receiver'
+);
+desc = Object.getOwnPropertyDescriptor(o2, 'p');
+assert.sameValue(
+ desc, undefined,
+ 'does not set a data descriptor on target if receiver is given'
+);
+desc = Object.getOwnPropertyDescriptor(receiver, 'p');
+assert.sameValue(
+ desc.value, 43,
+ 'sets a data descriptor on the receiver object to set a new property'
+);
+verifyWritable(receiver, 'p');
+verifyEnumerable(receiver, 'p');
+verifyConfigurable(receiver, 'p');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/different-property-descriptors.js b/js/src/tests/test262/built-ins/Reflect/set/different-property-descriptors.js
new file mode 100644
index 0000000000..1c70154f08
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/different-property-descriptors.js
@@ -0,0 +1,70 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Return false if target property turns to a data descriptor and receiver
+ property is an accessor descriptor.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 4. If ownDesc is undefined, then
+ a. Let parent be O.[[GetPrototypeOf]]().
+ b. ReturnIfAbrupt(parent).
+ c. If parent is not null, then
+ i. Return parent.[[Set]](P, V, Receiver).
+ d. Else,
+ ii. Let ownDesc be the PropertyDescriptor{[[Value]]: undefined,
+ [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}.
+ 5. If IsDataDescriptor(ownDesc) is true, then
+ a. If ownDesc.[[Writable]] is false, return false.
+ b. If Type(Receiver) is not Object, return false.
+ c. Let existingDescriptor be Receiver.[[GetOwnProperty]](P).
+ d. ReturnIfAbrupt(existingDescriptor).
+ e. If existingDescriptor is not undefined, then
+ i. If IsAccessorDescriptor(existingDescriptor) is true, return false.
+ ...
+features: [Reflect, Reflect.set]
+---*/
+
+var receiver = {};
+var fn = function() {};
+Object.defineProperty(receiver, 'p', {
+ set: fn
+});
+
+var o1 = {};
+var result = Reflect.set(o1, 'p', 42, receiver);
+assert.sameValue(
+ result, false,
+ 'target has no own `p` and receiver.p has an accessor descriptor'
+);
+assert.sameValue(
+ Object.getOwnPropertyDescriptor(receiver, 'p').set, fn,
+ 'receiver.p is not changed'
+);
+assert.sameValue(o1.hasOwnProperty('p'), false, 'target.p is not set');
+
+var o2 = {
+ p: 43
+};
+result = Reflect.set(o2, 'p', 42, receiver);
+assert.sameValue(
+ result, false,
+ 'target.p has a data descriptor and receiver.p has an accessor descriptor'
+);
+assert.sameValue(
+ Object.getOwnPropertyDescriptor(receiver, 'p').set, fn,
+ 'receiver.p is not changed'
+);
+assert.sameValue(o2.p, 43, 'target.p is not changed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/length.js b/js/src/tests/test262/built-ins/Reflect/set/length.js
new file mode 100644
index 0000000000..e8e0d537c7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/length.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Reflect.set.length value and property descriptor
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ The length property of the set function is 3.
+includes: [propertyHelper.js]
+features: [Reflect, Reflect.set]
+---*/
+
+assert.sameValue(
+ Reflect.set.length, 3,
+ 'The value of `Reflect.set.length` is `3`'
+);
+
+verifyNotEnumerable(Reflect.set, 'length');
+verifyNotWritable(Reflect.set, 'length');
+verifyConfigurable(Reflect.set, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/name.js b/js/src/tests/test262/built-ins/Reflect/set/name.js
new file mode 100644
index 0000000000..999e652586
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/name.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Reflect.set.name value and property descriptor
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect, Reflect.set]
+---*/
+
+assert.sameValue(
+ Reflect.set.name, 'set',
+ 'The value of `Reflect.set.name` is `"set"`'
+);
+
+verifyNotEnumerable(Reflect.set, 'name');
+verifyNotWritable(Reflect.set, 'name');
+verifyConfigurable(Reflect.set, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js
new file mode 100644
index 0000000000..c632ce534f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ Reflect.set does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Reflect, Reflect.set, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Reflect.set), false, 'isConstructor(Reflect.set) must return false');
+
+assert.throws(TypeError, () => {
+ new Reflect.set({});
+}, '`new Reflect.set({})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/receiver-is-not-object.js b/js/src/tests/test262/built-ins/Reflect/set/receiver-is-not-object.js
new file mode 100644
index 0000000000..30f2436869
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/receiver-is-not-object.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Return false if receiver is not an object.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 4. If ownDesc is undefined, then
+ a. Let parent be O.[[GetPrototypeOf]]().
+ b. ReturnIfAbrupt(parent).
+ c. If parent is not null, then
+ i. Return parent.[[Set]](P, V, Receiver).
+ d. Else,
+ ii. Let ownDesc be the PropertyDescriptor{[[Value]]: undefined,
+ [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}.
+ 5. If IsDataDescriptor(ownDesc) is true, then
+ a. If ownDesc.[[Writable]] is false, return false.
+ b. If Type(Receiver) is not Object, return false.
+ ...
+features: [Reflect, Reflect.set]
+---*/
+
+var o1 = {
+ p: 42
+};
+var receiver = 'receiver is a string';
+var result = Reflect.set(o1, 'p', 43, receiver);
+
+assert.sameValue(result, false, 'returns false');
+assert.sameValue(o1.p, 42, 'does not set a value');
+assert.sameValue(
+ receiver.hasOwnProperty('p'), false,
+ 'does not set a new property on receiver if it is not an object'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-property-key.js b/js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-property-key.js
new file mode 100644
index 0000000000..72712d21a4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-property-key.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Return abrupt from ToPropertyKey(propertyKey)
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 2. Let key be ToPropertyKey(propertyKey).
+ 3. ReturnIfAbrupt(key).
+ ...
+features: [Reflect, Reflect.set]
+---*/
+
+var p = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ Reflect.set({}, p);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-result.js b/js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-result.js
new file mode 100644
index 0000000000..f44011c5de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/return-abrupt-from-result.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Return abrupt result from get a property value.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 5. Return target.[[Set]](key, V, receiver).
+features: [Reflect, Reflect.set]
+---*/
+
+var o1 = {};
+Object.defineProperty(o1, 'p1', {
+ set: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ Reflect.set(o1, 'p1', 42);
+});
+
+// Abrupt from the prototype property
+var o2 = Object.create(o1);
+assert.throws(Test262Error, function() {
+ Reflect.set(o2, 'p1', 42);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/return-false-if-receiver-is-not-writable.js b/js/src/tests/test262/built-ins/Reflect/set/return-false-if-receiver-is-not-writable.js
new file mode 100644
index 0000000000..34a9fdd7b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/return-false-if-receiver-is-not-writable.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Return false if receiver is not writable.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 5. If IsDataDescriptor(ownDesc) is true, then
+ a. If ownDesc.[[Writable]] is false, return false.
+ ...
+features: [Reflect, Reflect.set]
+---*/
+
+var o1 = {};
+
+Object.defineProperty(o1, 'p', {
+ writable: false,
+ value: 42
+});
+var result = Reflect.set(o1, 'p', 43);
+assert.sameValue(result, false, 'returns false');
+assert.sameValue(o1.p, 42, 'does not set a new value');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/return-false-if-target-is-not-writable.js b/js/src/tests/test262/built-ins/Reflect/set/return-false-if-target-is-not-writable.js
new file mode 100644
index 0000000000..19a0a5ef24
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/return-false-if-target-is-not-writable.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Return false if target is not writable.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 5. If IsDataDescriptor(ownDesc) is true, then
+ a. If ownDesc.[[Writable]] is false, return false.
+ b. If Type(Receiver) is not Object, return false.
+ c. Let existingDescriptor be Receiver.[[GetOwnProperty]](P).
+ d. ReturnIfAbrupt(existingDescriptor).
+ e. If existingDescriptor is not undefined, then
+ i. If IsAccessorDescriptor(existingDescriptor) is true, return false.
+ ii. If existingDescriptor.[[Writable]] is false, return false.
+ ...
+features: [Reflect, Reflect.set]
+---*/
+
+var o1 = {};
+var receiver = {};
+Object.defineProperty(receiver, 'p', {
+ writable: false,
+ value: 42
+});
+var result = Reflect.set(o1, 'p', 43, receiver);
+assert.sameValue(result, false, 'returns false');
+assert.sameValue(receiver.p, 42, 'does not set a new value on receiver');
+assert.sameValue(
+ o1.hasOwnProperty('p'), false,
+ 'does not set a new value on target'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor-with-receiver.js b/js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor-with-receiver.js
new file mode 100644
index 0000000000..42d36f4964
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor-with-receiver.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Set value on an accessor descriptor property with receiver as `this`.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 6. Assert: IsAccessorDescriptor(ownDesc) is true.
+ 7. Let setter be ownDesc.[[Set]].
+ 8. If setter is undefined, return false.
+ 9. Let setterResult be Call(setter, Receiver, «V»).
+ 10. ReturnIfAbrupt(setterResult).
+ 11. Return true.
+features: [Reflect, Reflect.set]
+---*/
+
+var args;
+var count = 0
+var o1 = {};
+var receiver = {};
+var _receiver;
+Object.defineProperty(o1, 'p', {
+ set: function(a) {
+ count++;
+ args = arguments;
+ _receiver = this;
+ return false;
+ }
+});
+
+var result = Reflect.set(o1, 'p', 42, receiver);
+assert.sameValue(
+ result, true,
+ 'returns true if target.p has an accessor descriptor'
+);
+assert.sameValue(args.length, 1, 'target.p set is called with 1 argument');
+assert.sameValue(args[0], 42, 'target.p set is called with V');
+assert.sameValue(count, 1, 'target.p set is called once');
+assert.sameValue(
+ _receiver, receiver,
+ 'target.p set is called with receiver as `this`'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor.js b/js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor.js
new file mode 100644
index 0000000000..63fe98d832
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/set-value-on-accessor-descriptor.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Set value on an accessor descriptor property.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 6. Assert: IsAccessorDescriptor(ownDesc) is true.
+ 7. Let setter be ownDesc.[[Set]].
+ 8. If setter is undefined, return false.
+ 9. Let setterResult be Call(setter, Receiver, «V»).
+ 10. ReturnIfAbrupt(setterResult).
+ 11. Return true.
+features: [Reflect, Reflect.set]
+---*/
+
+var args;
+var count = 0
+var o1 = {};
+Object.defineProperty(o1, 'p', {
+ set: function(a) {
+ count++;
+ args = arguments;
+ return false;
+ }
+});
+
+var result = Reflect.set(o1, 'p', 42);
+assert.sameValue(
+ result, true,
+ 'returns true if target.p has an accessor descriptor'
+);
+assert.sameValue(args.length, 1, 'target.p set is called with 1 argument');
+assert.sameValue(args[0], 42, 'target.p set is called with V');
+assert.sameValue(count, 1, 'target.p set is called once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/set-value-on-data-descriptor.js b/js/src/tests/test262/built-ins/Reflect/set/set-value-on-data-descriptor.js
new file mode 100644
index 0000000000..4ad03c926b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/set-value-on-data-descriptor.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Sets the new value.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Set]](key, V, receiver).
+
+ 9.1.9 [[Set]] ( P, V, Receiver)
+
+ ...
+ 5. If IsDataDescriptor(ownDesc) is true, then
+ a. If ownDesc.[[Writable]] is false, return false.
+ b. If Type(Receiver) is not Object, return false.
+ c. Let existingDescriptor be Receiver.[[GetOwnProperty]](P).
+ d. ReturnIfAbrupt(existingDescriptor).
+ e. If existingDescriptor is not undefined, then
+ i. If IsAccessorDescriptor(existingDescriptor) is true, return false.
+ ii. If existingDescriptor.[[Writable]] is false, return false.
+ iii. Let valueDesc be the PropertyDescriptor{[[Value]]: V}.
+ iv. Return Receiver.[[DefineOwnProperty]](P, valueDesc).
+ f. Else Receiver does not currently have a property P,
+ i. Return CreateDataProperty(Receiver, P, V).
+ ...
+features: [Reflect, Reflect.set]
+---*/
+
+var o1 = {
+ p: 43
+};
+var result = Reflect.set(o1, 'p', 42);
+assert.sameValue(result, true, 'returns true on a successful setting');
+assert.sameValue(
+ o1.p, 42,
+ 'sets the new value'
+);
+
+var o2 = {
+ p: 43
+};
+var receiver = {
+ p: 44
+};
+var result = Reflect.set(o2, 'p', 42, receiver);
+assert.sameValue(result, true, 'returns true on a successful setting');
+assert.sameValue(o2.p, 43, 'with a receiver, does not set a value on target');
+assert.sameValue(receiver.p, 42, 'sets the new value on the receiver');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/set.js b/js/src/tests/test262/built-ins/Reflect/set/set.js
new file mode 100644
index 0000000000..8f7428b27f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/set.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Reflect.set is configurable, writable and not enumerable.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+verifyNotEnumerable(Reflect, 'set');
+verifyWritable(Reflect, 'set');
+verifyConfigurable(Reflect, 'set');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/shell.js b/js/src/tests/test262/built-ins/Reflect/set/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/Reflect/set/symbol-property.js b/js/src/tests/test262/built-ins/Reflect/set/symbol-property.js
new file mode 100644
index 0000000000..d6a5857ce7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/symbol-property.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Sets the new value.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ ...
+ 2. Let key be ToPropertyKey(propertyKey).
+ ...
+
+ 7.1.14 ToPropertyKey ( argument )
+
+ ...
+ 3. If Type(key) is Symbol, then
+ a. Return key.
+ ...
+features: [Reflect, Reflect.set, Symbol]
+---*/
+
+var o1 = {};
+var s = Symbol('1');
+var result = Reflect.set(o1, s, 42);
+assert.sameValue(result, true, 'returns true on a successful setting');
+assert.sameValue(o1[s], 42, 'sets the new value');
+
+var o2 = {};
+o2[s] = 43;
+var receiver = {};
+receiver[s] = 44;
+var result = Reflect.set(o2, s, 42, receiver);
+assert.sameValue(result, true, 'returns true on a successful setting');
+assert.sameValue(o2[s], 43, 'with a receiver, does not set a value on target');
+assert.sameValue(receiver[s], 42, 'sets the new value on the receiver');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/target-is-not-object-throws.js b/js/src/tests/test262/built-ins/Reflect/set/target-is-not-object-throws.js
new file mode 100644
index 0000000000..21018943ff
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/target-is-not-object-throws.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Throws a TypeError if target is not an Object.
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect, Reflect.set]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.set(1, 'p', 42);
+});
+
+assert.throws(TypeError, function() {
+ Reflect.set(null, 'p', 42);
+});
+
+assert.throws(TypeError, function() {
+ Reflect.set(undefined, 'p', 42);
+});
+
+assert.throws(TypeError, function() {
+ Reflect.set('', 'p', 42);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/set/target-is-symbol-throws.js b/js/src/tests/test262/built-ins/Reflect/set/target-is-symbol-throws.js
new file mode 100644
index 0000000000..b4bba97e83
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/set/target-is-symbol-throws.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.13
+description: >
+ Throws a TypeError if target is a Symbol
+info: |
+ 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect, Reflect.set, Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.set(Symbol(1), 'p', 42);
+});
+
+reportCompare(0, 0);