mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Merge pull request #259 from smikes/more-strict-object-property
fix tests in strict mode - Object/defineProperty
This commit is contained in:
commit
61cd8c6ad7
@ -26,7 +26,7 @@ try {
|
|||||||
|
|
||||||
assert.sameValue(obj.prop, 2010);
|
assert.sameValue(obj.prop, 2010);
|
||||||
verifyNotWritable(obj, "prop");
|
verifyNotWritable(obj, "prop");
|
||||||
|
assert.sameValue(obj.prop, 2010);
|
||||||
} finally {
|
} finally {
|
||||||
delete obj.prop;
|
delete obj.prop;
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,12 @@ description: >
|
|||||||
to an accessor property, 'O' is the global object (8.12.9 - step
|
to an accessor property, 'O' is the global object (8.12.9 - step
|
||||||
9.b.i)
|
9.b.i)
|
||||||
includes:
|
includes:
|
||||||
- runTestCase.js
|
- propertyHelper.js
|
||||||
- fnGlobalObject.js
|
- fnGlobalObject.js
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = fnGlobalObject();
|
||||||
var obj = fnGlobalObject();
|
try {
|
||||||
try {
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
value: 2010,
|
value: 2010,
|
||||||
writable: false,
|
writable: false,
|
||||||
@ -35,11 +34,13 @@ function testcase() {
|
|||||||
});
|
});
|
||||||
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
|
|
||||||
return desc1.hasOwnProperty("value") && desc2.hasOwnProperty("get") &&
|
assert(desc1.hasOwnProperty("value"));
|
||||||
desc2.enumerable === true && desc2.configurable === true &&
|
assert(desc2.hasOwnProperty("get"));
|
||||||
obj.prop === 20 && typeof desc2.set === "undefined" && desc2.get === getFunc;
|
assert.sameValue(desc2.enumerable, true);
|
||||||
} finally {
|
assert.sameValue(desc2.configurable, true);
|
||||||
|
assert.sameValue(obj.prop, 20);
|
||||||
|
assert.sameValue(typeof desc2.set, "undefined");
|
||||||
|
assert.sameValue(desc2.get, getFunc);
|
||||||
|
} finally {
|
||||||
delete obj.prop;
|
delete obj.prop;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -10,29 +10,27 @@ description: >
|
|||||||
ES5 Attributes - Updating a named accessor property 'P' without
|
ES5 Attributes - Updating a named accessor property 'P' without
|
||||||
[[Set]] using simple assignment is failed, 'O' is an Arguments
|
[[Set]] using simple assignment is failed, 'O' is an Arguments
|
||||||
object (8.12.5 step 5.b)
|
object (8.12.5 step 5.b)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = (function () {
|
||||||
var obj = (function () {
|
|
||||||
return arguments;
|
return arguments;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
var verifySetFunc = "data";
|
var verifySetFunc = "data";
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return verifySetFunc;
|
return verifySetFunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
get: getFunc,
|
get: getFunc,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
obj.prop = "overrideData";
|
assert(obj.hasOwnProperty("prop"));
|
||||||
var propertyDefineCorrect = obj.hasOwnProperty("prop");
|
verifyNotWritable(obj, "prop");
|
||||||
var desc = Object.getOwnPropertyDescriptor(obj, "prop");
|
var desc = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
|
|
||||||
return propertyDefineCorrect && typeof desc.set === "undefined" && obj.prop === "data";
|
assert.sameValue(typeof desc.set, "undefined");
|
||||||
}
|
assert.sameValue(obj.prop, "data");
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -11,13 +11,12 @@ description: >
|
|||||||
[[Set]] using simple assignment is failed, 'O' is the global
|
[[Set]] using simple assignment is failed, 'O' is the global
|
||||||
object (8.12.5 step 5.b)
|
object (8.12.5 step 5.b)
|
||||||
includes:
|
includes:
|
||||||
- runTestCase.js
|
- propertyHelper.js
|
||||||
- fnGlobalObject.js
|
- fnGlobalObject.js
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = fnGlobalObject();
|
||||||
var obj = fnGlobalObject();
|
try {
|
||||||
try {
|
|
||||||
obj.verifySetFunc = "data";
|
obj.verifySetFunc = "data";
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return obj.verifySetFunc;
|
return obj.verifySetFunc;
|
||||||
@ -29,14 +28,13 @@ function testcase() {
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
obj.prop = "overrideData";
|
assert(obj.hasOwnProperty("prop"));
|
||||||
var propertyDefineCorrect = obj.hasOwnProperty("prop");
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(obj, "prop");
|
var desc = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
|
|
||||||
return propertyDefineCorrect && typeof desc.set === "undefined" && obj.prop === "data";
|
verifyNotWritable(obj, "prop");
|
||||||
} finally {
|
assert.sameValue(typeof desc.set, "undefined");
|
||||||
|
assert.sameValue(obj.prop, "data");
|
||||||
|
} finally {
|
||||||
delete obj.prop;
|
delete obj.prop;
|
||||||
delete obj.verifySetFunc;
|
delete obj.verifySetFunc;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -11,35 +11,35 @@ description: >
|
|||||||
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
||||||
[[Enumerable]] is true, [[Configurable]] is true) to different
|
[[Enumerable]] is true, [[Configurable]] is true) to different
|
||||||
value
|
value
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
var obj = {};
|
|
||||||
|
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return 1001;
|
return 1001;
|
||||||
};
|
};
|
||||||
|
|
||||||
var verifySetFunc = "data";
|
var verifySetFunc = "data";
|
||||||
var setFunc = function (value) {
|
var setFunc = function (value) {
|
||||||
verifySetFunc = value;
|
verifySetFunc = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
get: getFunc,
|
get: getFunc,
|
||||||
set: setFunc,
|
set: setFunc,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
|
|
||||||
|
Object.defineProperty(obj, "prop", {
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
delete obj.prop;
|
|
||||||
|
|
||||||
return desc1.configurable === true && desc2.configurable === false && obj.hasOwnProperty("prop");
|
verifyNotConfigurable(obj, "prop");
|
||||||
}
|
assert.sameValue(desc1.configurable, true);
|
||||||
runTestCase(testcase);
|
assert.sameValue(desc2.configurable, false);
|
||||||
|
assert(obj.hasOwnProperty("prop"));
|
||||||
|
@ -10,38 +10,24 @@ description: >
|
|||||||
Object.defineProperty - 'name' property doesn't exist in 'O', test
|
Object.defineProperty - 'name' property doesn't exist in 'O', test
|
||||||
[[Set]] of 'name' property of 'Attributes' is set as undefined
|
[[Set]] of 'name' property of 'Attributes' is set as undefined
|
||||||
value if absent in accessor descriptor 'desc' (8.12.9 step 4.b.i)
|
value if absent in accessor descriptor 'desc' (8.12.9 step 4.b.i)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
var obj = {};
|
|
||||||
|
|
||||||
Object.defineProperty(obj, "property", {
|
Object.defineProperty(obj, "property", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return "property";
|
return "property";
|
||||||
},
|
},
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (obj.property !== "property") {
|
assert.sameValue(obj.property, "property");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(obj, "property");
|
|
||||||
if (typeof desc.set !== "undefined") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (var p in obj) {
|
|
||||||
if (p === "property") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete obj.property;
|
|
||||||
if (!obj.hasOwnProperty("property")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
var desc = Object.getOwnPropertyDescriptor(obj, "property");
|
||||||
}
|
assert.sameValue(typeof desc.set, "undefined");
|
||||||
runTestCase(testcase);
|
|
||||||
|
verifyNotEnumerable(obj, "property");
|
||||||
|
verifyNotConfigurable(obj, "property");
|
||||||
|
@ -10,33 +10,26 @@ description: >
|
|||||||
ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a
|
ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a
|
||||||
Function, [[Enumerable]] is true, [[Configurable]] is false) is
|
Function, [[Enumerable]] is true, [[Configurable]] is false) is
|
||||||
undeletable
|
undeletable
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
var obj = {};
|
|
||||||
|
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return 1001;
|
return 1001;
|
||||||
};
|
};
|
||||||
|
|
||||||
var verifySetFunc = "data";
|
var verifySetFunc = "data";
|
||||||
var setFunc = function (value) {
|
var setFunc = function (value) {
|
||||||
verifySetFunc = value;
|
verifySetFunc = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
get: getFunc,
|
get: getFunc,
|
||||||
set: setFunc,
|
set: setFunc,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var propertyDefineCorrect = obj.hasOwnProperty("prop");
|
assert(obj.hasOwnProperty("prop"));
|
||||||
var desc = Object.getOwnPropertyDescriptor(obj, "prop");
|
verifyNotConfigurable(obj, "prop");
|
||||||
|
|
||||||
delete obj.prop;
|
|
||||||
|
|
||||||
return propertyDefineCorrect && desc.configurable === false && obj.hasOwnProperty("prop");
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -11,40 +11,40 @@ description: >
|
|||||||
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
||||||
[[Enumerable]] is true, [[Configurable]] is false) to different
|
[[Enumerable]] is true, [[Configurable]] is false) to different
|
||||||
value
|
value
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
var obj = {};
|
|
||||||
|
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return 1001;
|
return 1001;
|
||||||
};
|
};
|
||||||
|
|
||||||
var verifySetFunc = "data";
|
var verifySetFunc = "data";
|
||||||
var setFunc = function (value) {
|
var setFunc = function (value) {
|
||||||
verifySetFunc = value;
|
verifySetFunc = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
get: getFunc,
|
get: getFunc,
|
||||||
set: setFunc,
|
set: setFunc,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
$ERROR("Expected TypeError");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
assert(e instanceof TypeError);
|
||||||
delete obj.prop;
|
assert.sameValue(desc1.configurable, false);
|
||||||
|
|
||||||
return desc1.configurable === false && desc2.configurable === false && obj.hasOwnProperty("prop") && e instanceof TypeError;
|
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
}
|
assert.sameValue(desc2.configurable, false);
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
verifyNotConfigurable(obj, "prop");
|
||||||
|
}
|
||||||
|
@ -11,36 +11,32 @@ description: >
|
|||||||
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
||||||
[[Enumerable]] is false, [[Configurable]] is true) to different
|
[[Enumerable]] is false, [[Configurable]] is true) to different
|
||||||
value
|
value
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
var obj = {};
|
|
||||||
|
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return 1001;
|
return 1001;
|
||||||
};
|
};
|
||||||
|
|
||||||
var verifySetFunc = "data";
|
var verifySetFunc = "data";
|
||||||
var setFunc = function (value) {
|
var setFunc = function (value) {
|
||||||
verifySetFunc = value;
|
verifySetFunc = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
get: getFunc,
|
get: getFunc,
|
||||||
set: setFunc,
|
set: setFunc,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
|
assert.sameValue(desc1.configurable, true);
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
|
||||||
delete obj.prop;
|
|
||||||
|
|
||||||
return desc1.configurable === true && desc2.configurable === false && obj.hasOwnProperty("prop");
|
verifyNotConfigurable(obj, "prop");
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -10,33 +10,26 @@ description: >
|
|||||||
ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a
|
ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a
|
||||||
Function, [[Enumerable]] is false, [[Configurable]] is false) is
|
Function, [[Enumerable]] is false, [[Configurable]] is false) is
|
||||||
undeletable
|
undeletable
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
var obj = {};
|
|
||||||
|
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return 1001;
|
return 1001;
|
||||||
};
|
};
|
||||||
|
|
||||||
var verifySetFunc = "data";
|
var verifySetFunc = "data";
|
||||||
var setFunc = function (value) {
|
var setFunc = function (value) {
|
||||||
verifySetFunc = value;
|
verifySetFunc = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
get: getFunc,
|
get: getFunc,
|
||||||
set: setFunc,
|
set: setFunc,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var propertyDefineCorrect = obj.hasOwnProperty("prop");
|
assert(obj.hasOwnProperty("prop"));
|
||||||
var desc = Object.getOwnPropertyDescriptor(obj, "prop");
|
verifyNotConfigurable(obj, "prop");
|
||||||
|
|
||||||
delete obj.prop;
|
|
||||||
|
|
||||||
return propertyDefineCorrect && desc.configurable === false && obj.hasOwnProperty("prop");
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -11,40 +11,36 @@ description: >
|
|||||||
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
accessor property ([[Get]] is a Function, [[Set]] is a Function,
|
||||||
[[Enumerable]] is false, [[Configurable]] is false) to different
|
[[Enumerable]] is false, [[Configurable]] is false) to different
|
||||||
value
|
value
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
var obj = {};
|
|
||||||
|
|
||||||
var getFunc = function () {
|
var getFunc = function () {
|
||||||
return 1001;
|
return 1001;
|
||||||
};
|
};
|
||||||
|
|
||||||
var verifySetFunc = "data";
|
var verifySetFunc = "data";
|
||||||
var setFunc = function (value) {
|
var setFunc = function (value) {
|
||||||
verifySetFunc = value;
|
verifySetFunc = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
get: getFunc,
|
get: getFunc,
|
||||||
set: setFunc,
|
set: setFunc,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
$ERROR("Expected TypeError");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
|
assert(e instanceof TypeError);
|
||||||
delete obj.prop;
|
assert.sameValue(desc1.configurable, false);
|
||||||
|
verifyNotConfigurable(obj, "prop");
|
||||||
return desc1.configurable === false && desc2.configurable === false && obj.hasOwnProperty("prop") && e instanceof TypeError;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -7,12 +7,11 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.6-4-581
|
es5id: 15.2.3.6-4-581
|
||||||
description: ES5 Attributes - Fail to add property into object (Number instance)
|
description: ES5 Attributes - Fail to add property into object (Number instance)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var data = "data";
|
||||||
var data = "data";
|
try {
|
||||||
try {
|
|
||||||
Object.defineProperty(Number.prototype, "prop", {
|
Object.defineProperty(Number.prototype, "prop", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return data;
|
return data;
|
||||||
@ -21,11 +20,12 @@ function testcase() {
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
var numObj = new Number();
|
var numObj = new Number();
|
||||||
numObj.prop = "myOwnProperty";
|
|
||||||
|
|
||||||
return !numObj.hasOwnProperty("prop") && numObj.prop === "data" && data === "data";
|
verifyNotWritable(numObj, "prop", "nocheck");
|
||||||
} finally {
|
|
||||||
|
assert(!numObj.hasOwnProperty("prop"));
|
||||||
|
assert.sameValue(numObj.prop, "data");
|
||||||
|
assert.sameValue(data, "data");
|
||||||
|
} finally {
|
||||||
delete Number.prototype.prop;
|
delete Number.prototype.prop;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -9,12 +9,11 @@ es5id: 15.2.3.6-4-586
|
|||||||
description: >
|
description: >
|
||||||
ES5 Attributes - Fail to update value of property into of
|
ES5 Attributes - Fail to update value of property into of
|
||||||
[[Proptotype]] internal property (JSON)
|
[[Proptotype]] internal property (JSON)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var data = "data";
|
||||||
var data = "data";
|
try {
|
||||||
try {
|
|
||||||
Object.defineProperty(Object.prototype, "prop", {
|
Object.defineProperty(Object.prototype, "prop", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return data;
|
return data;
|
||||||
@ -22,11 +21,11 @@ function testcase() {
|
|||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
JSON.prop = "myOwnProperty";
|
verifyNotWritable(JSON, "prop", "nocheck");
|
||||||
|
|
||||||
return !JSON.hasOwnProperty("prop") && JSON.prop === "data" && data === "data";
|
assert(!JSON.hasOwnProperty("prop"));
|
||||||
} finally {
|
assert.sameValue(JSON.prop, "data");
|
||||||
|
assert.sameValue(data, "data");
|
||||||
|
} finally {
|
||||||
delete Object.prototype.prop;
|
delete Object.prototype.prop;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -9,51 +9,61 @@ es5id: 15.2.3.6-4-591
|
|||||||
description: >
|
description: >
|
||||||
ES5 Attributes - Fail to update value of property of
|
ES5 Attributes - Fail to update value of property of
|
||||||
[[Proptotype]] internal property (Object.create)
|
[[Proptotype]] internal property (Object.create)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var appointment = {};
|
||||||
var appointment = {};
|
|
||||||
|
|
||||||
var data1 = 1001;
|
var data1 = 1001;
|
||||||
Object.defineProperty(appointment, "startTime", {
|
Object.defineProperty(appointment, "startTime", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return data1;
|
return data1;
|
||||||
},
|
},
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
var data2 = "NAME";
|
var data2 = "NAME";
|
||||||
Object.defineProperty(appointment, "name", {
|
Object.defineProperty(appointment, "name", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return data2;
|
return data2;
|
||||||
},
|
},
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var meeting = Object.create(appointment);
|
var meeting = Object.create(appointment);
|
||||||
var data3 = "In-person meeting";
|
var data3 = "In-person meeting";
|
||||||
Object.defineProperty(meeting, "conferenceCall", {
|
Object.defineProperty(meeting, "conferenceCall", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return data3;
|
return data3;
|
||||||
},
|
},
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var teamMeeting = Object.create(meeting);
|
var teamMeeting = Object.create(meeting);
|
||||||
|
|
||||||
|
verifyNotWritable(teamMeeting, "name", "nocheck");
|
||||||
|
verifyNotWritable(teamMeeting, "startTime", "nocheck");
|
||||||
|
verifyNotWritable(teamMeeting, "conferenceCall", "nocheck");
|
||||||
|
|
||||||
|
try {
|
||||||
teamMeeting.name = "IE Team Meeting";
|
teamMeeting.name = "IE Team Meeting";
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
var dateObj = new Date("10/31/2010 08:00");
|
var dateObj = new Date("10/31/2010 08:00");
|
||||||
teamMeeting.startTime = dateObj;
|
teamMeeting.startTime = dateObj;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
teamMeeting.conferenceCall = "4255551212";
|
teamMeeting.conferenceCall = "4255551212";
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
var hasOwnProperty = !teamMeeting.hasOwnProperty("name") &&
|
assert(!teamMeeting.hasOwnProperty("name"));
|
||||||
!teamMeeting.hasOwnProperty("startTime") &&
|
assert(!teamMeeting.hasOwnProperty("startTime"));
|
||||||
!teamMeeting.hasOwnProperty('conferenceCall');
|
assert(!teamMeeting.hasOwnProperty('conferenceCall'));
|
||||||
|
|
||||||
return hasOwnProperty && teamMeeting.name === "NAME" &&
|
assert.sameValue(teamMeeting.name, "NAME");
|
||||||
teamMeeting.startTime === 1001 &&
|
assert.sameValue(teamMeeting.startTime, 1001);
|
||||||
teamMeeting.conferenceCall === "In-person meeting";
|
assert.sameValue(teamMeeting.conferenceCall, "In-person meeting");
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -9,13 +9,12 @@ es5id: 15.2.3.6-4-596
|
|||||||
description: >
|
description: >
|
||||||
ES5 Attributes - Fail to update value of property into of
|
ES5 Attributes - Fail to update value of property into of
|
||||||
[[Proptotype]] internal property (Function.prototype.bind)
|
[[Proptotype]] internal property (Function.prototype.bind)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var foo = function () { };
|
||||||
var foo = function () { };
|
var data = "data";
|
||||||
var data = "data";
|
try {
|
||||||
try {
|
|
||||||
Object.defineProperty(Function.prototype, "prop", {
|
Object.defineProperty(Function.prototype, "prop", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return data;
|
return data;
|
||||||
@ -25,11 +24,10 @@ function testcase() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var obj = foo.bind({});
|
var obj = foo.bind({});
|
||||||
obj.prop = "overrideData";
|
|
||||||
|
|
||||||
return !obj.hasOwnProperty("prop") && obj.prop === "data";
|
assert(!obj.hasOwnProperty("prop"));
|
||||||
} finally {
|
verifyNotWritable(obj, "prop", "nocheck");
|
||||||
|
assert.sameValue(obj.prop, "data");;
|
||||||
|
} finally {
|
||||||
delete Function.prototype.prop;
|
delete Function.prototype.prop;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -9,37 +9,19 @@ es5id: 15.2.3.6-4-63
|
|||||||
description: >
|
description: >
|
||||||
Object.defineProperty - both desc.value and name.value are NaN
|
Object.defineProperty - both desc.value and name.value are NaN
|
||||||
(8.12.9 step 6)
|
(8.12.9 step 6)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
|
|
||||||
var obj = {};
|
Object.defineProperty(obj, "foo", { value: NaN });
|
||||||
|
|
||||||
Object.defineProperty(obj, "foo", { value: NaN });
|
Object.defineProperty(obj, "foo", { value: NaN });
|
||||||
|
|
||||||
Object.defineProperty(obj, "foo", { value: NaN });
|
assert(isNaN(obj.foo));
|
||||||
|
|
||||||
if (!isNaN(obj.foo)) {
|
verifyNotWritable(obj, "foo");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj.foo = "verifyValue";
|
verifyNotEnumerable(obj, "foo");
|
||||||
if (obj.foo === "verifyValue") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var prop in obj) {
|
verifyNotConfigurable(obj, "foo");
|
||||||
if (obj.hasOwnProperty(prop) && prop === "foo") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete obj.foo;
|
|
||||||
if (!obj.hasOwnProperty("foo")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -10,45 +10,27 @@ description: >
|
|||||||
Object.defineProperty will not throw TypeError if
|
Object.defineProperty will not throw TypeError if
|
||||||
name.configurable = false, name.writable = false, name.value = NaN
|
name.configurable = false, name.writable = false, name.value = NaN
|
||||||
and desc.value = NaN (8.12.9 step 10.a.ii.1)
|
and desc.value = NaN (8.12.9 step 10.a.ii.1)
|
||||||
includes: [runTestCase.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
var obj = {};
|
||||||
|
|
||||||
var obj = {};
|
Object.defineProperty(obj, "foo", {
|
||||||
|
|
||||||
Object.defineProperty(obj, "foo", {
|
|
||||||
value: NaN,
|
value: NaN,
|
||||||
writable: false,
|
writable: false,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.defineProperty(obj, "foo", {
|
Object.defineProperty(obj, "foo", {
|
||||||
value: NaN,
|
value: NaN,
|
||||||
writable: false,
|
writable: false,
|
||||||
configurable: false
|
configurable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isNaN(obj.foo)) {
|
assert(isNaN(obj.foo));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj.foo = "verifyValue";
|
verifyNotWritable(obj, "foo");
|
||||||
if (obj.foo === "verifyValue") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var prop in obj) {
|
verifyNotEnumerable(obj, "foo");
|
||||||
if (obj.hasOwnProperty(prop) && prop === "foo") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete obj.foo;
|
verifyNotConfigurable(obj, "foo");
|
||||||
if (!obj.hasOwnProperty("foo")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user