Sorting a non-array creates propreties (spec-violation)
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Sep 2012 23:37:01 +0000 (23:37 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Sep 2012 23:37:01 +0000 (23:37 +0000)
commit82fb13cca4a3df10d46a82e3f79d8081e19f0212
tree6a3a0fd1d5f6fdf7fc6a77991ea4301bb56be5d3
parented137a6f2a17060180a50fef6e3b43173b5c9878
Sorting a non-array creates propreties (spec-violation)
https://bugs.webkit.org/show_bug.cgi?id=25477

Reviewed by Oliver Hunt.

Source/JavaScriptCore:

We're just calling get() to get properties, which is converting missing properties to
undefined. Hole values should be retained, and moved to the end of the array.

* runtime/ArrayPrototype.cpp:
(JSC::getOrHole):
    - Helper function, returns JSValue() instead of undefined for missing properties.
(JSC::arrayProtoFuncSort):
    - Implemented per 15.4.4.11, see comments above.

LayoutTests:

Added test cases.

* fast/js/array-sort-sparse-expected.txt: Added.
* fast/js/array-sort-sparse.html: Added.
* fast/js/script-tests/array-sort-sparse.js: Added.
(testSort):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129317 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/js/array-sort-sparse-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/array-sort-sparse.html [new file with mode: 0644]
LayoutTests/fast/js/script-tests/array-sort-sparse.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ArrayPrototype.cpp