Ignore:
Timestamp:
Mar 28, 2007, 11:20:38 PM (18 years ago)
Author:
dsmith
Message:

JavaScriptCore:

Reviewed by Darin.

http://bugs.webkit.org/show_bug.cgi?id=12963
Fix some inconsistencies in the Mozilla JS Array extras implementations
with respect to the Mozilla implementation:

  • holes in arrays should be skipped, not treated as undefined, by all such methods
  • an element with value undefined is not a hole
  • Array.prototype.forEach should return undefined
  • kjs/array_object.cpp: (ArrayInstance::getOwnPropertySlot): (ArrayProtoFunc::callAsFunction):

LayoutTests:

Reviewed by Darin.

http://bugs.webkit.org/show_bug.cgi?id=12963
Fix some inconsistencies in the Mozilla JS Array extras implementations
with respect to the Mozilla implementation:

  • holes in arrays should be skipped, not treated as undefined, by all such methods
  • an element with value undefined is not a hole
  • Array.prototype.forEach should return undefined
  • fast/js/array-every-expected.txt:
  • fast/js/array-filter-expected.txt: Added.
  • fast/js/array-filter.html: Added.
  • fast/js/array-foreach-expected.txt:
  • fast/js/array-foreach.html:
  • fast/js/array-indexof-expected.txt:
  • fast/js/array-indexof.html:
  • fast/js/array-lastIndexOf-expected.txt:
  • fast/js/array-map-expected.txt: Added.
  • fast/js/array-map.html: Added.
  • fast/js/array-some-expected.txt:
  • fast/js/array-some.html:
  • fast/js/resources/array-every.js:
  • fast/js/resources/array-lastIndexOf.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r20310 r20569  
    102102    if (index < storageLength) {
    103103      JSValue *v = storage[index];
    104       if (!v || v->isUndefined())
     104      if (!v)
    105105        return false;     
    106106      slot.setValueSlot(this, &storage[index]);
     
    121121  if (index < storageLength) {
    122122    JSValue *v = storage[index];
    123     if (!v || v->isUndefined())
     123    if (!v)
    124124      return false;
    125125    slot.setValueSlot(this, &storage[index]);
     
    790790    if (id == Filter)
    791791      resultArray = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty()));
    792     else
    793  {
     792    else {
    794793      List args;
    795794      args.append(jsNumber(length));
     
    840839      result = jsBoolean(id == Every);
    841840    else
    842       result = thisObj;
     841      result = jsUndefined();
    843842   
    844843    for (unsigned k = 0; k < length && !exec->hadException(); ++k) {
     
    887886        JSValue* e = getProperty(exec, thisObj, index);
    888887        if (!e)
    889             e = jsUndefined();
     888            continue;
    890889        if (strictEqual(exec, searchElement, e))
    891890            return jsNumber(index);
     
    913912        JSValue* e = getProperty(exec, thisObj, index);
    914913        if (!e)
    915             e = jsUndefined();
     914            continue;
    916915        if (strictEqual(exec, searchElement, e))
    917916            return jsNumber(index);
Note: See TracChangeset for help on using the changeset viewer.