⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 92093 in webkit


Ignore:
Timestamp:
Jul 31, 2011, 6:50:16 PM (15 years ago)
Author:
barraclough@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=64679
Fix bugs in Array.prototype this handling.

Unreviewed - rolling out r91290.

Source/JavaScriptCore:

Looks like the wild wild web isn't ready for this yet.

This change broke http://slides.html5rocks.com/#landing-slide.
Interestingly, this might only be due to our lack of bind support -
it looks like this site is calling Array.prototype.slice as a part
of its bind implementation.

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncJoin):
(JSC::arrayProtoFuncConcat):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncReverse):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSort):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):
(JSC::arrayProtoFuncFilter):
(JSC::arrayProtoFuncMap):
(JSC::arrayProtoFuncEvery):
(JSC::arrayProtoFuncForEach):
(JSC::arrayProtoFuncSome):
(JSC::arrayProtoFuncReduce):
(JSC::arrayProtoFuncReduceRight):
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):

LayoutTests:

Checking in failing results - we can't fix this bug just yet
for web compatibility reasons.

  • fast/js/array-prototype-properties-expected.txt:
  • ietestcenter/Javascript/15.4.4.14-5-28-expected.txt:
  • ietestcenter/Javascript/15.4.4.15-5-28-expected.txt:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r92091 r92093  
     12011-07-31  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=64679
     4        Fix bugs in Array.prototype this handling.
     5
     6        Unreviewed - rolling out r91290.
     7
     8        Checking in failing results - we can't fix this bug just yet
     9        for web compatibility reasons.
     10
     11        * fast/js/array-prototype-properties-expected.txt:
     12        * ietestcenter/Javascript/15.4.4.14-5-28-expected.txt:
     13        * ietestcenter/Javascript/15.4.4.15-5-28-expected.txt:
     14
    1152011-07-31  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/LayoutTests/fast/js/array-prototype-properties-expected.txt

    r91290 r92093  
    66PASS Array.prototype.toString.call(undefined) threw exception TypeError: Type error.
    77PASS Array.prototype.toLocaleString.call(undefined) threw exception TypeError: Type error.
    8 PASS Array.prototype.concat.call(undefined, []) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.concat.call(undefined, [])').
    9 PASS Array.prototype.join.call(undefined, []) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.join.call(undefined, [])').
    10 PASS Array.prototype.pop.call(undefined) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.pop.call(undefined)').
    11 PASS Array.prototype.push.call(undefined, {}) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.push.call(undefined, {})').
    12 PASS Array.prototype.reverse.call(undefined) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.reverse.call(undefined)').
    13 PASS Array.prototype.shift.call(undefined) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.shift.call(undefined)').
    14 PASS Array.prototype.slice.call(undefined, 0, 1) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.slice.call(undefined, 0, 1)').
    15 PASS Array.prototype.sort.call(undefined) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.sort.call(undefined)').
    16 PASS Array.prototype.splice.call(undefined, 0, 1) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.splice.call(undefined, 0, 1)').
    17 PASS Array.prototype.unshift.call(undefined, {}) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.unshift.call(undefined, {})').
    18 PASS Array.prototype.every.call(undefined, toString) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.every.call(undefined, toString)').
    19 PASS Array.prototype.forEach.call(undefined, toString) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.forEach.call(undefined, toString)').
    20 PASS Array.prototype.some.call(undefined, toString) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.some.call(undefined, toString)').
    21 PASS Array.prototype.indexOf.call(undefined, 0) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.indexOf.call(undefined, 0)').
     8FAIL Array.prototype.concat.call(undefined, []) should throw an exception. Was [object DOMWindow].
     9FAIL Array.prototype.join.call(undefined, []) should throw an exception. Was .
     10FAIL Array.prototype.pop.call(undefined) should throw an exception. Was undefined.
     11FAIL Array.prototype.push.call(undefined, {}) should throw an exception. Was 1.
     12FAIL Array.prototype.reverse.call(undefined) should throw an exception. Was [object DOMWindow].
     13FAIL Array.prototype.shift.call(undefined) should throw an exception. Was [object Object].
     14FAIL Array.prototype.slice.call(undefined, 0, 1) should throw an exception. Was .
     15FAIL Array.prototype.sort.call(undefined) should throw an exception. Was [object DOMWindow].
     16FAIL Array.prototype.splice.call(undefined, 0, 1) should throw an exception. Was .
     17FAIL Array.prototype.unshift.call(undefined, {}) should throw an exception. Was 1.
     18FAIL Array.prototype.every.call(undefined, toString) should throw an exception. Was true.
     19FAIL Array.prototype.forEach.call(undefined, toString) should throw an exception. Was undefined.
     20FAIL Array.prototype.some.call(undefined, toString) should throw an exception. Was true.
     21FAIL Array.prototype.indexOf.call(undefined, 0) should throw an exception. Was -1.
    2222PASS Array.prototype.indlastIndexOfexOf.call(undefined, 0) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.indlastIndexOfexOf.call').
    23 PASS Array.prototype.filter.call(undefined, toString) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.filter.call(undefined, toString)').
    24 PASS Array.prototype.reduce.call(undefined, toString) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.reduce.call(undefined, toString)').
    25 PASS Array.prototype.reduceRight.call(undefined, toString) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.reduceRight.call(undefined, toString)').
    26 PASS Array.prototype.map.call(undefined, toString) threw exception TypeError: 'undefined' is not an object (evaluating 'Array.prototype.map.call(undefined, toString)').
     23FAIL Array.prototype.filter.call(undefined, toString) should throw an exception. Was [object Object].
     24FAIL Array.prototype.reduce.call(undefined, toString) should throw an exception. Was [object Object].
     25FAIL Array.prototype.reduceRight.call(undefined, toString) should throw an exception. Was [object Object].
     26FAIL Array.prototype.map.call(undefined, toString) should throw an exception. Was [object DOMWindow].
    2727PASS successfullyParsed is true
    2828
  • trunk/LayoutTests/ietestcenter/Javascript/15.4.4.14-5-28-expected.txt

    r91290 r92093  
    55
    66PASS ES5Harness.preconditionPassed is true
    7 PASS ES5Harness.testPassed is true
     7FAIL ES5Harness.testPassed should be true. Was false.
    88PASS successfullyParsed is true
    99
  • trunk/LayoutTests/ietestcenter/Javascript/15.4.4.15-5-28-expected.txt

    r91290 r92093  
    55
    66PASS ES5Harness.preconditionPassed is true
    7 PASS ES5Harness.testPassed is true
     7FAIL ES5Harness.testPassed should be true. Was false.
    88PASS successfullyParsed is true
    99
  • trunk/Source/JavaScriptCore/ChangeLog

    r92092 r92093  
     12011-07-31  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=64679
     4        Fix bugs in Array.prototype this handling.
     5
     6        Unreviewed - rolling out r91290.
     7
     8        Looks like the wild wild web isn't ready for this yet.
     9
     10        This change broke http://slides.html5rocks.com/#landing-slide.
     11        Interestingly, this might only be due to our lack of bind support -
     12        it looks like this site is calling  Array.prototype.slice as a part
     13        of its bind implementation.
     14
     15        * runtime/ArrayPrototype.cpp:
     16        (JSC::arrayProtoFuncJoin):
     17        (JSC::arrayProtoFuncConcat):
     18        (JSC::arrayProtoFuncPop):
     19        (JSC::arrayProtoFuncPush):
     20        (JSC::arrayProtoFuncReverse):
     21        (JSC::arrayProtoFuncShift):
     22        (JSC::arrayProtoFuncSlice):
     23        (JSC::arrayProtoFuncSort):
     24        (JSC::arrayProtoFuncSplice):
     25        (JSC::arrayProtoFuncUnShift):
     26        (JSC::arrayProtoFuncFilter):
     27        (JSC::arrayProtoFuncMap):
     28        (JSC::arrayProtoFuncEvery):
     29        (JSC::arrayProtoFuncForEach):
     30        (JSC::arrayProtoFuncSome):
     31        (JSC::arrayProtoFuncReduce):
     32        (JSC::arrayProtoFuncReduceRight):
     33        (JSC::arrayProtoFuncIndexOf):
     34        (JSC::arrayProtoFuncLastIndexOf):
     35
    1362011-07-31  Filip Pizlo  <fpizlo@apple.com>
    237
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r91824 r92093  
    268268EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
    269269{
    270     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     270    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    271271    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    272272    if (exec->hadException())
     
    338338    JSArray* arr = constructEmptyArray(exec);
    339339    unsigned n = 0;
    340     JSValue curArg = thisValue.toObject(exec);
    341     if (exec->hadException())
    342         return JSValue::encode(jsUndefined());
     340    JSValue curArg = thisValue.toThisObject(exec);
    343341    size_t i = 0;
    344342    size_t argCount = exec->argumentCount();
     
    372370        return JSValue::encode(asArray(thisValue)->pop());
    373371
    374     JSObject* thisObj = thisValue.toObject(exec);
     372    JSObject* thisObj = thisValue.toThisObject(exec);
    375373    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    376374    if (exec->hadException())
     
    399397    }
    400398
    401     JSObject* thisObj = thisValue.toObject(exec);
     399    JSObject* thisObj = thisValue.toThisObject(exec);
    402400    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    403401    if (exec->hadException())
     
    421419EncodedJSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec)
    422420{
    423     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     421    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    424422    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    425423    if (exec->hadException())
     
    447445EncodedJSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec)
    448446{
    449     JSObject* thisObj = exec->hostThisValue().toObject(exec);
    450     unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    451     if (exec->hadException())
    452         return JSValue::encode(jsUndefined());
    453 
     447    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    454448    JSValue result;
     449
     450    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
     451    if (exec->hadException())
     452        return JSValue::encode(jsUndefined());
     453
    455454    if (length == 0) {
    456455        putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(length));
     
    477476{
    478477    // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
    479     JSObject* thisObj = exec->hostThisValue().toObject(exec);
    480     unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    481     if (exec->hadException())
    482         return JSValue::encode(jsUndefined());
     478    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    483479
    484480    // We return a new array
    485481    JSArray* resObj = constructEmptyArray(exec);
    486482    JSValue result = resObj;
     483
     484    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
     485    if (exec->hadException())
     486        return JSValue::encode(jsUndefined());
    487487
    488488    unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 0, length);
     
    500500EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec)
    501501{
    502     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     502    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    503503    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    504504    if (!length || exec->hadException())
     
    562562    // 15.4.4.12
    563563
    564     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     564    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    565565    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    566566    if (exec->hadException())
     
    630630    // 15.4.4.13
    631631
    632     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     632    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    633633    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    634634    if (exec->hadException())
     
    657657EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec)
    658658{
    659     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     659    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    660660    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    661661    if (exec->hadException())
     
    716716EncodedJSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec)
    717717{
    718     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     718    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    719719    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    720720    if (exec->hadException())
     
    778778EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec)
    779779{
    780     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     780    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    781781    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    782782    if (exec->hadException())
     
    836836EncodedJSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec)
    837837{
    838     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     838    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    839839    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    840840    if (exec->hadException())
     
    886886EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec)
    887887{
    888     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     888    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    889889    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    890890    if (exec->hadException())
     
    943943EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec)
    944944{
    945     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     945    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    946946    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    947947    if (exec->hadException())
     
    10181018EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec)
    10191019{
    1020     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     1020    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    10211021    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    10221022    if (exec->hadException())
     
    10931093{
    10941094    // 15.4.4.14
    1095     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     1095    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    10961096    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    10971097    if (exec->hadException())
     
    11141114{
    11151115    // 15.4.4.15
    1116     JSObject* thisObj = exec->hostThisValue().toObject(exec);
     1116    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
    11171117    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    11181118    if (!length)
Note: See TracChangeset for help on using the changeset viewer.