diff --git a/test/language/arguments-object/mapped/nonconfigurable-descriptors-basic.js b/test/language/arguments-object/mapped/nonconfigurable-descriptors-basic.js new file mode 100644 index 0000000000..e7e8891bb5 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-descriptors-basic.js @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments object with non-configurable property property descriptor behavior +info: > + Descriptor of a mapped value is updated when property is made non-configurable. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function argumentsNonConfigurable(a) { + Object.defineProperty(arguments, "0", {configurable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +argumentsNonConfigurable(1); diff --git a/test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-by-arguments.js b/test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-by-arguments.js new file mode 100644 index 0000000000..50ae4dd904 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-by-arguments.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change with non-configurable property +info: > + Mapping keep working when property is set to non-configurable and its + value is changed using arguments[i] where "i" is the argument index. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function argumentsAndSetByIndex(a) { + Object.defineProperty(arguments, "0", {configurable: false}); + + arguments[0] = 2; + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + assert.sameValue(a, 2); + verifyEnumerable(arguments, "0"); + verifyWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +argumentsAndSetByIndex(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-with-define-property.js b/test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-with-define-property.js new file mode 100644 index 0000000000..181609f803 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-with-define-property.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change with non-configurable property +info: > + Mapping keep working when property is set to non-configurable and its + value is changed using [[DefineOwnProperty]]. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function setArgumentValueWithDefineOwnProperty(a) { + Object.defineProperty(arguments, "0", {configurable: false}); + + Object.defineProperty(arguments, "0", {value: 2}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + assert.sameValue(a, 2); + verifyEnumerable(arguments, "0"); + verifyWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +setArgumentValueWithDefineOwnProperty(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-descriptors-with-param-assign.js b/test/language/arguments-object/mapped/nonconfigurable-descriptors-with-param-assign.js new file mode 100644 index 0000000000..d4c163a458 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-descriptors-with-param-assign.js @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Property descriptor of mapped arguments object with non-configurable property +info: > + Mapping keep working when property is set to non-configurable, and its + descriptor needs to change properly. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function argumentsAndSetMutableBinding(a) { + Object.defineProperty(arguments, "0", {configurable: false}); + + a = 2; + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + verifyEnumerable(arguments, "0"); + verifyWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +argumentsAndSetMutableBinding(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-basic.js b/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-basic.js new file mode 100644 index 0000000000..344e5b853b --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-basic.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change with non-configurable, non-enumerable and non-writable property +info: > + Mapping stop working when property is set to non-writable. The + descriptor's enumerable property is the one set before the mapping removal. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {configurable: false, enumerable: false, writable: false}); + + // Postcondition: Arguments mapping is removed. + a = 2; + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-arguments.js b/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-arguments.js new file mode 100644 index 0000000000..3d52700a16 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-arguments.js @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-configurable, non-enumerable and non-writable +info: > + Change the descriptor using [[DefineOwnProperty]] to {configurable: false, enumerable: false}, + set arguments[0] = 2 and then change property descriptor to {writable: false}. + The descriptor's enumerable property is the one set before the mapping removal. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {configurable: false, enumerable: false}); + arguments[0] = 2; + Object.defineProperty(arguments, "0", {writable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + assert.sameValue(a, 2); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 3; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-param.js b/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-param.js new file mode 100644 index 0000000000..d66a94d359 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-param.js @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-configurable, non-enumerable and non-writable +info: > + Change the descriptor using [[DefineOwnProperty]] to + {configurable: false, enumerable: false}, set a = 2 and then + change property descriptor to {writable: false}. The descriptor's enumerable + property need to be the one set before the mapping removal. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {configurable: false, enumerable: false}); + a = 2; + Object.defineProperty(arguments, "0", {writable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 3; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-basic.js b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-basic.js new file mode 100644 index 0000000000..60c6960371 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-basic.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change with non-configurable and non-writable property +info: > + Mapping stop working when property is set to non-writable. The + descriptor's value need to be the one set before the property be configured as + writable: false. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {configurable: false, writable: false}); + + // Postcondition: Arguments mapping is removed. + a = 2; + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-define-property-consecutive.js b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-define-property-consecutive.js new file mode 100644 index 0000000000..03c9d07b98 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-define-property-consecutive.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change with non-configurable and non-writable property +info: > + Mapping stop working when property is set to non-writable. Change the + descriptor with two [[DefineOwnProperty]] calls. The descriptor's value need to be + the one set before the property be configured as writable: false. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {configurable: false}); + Object.defineProperty(arguments, "0", {writable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 2; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-arguments.js b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-arguments.js new file mode 100644 index 0000000000..fa4da2fcfe --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-arguments.js @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-configurable and non-writable +info: > + Mapping just stop working when property is set to non-writable. Change the + descriptor using [[DefineOwnProperty]] to {configurable: false}, set arguments[0] = 2 + and then change property descriptor to {writable: false}. + The descriptor's value need to be the one set before the property be + configured as {writable: false}. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {configurable: false}); + arguments[0] = 2; + Object.defineProperty(arguments, "0", {writable: false}); + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + assert.sameValue(a, 2) + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 3; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-param.js b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-param.js new file mode 100644 index 0000000000..a3025f7e81 --- /dev/null +++ b/test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-param.js @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-configurable and non-writable +info: > + Mapping just stop working when property is set to non-writable. Change the + descriptor using [[DefineOwnProperty]] to {configurable: false}, set a = 2 and then + change property descriptor to {writable: false}. The descriptor's value is + the one set before the property be configured as {writable: false}. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {configurable: false}); + a = 2; + Object.defineProperty(arguments, "0", {writable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 3; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-basic.js b/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-basic.js new file mode 100644 index 0000000000..dead55dc0a --- /dev/null +++ b/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-basic.js @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-writable and non-configurable +info: > + Mapping stop working when property is set to non-writable. Here we change the + descriptor using [[DefineOwnProperty]] to {writable: false} and then + change property descriptor to {configurable: false} in sequence. + The property descriptor need to be the one set before the property be + configured as {writable: false}. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {writable: false}); + Object.defineProperty(arguments, "0", {configurable: false}); + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. Descriptors need to be the same + // as above. + a = 2; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-set-by-arguments.js b/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-set-by-arguments.js new file mode 100644 index 0000000000..2bd6995a12 --- /dev/null +++ b/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-set-by-arguments.js @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-writable and non-configurable +info: > + Mapping stop working when property is set to non-writable. Change the + descriptor using [[DefineOwnProperty]] to {writable: false}, set argument[0] = 2 and then + change property descriptor to {configurable: false}. + The descriptor's value is the one set before the property be + configured as {writable: false} because mapping was removed. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {writable: false}); + arguments[0] = 2; + Object.defineProperty(arguments, "0", {configurable: false}); + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + assert.sameValue(a, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 3; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-set-by-param.js b/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-set-by-param.js new file mode 100644 index 0000000000..b5a04c136e --- /dev/null +++ b/test/language/arguments-object/mapped/nonwritable-nonconfigurable-descriptors-set-by-param.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-writable and non-configurable +info: > + Mapping just stop working when property is set to non-writable. Change the + descriptor using [[DefineOwnProperty]] to {writable: false}, set a = 2 and then + change property descriptor to {configurable: false}. + The descriptor's value is the one set before the property be + configured as {writable: false} because mapping was removed. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {writable: false}); + a = 2; + Object.defineProperty(arguments, "0", {configurable: false}); + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); + diff --git a/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-basic.js b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-basic.js new file mode 100644 index 0000000000..273a0040ff --- /dev/null +++ b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-basic.js @@ -0,0 +1,35 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-writable and non-configurable +info: > + Change the descriptor using [[DefineOwnProperty]] to + {writable: false, enumerable: false} and then + change property descriptor to {configurable: false}. + The descriptor's enumerable property continue with its configured value + even if mapping stops. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {writable: false, enumerable: false}); + Object.defineProperty(arguments, "0", {configurable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 2; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); diff --git a/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-arguments.js b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-arguments.js new file mode 100644 index 0000000000..e345eb2566 --- /dev/null +++ b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-arguments.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-writable, non-enumerable and non-configurable +info: > + Change the descriptor using [[DefineOwnProperty]] to {writable: false, enumerable: false}, + set argument[0] = 2 and then change property descriptor to {configurable: false}. + The descriptor's enumerable property continues with its configured value. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {writable: false, enumerable: false}); + arguments[0] = 2; + Object.defineProperty(arguments, "0", {configurable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 3; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); diff --git a/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-define-property.js b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-define-property.js new file mode 100644 index 0000000000..04d83c6a9e --- /dev/null +++ b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-define-property.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-writable, non-enumerable and non-configurable +info: > + Change the descriptor using [[DefineOwnProperty]] to + {writable: false, enumerable: false}, change argument[0] + value to 2 using [[DefineOwnProperty]] and then + change property descriptor to {configurable: false}. + The descriptor's enumerable property continues with its configured value. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {writable: false, enumerable: false, value: 2, configurable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 2); + assert.sameValue(arguments[0], 2); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1); diff --git a/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-param.js b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-param.js new file mode 100644 index 0000000000..49b75ecfed --- /dev/null +++ b/test/language/arguments-object/mapped/nonwritable-nonenumerable-nonconfigurable-descriptors-set-by-param.js @@ -0,0 +1,35 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Mapped arguments property descriptor change to non-writable, non-enumerable and non-configurable +info: > + Change the descriptor using [[DefineOwnProperty]] to + {writable: false, enumerable: false}, set a = 2 and then + change property descriptor to {configurable: false}. + The descriptor's enumerable property continue with its configured value. +flags: [noStrict] +esid: sec-arguments-exotic-objects-defineownproperty-p-desc +includes: [propertyHelper.js] +---*/ + +function fn(a) { + Object.defineProperty(arguments, "0", {writable: false, enumerable: false}); + a = 2; + Object.defineProperty(arguments, "0", {configurable: false}); + + let propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); + + // Postcondition: Arguments mapping is removed. + a = 3; + propertyDescriptor = Object.getOwnPropertyDescriptor(arguments, "0"); + assert.sameValue(propertyDescriptor.value, 1); + verifyNotEnumerable(arguments, "0"); + verifyNotWritable(arguments, "0"); + verifyNotConfigurable(arguments, "0"); +} +fn(1);