diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/preventExtensions')
42 files changed, 861 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-0-1.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-0-1.js new file mode 100644 index 0000000000..c01efa70d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-0-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-0-1 +description: Object.preventExtensions must exist as a function +---*/ + +var f = Object.preventExtensions; + +assert.sameValue(typeof(f), "function", 'typeof(f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-0-2.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-0-2.js new file mode 100644 index 0000000000..f1dbaa35ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-0-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-0-2 +description: > + Object.preventExtensions must exist as a function taking 1 + parameter +---*/ + +assert.sameValue(Object.preventExtensions.length, 1, 'Object.preventExtensions.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-1.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-1.js new file mode 100644 index 0000000000..25426b1b88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-1-1 +description: > + Object.preventExtensions does not throw TypeError if 'O' is + undefined +---*/ + +Object.preventExtensions(undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-2.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-2.js new file mode 100644 index 0000000000..bac4c4e914 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-2.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-1-2 +description: Object.preventExtensions does not throw TypeError if 'O' is null +---*/ + +Object.preventExtensions(null); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-3.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-3.js new file mode 100644 index 0000000000..d765ba8cf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-1-3 +description: > + Object.preventExtensions does not throw TypeError if 'O' is a + boolean primitive value +---*/ + +Object.preventExtensions(true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-4.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-4.js new file mode 100644 index 0000000000..1ffbf1e9be --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-1-4 +description: > + Object.preventExtensions does not throw TypeError if 'O' is a + string primitive value +---*/ + +Object.preventExtensions("abc"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1.js new file mode 100644 index 0000000000..64f566f7dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-1 +description: > + Object.preventExtensions does not throw TypeError if type of first + param is not Object +---*/ + +Object.preventExtensions(0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-2-1.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-2-1.js new file mode 100644 index 0000000000..b0d64ba6e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-2-1.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-2-1 +description: > + Object.preventExtensions - repeated calls to preventExtensions + have no side effects +---*/ + +var obj = {}; +var testResult1 = true; +var testResult2 = true; + +var preCheck = Object.isExtensible(obj); + +Object.preventExtensions(obj); +testResult1 = Object.isExtensible(obj); +Object.preventExtensions(obj); +testResult2 = Object.isExtensible(obj); + +assert(preCheck, 'preCheck !== true'); +assert.sameValue(testResult1, false, 'testResult1'); +assert.sameValue(testResult2, false, 'testResult2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-2.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-2.js new file mode 100644 index 0000000000..7b76d2c18a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-2.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The effect of preventExtentions must be testable by calling isExtensible +es5id: 15.2.3.10-2 +description: > + Object.preventExtensions returns its arguments after setting its + extensible property to false +---*/ + +var o = {}; +var o2 = undefined; + +o2 = Object.preventExtensions(o); + +assert.sameValue(o2, o, 'o2'); +assert.sameValue(Object.isExtensible(o2), false, 'Object.isExtensible(o2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-1.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-1.js new file mode 100644 index 0000000000..0b743f2b1c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-1.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-1 +description: > + Object.preventExtensions - Object.isExtensible(arg) returns false + if arg is the returned object +---*/ + +var obj = {}; +var preCheck = Object.isExtensible(obj); +Object.preventExtensions(obj); + +assert(preCheck, 'preCheck !== true'); +assert.sameValue(Object.isExtensible(obj), false, 'Object.isExtensible(obj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-10.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-10.js new file mode 100644 index 0000000000..dee7f3deb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-10.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-10 +description: > + Object.preventExtensions - indexed properties cannot be added into + an Error object +includes: [propertyHelper.js] +---*/ + +var errObj = new Error(); + +assert(Object.isExtensible(errObj)); +Object.preventExtensions(errObj); +assert(!Object.isExtensible(errObj)); + +verifyNotWritable(errObj, "0", "nocheck"); + +assert(!errObj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-11.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-11.js new file mode 100644 index 0000000000..1c42839aee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-11.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-11 +description: > + Object.preventExtensions - indexed properties cannot be added into + an Arguments object +includes: [propertyHelper.js] +---*/ + +var argObj; +(function() { + argObj = arguments; +}()); + +assert(Object.isExtensible(argObj)); +Object.preventExtensions(argObj); +assert(!Object.isExtensible(argObj)); + +verifyNotWritable(argObj, "0", "nocheck"); + +assert(!argObj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-12.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-12.js new file mode 100644 index 0000000000..7b14a19bf1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-12.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-12 +description: > + Object.preventExtensions - named properties cannot be added into + the returned object +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-13.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-13.js new file mode 100644 index 0000000000..5080aace99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-13.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-13 +description: > + Object.preventExtensions - named properties cannot be added into a + Function object +includes: [propertyHelper.js] +---*/ + +var obj = function() {}; + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-14.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-14.js new file mode 100644 index 0000000000..1b3215f02c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-14.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-14 +description: > + Object.preventExtensions - named properties cannot be added into + an Array object +includes: [propertyHelper.js] +---*/ + +var obj = []; + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-15.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-15.js new file mode 100644 index 0000000000..61ebf986b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-15.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-15 +description: > + Object.preventExtensions - named properties cannot be added into a + String object +includes: [propertyHelper.js] +---*/ + +var obj = new String("bbq"); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-16.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-16.js new file mode 100644 index 0000000000..56209edb33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-16.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-16 +description: > + Object.preventExtensions - named properties cannot be added into a + Boolean object +includes: [propertyHelper.js] +---*/ + +var obj = new Boolean(true); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-17.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-17.js new file mode 100644 index 0000000000..49162ee573 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-17.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-17 +description: > + Object.preventExtensions - named properties cannot be added into a + Number object +includes: [propertyHelper.js] +---*/ + +var obj = new Number(123); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-18.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-18.js new file mode 100644 index 0000000000..44c410f8b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-18.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-18 +description: > + Object.preventExtensions - named properties cannot be added into a + Date object +includes: [propertyHelper.js] +---*/ + +var obj = new Date(); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-19.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-19.js new file mode 100644 index 0000000000..5c9440afd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-19.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-19 +description: > + Object.preventExtensions - named properties cannot be added into a + RegExp object +includes: [propertyHelper.js] +---*/ + +var obj = new RegExp(); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-2.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-2.js new file mode 100644 index 0000000000..ea15fa3fbf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-2 +description: > + Object.preventExtensions - indexed properties cannot be added into + the returned object +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "0", "nocheck"); + +assert(!obj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-20.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-20.js new file mode 100644 index 0000000000..f1bc6393e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-20.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-20 +description: > + Object.preventExtensions - named properties cannot be added into + an Error object +includes: [propertyHelper.js] +---*/ + +var obj = new Error(); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-21.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-21.js new file mode 100644 index 0000000000..524f4f64f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-21.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-21 +description: > + Object.preventExtensions - named properties cannot be added into + an Arguments object +includes: [propertyHelper.js] +---*/ + +var obj; +(function() { + obj = arguments; +}()); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "exName", "nocheck"); + +assert(!obj.hasOwnProperty("exName")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-22.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-22.js new file mode 100644 index 0000000000..58d9a2ab18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-22.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-22 +description: > + Object.preventExtensions - properties can still be deleted after + extensions have been prevented +---*/ + +var obj = { + prop: 12 +}; +var preCheck = Object.isExtensible(obj); +Object.preventExtensions(obj); + +delete obj.prop; + +assert(preCheck, 'preCheck !== true'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-23.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-23.js new file mode 100644 index 0000000000..1d0ff17f80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-23.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-23 +description: > + Object.preventExtensions - properties can still be reassigned + after extensions have been prevented +---*/ + +var obj = { + prop: 12 +}; +var preCheck = Object.isExtensible(obj); +Object.preventExtensions(obj); + +obj.prop = -1; + +assert(preCheck, 'preCheck !== true'); +assert.sameValue(obj.prop, -1, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-24.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-24.js new file mode 100644 index 0000000000..d5299f2afa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-24.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-24 +description: > + Object.preventExtensions - [[Extensible]]: false on a prototype + doesn't prevent adding properties to an instance that inherits + from that prototype +---*/ + +var proto = {}; +var preCheck = Object.isExtensible(proto); +Object.preventExtensions(proto); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var child = new ConstructFun(); + +child.prop = 10; + +assert(preCheck, 'preCheck !== true'); +assert(child.hasOwnProperty("prop"), 'child.hasOwnProperty("prop") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-3.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-3.js new file mode 100644 index 0000000000..0e82ad9285 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-3.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-3 +description: > + Object.preventExtensions - indexed properties cannot be added into + a Function object +includes: [propertyHelper.js] +---*/ + +var obj = function() {}; + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "0", "nocheck"); + +assert(!obj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-4.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-4.js new file mode 100644 index 0000000000..4d79be6486 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-4.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-4 +description: > + Object.preventExtensions - indexed properties cannot be added into + an Array object +includes: [propertyHelper.js] +---*/ + +var obj = []; + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "0", "nocheck"); + +assert(!obj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-5-1.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-5-1.js new file mode 100644 index 0000000000..a35d2ab8e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-5-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-5-1 +description: > + Object.preventExtensions - indexed properties cannot be added into + a String object +includes: [propertyHelper.js] +---*/ + +var obj = new String("bbq"); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "10", "nocheck"); + +assert(!obj.hasOwnProperty("10")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-5.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-5.js new file mode 100644 index 0000000000..c234615332 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-5.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-5 +description: > + Object.preventExtensions - indexed properties cannot be added into + a String object +---*/ + +var strObj = new String(); +var preCheck = Object.isExtensible(strObj); +Object.preventExtensions(strObj); +assert.throws(TypeError, function() { + Object.defineProperty(strObj, "0", { + value: "c" + }); +}); +assert(preCheck, 'preCheck !== true'); +assert.sameValue(strObj.hasOwnProperty("0"), false, 'strObj.hasOwnProperty("0")'); +assert.sameValue(typeof strObj[0], "undefined", 'typeof strObj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-6.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-6.js new file mode 100644 index 0000000000..1f556adb97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-6 +description: > + Object.preventExtensions - indexed properties cannot be added into + a Boolean object +includes: [propertyHelper.js] +---*/ + +var obj = new Boolean(true); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "0", "nocheck"); + +assert(!obj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-7.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-7.js new file mode 100644 index 0000000000..35f92e2a9e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-7.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-7 +description: > + Object.preventExtensions - indexed properties cannot be added into + a Number object +includes: [propertyHelper.js] +---*/ + +var obj = new Number(123); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "0", "nocheck"); + +assert(!obj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-8.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-8.js new file mode 100644 index 0000000000..3fd880b2d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-8.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-8 +description: > + Object.preventExtensions - indexed properties cannot be added into + a Date object +includes: [propertyHelper.js] +---*/ + +var obj = new Date(); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "0", "nocheck"); + +assert(!obj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-9.js b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-9.js new file mode 100644 index 0000000000..f98d113553 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/15.2.3.10-3-9.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.10-3-9 +description: > + Object.preventExtensions - indexed properties cannot be added into + a RegExp object +includes: [propertyHelper.js] +---*/ + +var obj = new RegExp(); + +assert(Object.isExtensible(obj)); +Object.preventExtensions(obj); +assert(!Object.isExtensible(obj)); + +verifyNotWritable(obj, "0", "nocheck"); + +assert(!obj.hasOwnProperty("0")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/abrupt-completion.js b/js/src/tests/test262/built-ins/Object/preventExtensions/abrupt-completion.js new file mode 100644 index 0000000000..9a2f60e01f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/abrupt-completion.js @@ -0,0 +1,26 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.preventextensions +description: > + O.[[PreventExtensions]]() returns abrupt completion. +info: | + Object.preventExtensions ( O ) + + ... + 2. Let status be ? O.[[PreventExtensions]](). +features: [Proxy] +---*/ + +var p = new Proxy({}, { + preventExtensions: function() { + throw new Test262Error(); + }, +}); + +assert.throws(Test262Error, function() { + Object.preventExtensions(p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/browser.js b/js/src/tests/test262/built-ins/Object/preventExtensions/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/browser.js diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/name.js b/js/src/tests/test262/built-ins/Object/preventExtensions/name.js new file mode 100644 index 0000000000..09e9f7130d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.1.2.15 +description: > + Object.preventExtensions.name is "preventExtensions". +info: | + Object.preventExtensions ( O ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Object.preventExtensions.name, "preventExtensions"); + +verifyNotEnumerable(Object.preventExtensions, "name"); +verifyNotWritable(Object.preventExtensions, "name"); +verifyConfigurable(Object.preventExtensions, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/preventExtensions/not-a-constructor.js new file mode 100644 index 0000000000..dac8c6ee18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/not-a-constructor.js @@ -0,0 +1,35 @@ +// 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: > + Object.preventExtensions 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Object.preventExtensions), + false, + 'isConstructor(Object.preventExtensions) must return false' +); + +assert.throws(TypeError, () => { + new Object.preventExtensions({}); +}, '`new Object.preventExtensions({})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/shell.js b/js/src/tests/test262/built-ins/Object/preventExtensions/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/shell.js diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-non-strict.js b/js/src/tests/test262/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-non-strict.js new file mode 100644 index 0000000000..3f45211187 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-non-strict.js @@ -0,0 +1,22 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.4 +description: > + Object.preventExtensions(obj) where obj contains symbol properties. +flags: [noStrict] +features: [Symbol] +---*/ +var symA = Symbol("A"); +var symB = Symbol("B"); +var obj = {}; +obj[symA] = 1; +Object.preventExtensions(obj); +obj[symA] = 2; +obj[symB] = 1; + +assert.sameValue(obj[symA], 2, "The value of `obj[symA]` is `2`"); +assert.sameValue(delete obj[symA], true, "`delete obj[symA]` is `true`"); +assert.sameValue(obj[symB], undefined, "The value of `obj[symB]` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-strict-strict.js b/js/src/tests/test262/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-strict-strict.js new file mode 100644 index 0000000000..31aebc0bc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-strict-strict.js @@ -0,0 +1,34 @@ +'use strict'; +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.4 +description: > + Object.preventExtensions(obj) where obj contains symbol properties. +flags: [onlyStrict] +features: [Symbol] +---*/ +var symA = Symbol("A"); +var symB = Symbol("B"); +var symC = Symbol("C"); +var obj = {}; +obj[symA] = 1; +Object.preventExtensions(obj); +obj[symA] = 2; + +assert.throws(TypeError, function() { + obj[symB] = 1; +}); + +assert.throws(TypeError, function() { + Object.defineProperty(obj, symC, { + value: 1 + }); +}); + +assert.sameValue(obj[symA], 2, "The value of `obj[symA]` is `2`"); +assert.sameValue(delete obj[symA], true, "`delete obj[symA]` is `true`"); +assert.sameValue(obj[symB], undefined, "The value of `obj[symB]` is `undefined`"); +assert.sameValue(obj[symC], undefined, "The value of `obj[symC]` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/throws-when-false.js b/js/src/tests/test262/built-ins/Object/preventExtensions/throws-when-false.js new file mode 100644 index 0000000000..f77a15f63c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/throws-when-false.js @@ -0,0 +1,25 @@ +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.preventextensions +description: > + Object.preventExtensions throws if O.[[PreventExtensions]]() returns false. +info: | + Object.preventExtensions ( O ) + ... + 2. Let status be ? O.[[PreventExtensions]](). + 3. If status is false, throw a TypeError exception. +---*/ + +const p = new Proxy({}, { + preventExtensions() { + return false; + }, +}); + +assert.throws(TypeError, () => { + Object.preventExtensions(p); +}); + +reportCompare(0, 0); |