archives

« Bugzilla Issues Index

#1450 — No-one seems to know why Test 12.6.4-2.js does what it does.


As discussed on-list[1], this test (quoted below) sets up a non-enumerable property in the prototype of an object we wish to loop over. It does not shadow this property. It does not test to see if that property is enumerated.

Since no-one seems to know what behaviour this is intended to expose, it seems likely that it's not doing what it was intended to do.

function testcase() {
var obj = {};

var proto = {};

Object.defineProperty(proto, "prop", {
value: "inheritedValue",
enumerable: false,
configurable: true,
writable: true
});

var ConstructFun = function () { };
ConstructFun.prototype = proto;

var child = new ConstructFun();

Object.defineProperty(child, "prop1", {
value: "overridedValue1",
enumerable: false
});
Object.defineProperty(child, "prop2", {
value: "overridedValue2",
enumerable: true
});
var accessedProp1 = false;
var accessedProp2 = false;

for (var p in child) {
if (child.hasOwnProperty(p)) {
if (p === "prop1") {
accessedProp1 = true;
}
if (p === "prop2") {
accessedProp2 = true;
}
}
}
return !accessedProp1 && accessedProp2 && child.prop1 === "overridedValue1" && child.prop2 === "overridedValue2";
}

[1] https://mail.mozilla.org/pipermail/test262-discuss/2013-April/000188.html