Cope with localStorage reifying __iterator__ with null value, and the like (573875, r=gal).

This commit is contained in:
Brendan Eich 2011-01-14 08:03:45 -08:00
parent b5d79c6a75
commit 6e8832e1a8
3 changed files with 25 additions and 1 deletions

View File

@ -404,8 +404,10 @@ GetCustomIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp)
return false;
/* If there is no custom __iterator__ method, we are done here. */
if (vp->isUndefined())
if (!vp->isObject()) {
vp->setUndefined();
return true;
}
/* Otherwise call it and return that object. */
LeaveTrace(cx);

View File

@ -29,6 +29,7 @@ script regress-567152.js
script regress-569306.js
script regress-569464.js
script regress-571014.js
script regress-573875.js
script regress-577648-1.js
script regress-577648-2.js
script regress-583429.js

View File

@ -0,0 +1,21 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
var o = {__iterator__:null, a:1, b:2, c:3}
var expect = '__iterator__,a,b,c,';
var actual = '';
try {
for (var i in o)
actual += i + ',';
} catch (e) {
actual = '' + e;
if (/invalid __iterator__ value/.test(actual) ||
/null is not a function/.test(actual)) {
expect = actual;
}
}
reportCompare(expect, actual, "ok");