Skip to content
  • commit-queue@webkit.org's avatar
    reduce and reduceRight bind callback's this to null rather than undefined · 6517cf93
    commit-queue@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=62264
    
    Patch by Mark Hahnenberg <mhahnenberg@apple.com> on 2011-07-26
    Reviewed by Oliver Hunt.
    
    Source/JavaScriptCore:
    
    Fixed Array.prototype.reduce and Array.prototype.reduceRight so that they behave correctly
    when calling the callback function without an argument for this, which means it should
    be undefined according to ES 15.4.4.21 and 15.4.4.22.
    
    * runtime/ArrayPrototype.cpp:
    (JSC::arrayProtoFuncReduce):
    (JSC::arrayProtoFuncReduceRight):
    
    LayoutTests:
    
    Added additional tests to test Array.prototype.reduce and Array.prototype.reduceRight
    when calling the callback function without an argument for this, which means it should
    be undefined according to ES 15.4.4.21 and 15.4.4.22.
    
    * fast/js/array-reduce-expected.txt:
    * fast/js/array-reduceRight-expected.txt:
    * fast/js/script-tests/array-reduce.js:
    * fast/js/script-tests/array-reduceRight.js:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@91824 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    6517cf93