Bug 942390 - Don't use the iterator cache if the object has an __iterator__ property. r=bhackett

This commit is contained in:
Jan de Mooij 2013-11-28 11:09:40 +01:00
parent 334e43f829
commit cbfe81d2aa
2 changed files with 15 additions and 2 deletions

View File

@ -0,0 +1,11 @@
var count = 0;
Object.defineProperty(__proto__, "__iterator__", {
get: (function() {
count++;
})
})
__proto__ = (function(){})
for (var m = 0; m < 7; ++m) {
for (var a in 6) {}
}
assertEq(count, 7);

View File

@ -618,8 +618,10 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa
if (!pobj->isNative() ||
!pobj->hasEmptyElements() ||
pobj->hasUncacheableProto() ||
obj->getOps()->enumerate ||
pobj->getClass()->enumerate != JS_EnumerateStub) {
pobj->getOps()->enumerate ||
pobj->getClass()->enumerate != JS_EnumerateStub ||
pobj->nativeContainsPure(cx->names().iteratorIntrinsic))
{
shapes.clear();
goto miss;
}