diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/freeze')
54 files changed, 1369 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-0-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-0-1.js new file mode 100644 index 0000000000..13824be466 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-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.9-0-1 +description: Object.freeze must exist as a function +---*/ + +var f = Object.freeze; + +assert.sameValue(typeof(f), "function", 'typeof(f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-0-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-0-2.js new file mode 100644 index 0000000000..7d1a9d3f4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-0-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.9-0-2 +description: Object.freeze must exist as a function taking 1 parameter +---*/ + +assert.sameValue(Object.freeze.length, 1, 'Object.freeze.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-1.js new file mode 100644 index 0000000000..418c1eedf4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-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.9-1-1 +description: > + Object.freeze does not throw TypeError if type of first param is + undefined +---*/ + +Object.freeze(undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-2.js new file mode 100644 index 0000000000..98997a2183 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-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.9-1-2 +description: > + Object.freeze does not throw TypeError if type of first param is + null +---*/ + +Object.freeze(null); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-3.js new file mode 100644 index 0000000000..39945d1f8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-3.js @@ -0,0 +1,14 @@ +// 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.9-1-3 +description: > + Object.freeze does not throw TypeError if type of first param is + boolean primitive +---*/ + +Object.freeze(false); +Object.freeze(true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1-4.js new file mode 100644 index 0000000000..4ba634df2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-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.9-1-4 +description: > + Object.freeze does not throw TypeError if type of first param is + string primitive +---*/ + +Object.freeze("abc"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-1.js new file mode 100644 index 0000000000..d5ebef77a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-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.9-1 +description: > + Object.freeze does not throw TypeError if type of first param is + not Object +---*/ + +Object.freeze(0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-1.js new file mode 100644 index 0000000000..f3bd2576e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-1.js @@ -0,0 +1,17 @@ +// 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.9-2-1 +description: > + Object.freeze - extensible of 'O' is set as false even if 'O' has + no own property +---*/ + +var obj = {}; + +Object.freeze(obj); + +assert.sameValue(Object.isExtensible(obj), false, 'Object.isExtensible(obj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-2.js new file mode 100644 index 0000000000..2568b42bcb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-2.js @@ -0,0 +1,29 @@ +// 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.9-2-2 +description: Object.freeze - inherited data properties are not frozen +---*/ + +var proto = {}; + +Object.defineProperty(proto, "Father", { + value: 10, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.freeze(child); + +var beforeDeleted = proto.hasOwnProperty("Father"); +delete proto.Father; +var afterDeleted = proto.hasOwnProperty("Father"); + +assert(beforeDeleted, 'beforeDeleted !== true'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-3.js new file mode 100644 index 0000000000..b319a9f7ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-3.js @@ -0,0 +1,31 @@ +// 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.9-2-3 +description: Object.freeze - inherited accessor properties are not frozen +---*/ + +var proto = {}; + +Object.defineProperty(proto, "Father", { + get: function() { + return 10; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.freeze(child); + +var beforeDeleted = proto.hasOwnProperty("Father"); +delete proto.Father; +var afterDeleted = proto.hasOwnProperty("Father"); + +assert(beforeDeleted, 'beforeDeleted !== true'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-4.js new file mode 100644 index 0000000000..d1c0131160 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-4.js @@ -0,0 +1,24 @@ +// 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.9-2-4 +description: Object.freeze - Non-enumerable own properties of 'O' are frozen +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 10, + enumerable: false, + configurable: true +}); + +Object.freeze(obj); + +assert(obj.hasOwnProperty("foo")); +verifyNotWritable(obj, "foo"); +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-1.js new file mode 100644 index 0000000000..a03d148d17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-1.js @@ -0,0 +1,21 @@ +// 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.9-2-a-1 +description: Object.freeze - 'P' is own data property +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +obj.foo = 10; // default [[Configurable]] attribute value of foo: true + +Object.freeze(obj); + +verifyNotWritable(obj, "foo"); +verifyNotConfigurable(obj, "foo"); + +assert.sameValue(obj.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-10.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-10.js new file mode 100644 index 0000000000..ac66e48f32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-10.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.9-2-a-10 +description: > + Object.freeze - 'P' is own named property of an Array object that + uses Object's [[GetOwnProperty]] +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +arrObj.foo = 10; // default [[Configurable]] attribute value of foo: true + +Object.freeze(arrObj); + +verifyNotWritable(arrObj, "foo"); +verifyNotConfigurable(arrObj, "foo"); + +assert.sameValue(arrObj.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-11.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-11.js new file mode 100644 index 0000000000..b9db664525 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-11.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.9-2-a-11 +description: > + Object.freeze - 'P' is own index property of the Arguments object + that implements its own [[GetOwnProperty]] +includes: [propertyHelper.js] +---*/ + + +// default [[Configurable]] attribute value of "0": true +var argObj = (function() { + return arguments; +}(1, 2, 3)); + +Object.freeze(argObj); + +var desc = Object.getOwnPropertyDescriptor(argObj, "0"); + +verifyNotWritable(argObj, "0"); +verifyNotConfigurable(argObj, "0"); +assert.sameValue(argObj[0], 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-12.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-12.js new file mode 100644 index 0000000000..1eb5dbbc11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-12.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.9-2-a-12 +description: > + Object.freeze - 'P' is own index property of a String object that + implements its own [[GetOwnProperty]] +includes: [propertyHelper.js] +---*/ + + +// default [[Configurable]] attribute value of "0": true +var strObj = new String("abc"); + +Object.freeze(strObj); + +verifyNotWritable(strObj, "0"); +verifyNotConfigurable(strObj, "0"); + +assert.sameValue(strObj[0], "a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-13.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-13.js new file mode 100644 index 0000000000..c4d1fa96be --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-13.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.9-2-a-13 +description: Object.freeze - 'P' is own index property of the Object +includes: [propertyHelper.js] +---*/ + + +// default [[Configurable]] attribute value of "0": true +var obj = { + 0: 0, + 1: 1, + length: 2 +}; + +Object.freeze(obj); + +verifyNotWritable(obj, "0"); +verifyNotConfigurable(obj, "0"); + +assert.sameValue(obj[0], 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-14.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-14.js new file mode 100644 index 0000000000..eecc860739 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-14.js @@ -0,0 +1,21 @@ +// 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.9-2-a-14 +description: > + Object.freeze - 'P' is own index property of an Array object that + uses Object's [[GetOwnProperty]] +includes: [propertyHelper.js] +---*/ + +// default [[Configurable]] attribute value of "0": true +var arrObj = [0, 1, 2]; + +Object.freeze(arrObj); + +verifyNotWritable(arrObj, "0"); +verifyNotConfigurable(arrObj, "0"); +assert.sameValue(arrObj[0], 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-2.js new file mode 100644 index 0000000000..3bf26de301 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-2.js @@ -0,0 +1,31 @@ +// 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.9-2-a-2 +description: > + Object.freeze - 'P' is own data property that overrides an + inherited data property +includes: [propertyHelper.js] +---*/ + + +var proto = { + foo: 0 +}; // default [[Configurable]] attribute value of foo: true + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +child.foo = 10; // default [[Configurable]] attribute value of foo: true + +Object.freeze(child); + +verifyNotWritable(child, "foo"); +verifyNotConfigurable(child, "foo"); + +assert.sameValue(child.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-3.js new file mode 100644 index 0000000000..9e70497f78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-3.js @@ -0,0 +1,36 @@ +// 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.9-2-a-3 +description: > + Object.freeze - 'P' is own data property that overrides an + inherited accessor property +includes: [propertyHelper.js] +---*/ + +var proto = {}; + +Object.defineProperty(proto, "foo", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "foo", { + value: 10, + configurable: true +}); + +Object.freeze(child); + +verifyNotWritable(child, "foo"); +verifyNotConfigurable(child, "foo"); +assert.sameValue(child.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-4.js new file mode 100644 index 0000000000..acdfed7f01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-4.js @@ -0,0 +1,24 @@ +// 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.9-2-a-4 +description: Object.freeze - 'P' is own accessor property +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.freeze(obj); + +verifyNotConfigurable(obj, "foo"); +assert.sameValue(obj.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-5.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-5.js new file mode 100644 index 0000000000..00ff5bfc63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-5.js @@ -0,0 +1,34 @@ +// 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.9-2-a-5 +description: > + Object.freeze - 'P' is own accessor property that overrides an + inherited data property +includes: [propertyHelper.js] +---*/ + + +var proto = {}; + +proto.foo = 0; // default [[Configurable]] attribute value of foo: true + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "foo", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.freeze(child); + +verifyNotConfigurable(child, "foo"); +assert.sameValue(child.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-6.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-6.js new file mode 100644 index 0000000000..163d0a951e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-6.js @@ -0,0 +1,38 @@ +// 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.9-2-a-6 +description: > + Object.freeze - 'P' is own accessor property that overrides an + inherited accessor property +includes: [propertyHelper.js] +---*/ + +var proto = {}; + +Object.defineProperty(proto, "foo", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "foo", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.freeze(child); + +verifyNotConfigurable(child, "foo"); +assert.sameValue(child.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-7.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-7.js new file mode 100644 index 0000000000..c8de353b20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-7.js @@ -0,0 +1,24 @@ +// 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.9-2-a-7 +description: > + Object.freeze - 'P' is own named property of an Arguments object + that implements its own [[GetOwnProperty]] +includes: [propertyHelper.js] +---*/ + +var argObj = (function() { + return arguments; +}()); + +argObj.foo = 10; // default [[Configurable]] attribute value of foo: true + +Object.freeze(argObj); + +verifyNotWritable(argObj, "foo"); +verifyNotConfigurable(argObj, "foo"); +assert.sameValue(argObj.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-8.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-8.js new file mode 100644 index 0000000000..f930bdee5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-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.9-2-a-8 +description: > + Object.freeze - 'P' is own named property of the String object + that implements its own [[GetOwnProperty]] +includes: [propertyHelper.js] +---*/ + +var strObj = new String("abc"); + +strObj.foo = 10; // default [[Configurable]] attribute value of foo: true + +Object.freeze(strObj); + +verifyNotWritable(strObj, "foo"); +verifyNotConfigurable(strObj, "foo"); +assert.sameValue(strObj.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-9.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-9.js new file mode 100644 index 0000000000..2d2c722646 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-9.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.9-2-a-9 +description: > + Object.freeze - 'P' is own property of the Function object that + uses Object's [[GetOwnProperty]] +includes: [propertyHelper.js] +---*/ + +var funObj = function() {}; + +funObj.foo = 10; // default [[Configurable]] attribute value of foo: true + +Object.freeze(funObj); + +verifyNotWritable(funObj, "foo"); +verifyNotConfigurable(funObj, "foo"); + +assert.sameValue(funObj.foo, 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-1.js new file mode 100644 index 0000000000..4c6c953c7b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-1.js @@ -0,0 +1,40 @@ +// 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.9-2-b-i-1 +description: > + Object.freeze - The [[Wrtiable]] attribute of own data property of + 'O' is set to false while other attributes are unchanged +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 10, + writable: true, + enumerable: true, + configurable: false +}); + +Object.freeze(obj); +var desc = Object.getOwnPropertyDescriptor(obj, "foo"); + +verifyEqualTo(obj, "foo", 10); + +verifyNotWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +if (desc.writable !== false) { + throw new Test262Error('Expected desc.writable === false, actually ' + desc.writable); +} + +if (desc.configurable !== false) { + throw new Test262Error('Expected desc.configurable === false, actually ' + desc.configurable); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-2.js new file mode 100644 index 0000000000..2d8a00a53b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-2.js @@ -0,0 +1,66 @@ +// 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.9-2-b-i-2 +description: > + Object.freeze - The [[Wrtiable]] attribute of all own data + property of 'O' is set to false while other attributes are + unchanged +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo1", { + value: 10, + writable: false, + enumerable: true, + configurable: false +}); + +Object.defineProperty(obj, "foo2", { + value: 20, + writable: true, + enumerable: false, + configurable: false +}); + +Object.freeze(obj); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1"); +var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2"); + +verifyEqualTo(obj, "foo1", 10); + +verifyNotWritable(obj, "foo1"); + +verifyEnumerable(obj, "foo1"); + +verifyNotConfigurable(obj, "foo1"); + +verifyEqualTo(obj, "foo2", 20); + +verifyNotWritable(obj, "foo2"); + +verifyNotEnumerable(obj, "foo2"); + +verifyNotConfigurable(obj, "foo2"); + +if (desc1.configurable !== false) { + throw new Test262Error('Expected desc1.configurable === false, actually ' + desc1.configurable); +} + +if (desc1.writable !== false) { + throw new Test262Error('Expected desc1.writable === false, actually ' + desc1.writable); +} + +if (desc2.configurable !== false) { + throw new Test262Error('Expected desc2.configurable === false, actually ' + desc2.configurable); +} + +if (desc2.writable !== false) { + throw new Test262Error('Expected desc2.writable === false, actually ' + desc2.writable); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-1.js new file mode 100644 index 0000000000..219519195c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-1.js @@ -0,0 +1,41 @@ +// 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.9-2-c-1 +description: > + Object.freeze - The [[Configurable]] attribute of own data + property of 'O' is set to false while other attributes are + unchanged +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: true, + configurable: true +}); + +Object.freeze(obj); + +var desc = Object.getOwnPropertyDescriptor(obj, "foo"); + +if (desc.configurable !== false) { + throw new Test262Error("Expected desc.configurable to be false, actually " + desc.configurable); +} +if (desc.writable !== false) { + throw new Test262Error("Expected desc.writable to be false, actually " + desc.writable); +} + +verifyEqualTo(obj, "foo", 10); + +verifyNotWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-2.js new file mode 100644 index 0000000000..af0797a00d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-2.js @@ -0,0 +1,47 @@ +// 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.9-2-c-2 +description: > + Object.freeze - The [[Configurable]] attribute of own accessor + property of 'O' is set to false while other attributes are + unchanged +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +function get_func() { + return 10; +} + +var set_funcCalled = false; + +function set_func() { + set_funcCalled = true; +} + +Object.defineProperty(obj, "foo", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.freeze(obj); + +assert(obj.hasOwnProperty("foo")); +verifyNotConfigurable(obj, "foo"); + +assert.sameValue(obj.foo, 10); + +obj.foo = 12; +assert(set_funcCalled); + +verifyEnumerable(obj, "foo"); + +var desc = Object.getOwnPropertyDescriptor(obj, "foo"); +assert.sameValue(desc.configurable, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-3.js new file mode 100644 index 0000000000..24be086754 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-3.js @@ -0,0 +1,70 @@ +// 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.9-2-c-3 +description: > + Object.freeze - The [[Configurable]] attribute of all own data + property of 'O' is set to false while other attributes are + unchanged +includes: [propertyHelper.js] +---*/ + +var obj = {}; +var resultSetFun = false; + +Object.defineProperty(obj, "foo1", { + value: 10, + writable: false, + enumerable: true, + configurable: true +}); + +function get_func() { + return 10; +} + +function set_func() { + resultSetFun = true; +} + +Object.defineProperty(obj, "foo2", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.freeze(obj); + +verifyNotConfigurable(obj, "foo2"); +verifyEqualTo(obj, "foo2", 10); + +obj.foo2 = 12; +if (!resultSetFun) { + throw new Test262Error('Expected obj["foo2"] set() to be called, but was not.'); +} + +if (!isEnumerable(obj, "foo2")) { + throw new Test262Error('Expected obj["foo2"] to be enumerable.'); +} + +var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1"); +if (desc1.configurable || desc1.writable) { + throw new Test262Error('Expected obj["foo1"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc1)); +} + +var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2"); +if (desc2.configurable || desc2.writable) { + throw new Test262Error('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2)); +} + +verifyEqualTo(obj, "foo1", 10); + +verifyNotWritable(obj, "foo1"); + +verifyEnumerable(obj, "foo1"); + +verifyNotConfigurable(obj, "foo1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-4.js new file mode 100644 index 0000000000..49390cbf84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-4.js @@ -0,0 +1,68 @@ +// 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.9-2-c-4 +description: > + Object.freeze - all own properties of 'O' are not writable and not + configurable +includes: [propertyHelper.js] +---*/ + +var obj = {}; +var resultSetFun = false; + +Object.defineProperty(obj, "foo1", { + value: 10, + writable: false, + enumerable: true, + configurable: false +}); + +function get_func() { + return 10; +} + +function set_func() { + resultSetFun = true; +} + +Object.defineProperty(obj, "foo2", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.freeze(obj); + +verifyEqualTo(obj, "foo2", 10); + +verifyNotConfigurable(obj, "foo2"); + +obj.foo2 = 12; +if (!resultSetFun) { + throw new Test262Error('Expected obj["foo2"] set() to be called, but was not.'); +} + +verifyEnumerable(obj, "foo2"); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1"); +if (desc1.configurable || desc1.writable) { + throw new Test262Error('Expected obj["foo1"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc1)); +} + +var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2"); +if (desc2.configurable || desc2.writable) { + throw new Test262Error('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2)); +} + +verifyEqualTo(obj, "foo1", 10); + +verifyNotWritable(obj, "foo1"); + +verifyEnumerable(obj, "foo1"); + +verifyNotConfigurable(obj, "foo1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-1.js new file mode 100644 index 0000000000..c4f2659e2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-1.js @@ -0,0 +1,15 @@ +// 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.9-2-d-1 +description: Object.freeze - 'O' is a Function object +---*/ + +var funObj = function() {}; + +Object.freeze(funObj); + +assert(Object.isFrozen(funObj), 'Object.isFrozen(funObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-2.js new file mode 100644 index 0000000000..1bf24a57b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-2.js @@ -0,0 +1,15 @@ +// 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.9-2-d-2 +description: Object.freeze - 'O' is an Array object +---*/ + +var arrObj = [0, 1]; + +Object.freeze(arrObj); + +assert(Object.isFrozen(arrObj), 'Object.isFrozen(arrObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-3.js new file mode 100644 index 0000000000..ba368c60c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-3.js @@ -0,0 +1,15 @@ +// 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.9-2-d-3 +description: Object.freeze - 'O' is a String object +---*/ + +var strObj = new String("a"); + +Object.freeze(strObj); + +assert(Object.isFrozen(strObj), 'Object.isFrozen(strObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-4.js new file mode 100644 index 0000000000..de82e4228d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-4.js @@ -0,0 +1,15 @@ +// 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.9-2-d-4 +description: Object.freeze - 'O' is a Boolean object +---*/ + +var boolObj = new Boolean(false); + +Object.freeze(boolObj); + +assert(Object.isFrozen(boolObj), 'Object.isFrozen(boolObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-5.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-5.js new file mode 100644 index 0000000000..82f44bc68f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-5.js @@ -0,0 +1,15 @@ +// 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.9-2-d-5 +description: Object.freeze - 'O' is a Number object +---*/ + +var numObj = new Number(3); + +Object.freeze(numObj); + +assert(Object.isFrozen(numObj), 'Object.isFrozen(numObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-6.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-6.js new file mode 100644 index 0000000000..1578c057a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-6.js @@ -0,0 +1,15 @@ +// 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.9-2-d-6 +description: Object.freeze - 'O' is a Date object +---*/ + +var dateObj = new Date(); + +Object.freeze(dateObj); + +assert(Object.isFrozen(dateObj), 'Object.isFrozen(dateObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-7.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-7.js new file mode 100644 index 0000000000..2665520211 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-7.js @@ -0,0 +1,15 @@ +// 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.9-2-d-7 +description: Object.freeze - 'O' is a RegExp object +---*/ + +var regObj = new RegExp(); + +Object.freeze(regObj); + +assert(Object.isFrozen(regObj), 'Object.isFrozen(regObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-8.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-8.js new file mode 100644 index 0000000000..aaf3b8f901 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-8.js @@ -0,0 +1,15 @@ +// 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.9-2-d-8 +description: Object.freeze - 'O' is an Error object +---*/ + +var errObj = new SyntaxError(); + +Object.freeze(errObj); + +assert(Object.isFrozen(errObj), 'Object.isFrozen(errObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-9.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-9.js new file mode 100644 index 0000000000..62cf0f48e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-d-9.js @@ -0,0 +1,17 @@ +// 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.9-2-d-9 +description: Object.freeze - 'O' is the Arguments object +---*/ + +var argObj = (function() { + return arguments; +}()); + +Object.freeze(argObj); + +assert(Object.isFrozen(argObj), 'Object.isFrozen(argObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-3-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-3-1.js new file mode 100644 index 0000000000..262adea1c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-3-1.js @@ -0,0 +1,14 @@ +// 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.9-3-1 +description: Object.freeze - returned object is not extensible +---*/ + +var obj = {}; +Object.freeze(obj); + +assert.sameValue(Object.isExtensible(obj), false, 'Object.isExtensible(obj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-1.js new file mode 100644 index 0000000000..32cf02a38f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-1.js @@ -0,0 +1,19 @@ +// 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.9-4-1 +description: Object.freeze - 'O' is sealed already +---*/ + +var obj = {}; + +obj.foo = 10; // default value of attributes: writable: true, enumerable: true + +Object.seal(obj); + +Object.freeze(obj); + +assert(Object.isFrozen(obj), 'Object.isFrozen(obj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-2.js new file mode 100644 index 0000000000..c58b336b8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-2.js @@ -0,0 +1,19 @@ +// 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.9-4-2 +description: Object.freeze - 'O' is frozen already +---*/ + +var obj = {}; + +obj.foo = 10; // default value of attributes: writable: true, enumerable: true + +Object.freeze(obj); + +Object.freeze(obj); + +assert(Object.isFrozen(obj), 'Object.isFrozen(obj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-3.js new file mode 100644 index 0000000000..e6341d163d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-4-3.js @@ -0,0 +1,19 @@ +// 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.9-4-3 +description: Object.freeze - the extensions of 'O' is prevented already +---*/ + +var obj = {}; + +obj.foo = 10; // default value of attributes: writable: true, enumerable: true + +Object.preventExtensions(obj); + +Object.freeze(obj); + +assert(Object.isFrozen(obj), 'Object.isFrozen(obj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/abrupt-completion.js b/js/src/tests/test262/built-ins/Object/freeze/abrupt-completion.js new file mode 100644 index 0000000000..fe2dc37215 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/abrupt-completion.js @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.freeze +description: > + O.[[PreventExtensions]]() returns abrupt completion. +info: | + Object.freeze ( O ) + + ... + 2. Let status be ? SetIntegrityLevel(O, frozen). + + SetIntegrityLevel ( O, level ) + + ... + 3. Let status be ? O.[[PreventExtensions]](). +features: [Proxy] +---*/ + +var p = new Proxy({}, { + preventExtensions: function() { + throw new Test262Error(); + }, +}); + +assert.throws(Test262Error, function() { + Object.freeze(p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/browser.js b/js/src/tests/test262/built-ins/Object/freeze/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/browser.js diff --git a/js/src/tests/test262/built-ins/Object/freeze/frozen-object-contains-symbol-properties-non-strict.js b/js/src/tests/test262/built-ins/Object/freeze/frozen-object-contains-symbol-properties-non-strict.js new file mode 100644 index 0000000000..c8992cca64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/frozen-object-contains-symbol-properties-non-strict.js @@ -0,0 +1,18 @@ +// 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.1.2.5 +description: > + Frozen object contains symbol properties. +flags: [noStrict] +features: [Symbol] +---*/ +var sym = Symbol(); +var obj = {}; +obj[sym] = 1; +Object.freeze(obj); +obj[sym] = 2; +assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`"); +assert.sameValue(delete obj[sym], false, "`delete obj[sym]` is `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/frozen-object-contains-symbol-properties-strict-strict.js b/js/src/tests/test262/built-ins/Object/freeze/frozen-object-contains-symbol-properties-strict-strict.js new file mode 100644 index 0000000000..a94217e219 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/frozen-object-contains-symbol-properties-strict-strict.js @@ -0,0 +1,20 @@ +'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.1.2.5 +description: > + Frozen object contains symbol properties. +flags: [onlyStrict] +features: [Symbol] +---*/ +var sym = Symbol("66"); +var obj = {}; +obj[sym] = 1; +Object.freeze(obj); + +assert.throws(TypeError, function() { + obj[sym] = 2; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/name.js b/js/src/tests/test262/built-ins/Object/freeze/name.js new file mode 100644 index 0000000000..1881d15751 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/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.5 +description: > + Object.freeze.name is "freeze". +info: | + Object.freeze ( 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.freeze.name, "freeze"); + +verifyNotEnumerable(Object.freeze, "name"); +verifyNotWritable(Object.freeze, "name"); +verifyConfigurable(Object.freeze, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/freeze/not-a-constructor.js new file mode 100644 index 0000000000..6d928f4f11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/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: > + Object.freeze 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.freeze), false, 'isConstructor(Object.freeze) must return false'); + +assert.throws(TypeError, () => { + new Object.freeze({}); +}, '`new Object.freeze({})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/proxy-no-ownkeys-returned-keys-order.js b/js/src/tests/test262/built-ins/Object/freeze/proxy-no-ownkeys-returned-keys-order.js new file mode 100644 index 0000000000..98af5d3c33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/proxy-no-ownkeys-returned-keys-order.js @@ -0,0 +1,57 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.freeze +description: > + If Proxy "ownKeys" trap is missing, keys are sorted by type in ascending + chronological order. +info: | + SetIntegrityLevel ( O, level ) + + [...] + 5. Let keys be ? O.[[OwnPropertyKeys]](). + 6. If level is sealed, then + [...] + 7. Else, + a. Assert: level is frozen. + b. For each element k of keys, do + i. Let currentDesc be ? O.[[GetOwnProperty]](k). + + [[OwnPropertyKeys]] ( ) + + [...] + 6. If trap is undefined, then + a. Return ? target.[[OwnPropertyKeys]](). + + OrdinaryOwnPropertyKeys ( O ) + + [...] + 3. For each own property key P of O such that Type(P) is String and P is + not an array index, in ascending chronological order of property creation, do + a. Add P as the last element of keys. + 4. For each own property key P of O such that Type(P) is Symbol, + in ascending chronological order of property creation, do + a. Add P as the last element of keys. + 5. Return keys. +features: [Proxy, Symbol, Reflect] +includes: [compareArray.js] +---*/ + +var target = {}; +var sym = Symbol(); +target[sym] = 1; +target.foo = 2; +target[0] = 3; + +var getOwnKeys = []; +var proxy = new Proxy(target, { + getOwnPropertyDescriptor: function(target, key) { + getOwnKeys.push(key); + return Reflect.getOwnPropertyDescriptor(target, key); + }, +}); + +Object.freeze(proxy); +assert.compareArray(getOwnKeys, ["0", "foo", sym]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/proxy-with-defineProperty-handler.js b/js/src/tests/test262/built-ins/Object/freeze/proxy-with-defineProperty-handler.js new file mode 100644 index 0000000000..733ed267e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/proxy-with-defineProperty-handler.js @@ -0,0 +1,52 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.freeze +description: > + [[DefineOwnProperty]] is called with partial descriptor with only [[Configurable]] and + [[Writable]] (for data properties only) fields present. +info: | + SetIntegrityLevel ( O, level ) + + [...] + 5. Let keys be ? O.[[OwnPropertyKeys]](). + [...] + 7. Else, + a. Assert: level is frozen. + b. For each element k of keys, do + i. Let currentDesc be ? O.[[GetOwnProperty]](k). + ii. If currentDesc is not undefined, then + 1. If IsAccessorDescriptor(currentDesc) is true, then + a. Let desc be the PropertyDescriptor { [[Configurable]]: false }. + 2. Else, + a. Let desc be the PropertyDescriptor { [[Configurable]]: false, [[Writable]]: false }. + 3. Perform ? DefinePropertyOrThrow(O, k, desc). +features: [Symbol, Proxy, Reflect] +---*/ + +var sym = Symbol(); +var seenDescriptors = {}; +var proxy = new Proxy({ + [sym]: 1, + get foo() {}, + set foo(_v) {}, +}, { + defineProperty: function(target, key, descriptor) { + seenDescriptors[key] = descriptor; + return Reflect.defineProperty(target, key, descriptor); + }, +}); + +Object.freeze(proxy); + +assert.sameValue(seenDescriptors[sym].value, undefined, "value"); +assert.sameValue(seenDescriptors[sym].writable, false, "writable"); +assert.sameValue(seenDescriptors[sym].enumerable, undefined, "enumerable"); +assert.sameValue(seenDescriptors[sym].configurable, false, "configurable"); + +assert.sameValue(seenDescriptors.foo.get, undefined, "get"); +assert.sameValue(seenDescriptors.foo.set, undefined, "set"); +assert.sameValue(seenDescriptors.foo.enumerable, undefined, "enumerable"); +assert.sameValue(seenDescriptors.foo.configurable, false, "configurable"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/shell.js b/js/src/tests/test262/built-ins/Object/freeze/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/shell.js diff --git a/js/src/tests/test262/built-ins/Object/freeze/throws-when-false.js b/js/src/tests/test262/built-ins/Object/freeze/throws-when-false.js new file mode 100644 index 0000000000..ce2e5ae626 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/freeze/throws-when-false.js @@ -0,0 +1,30 @@ +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.freeze +description: > + Object.freeze throws if SetIntegrityLevel(O, frozen) returns false. +info: | + Object.freeze ( O ) + ... + 2. Let status be ? SetIntegrityLevel(O, frozen). + 3. If status is false, throw a TypeError exception. + + SetIntegrityLevel ( O, level ) + ... + 3. Let status be ? O.[[PreventExtensions]](). + 4. If status is false, return false. +---*/ + +const p = new Proxy({}, { + preventExtensions() { + return false; + }, +}); + +assert.throws(TypeError, () => { + Object.freeze(p); +}); + +reportCompare(0, 0); |