Array.sort does not always call function arg

RESOLVED FIXED

Status

RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: roger.skubowius, Unassigned)

Tracking

Details

(Reporter)

Description

7 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0.1) Gecko/20100101 Firefox/10.0.1
Build ID: 20120208060813

Steps to reproduce:

Running jQuery core test suite against Rhino 1.7R3 and investigating failures that involve removing duplicate jQuery objects.



Actual results:

Duplicates HTML  elements were not detected as duplicate. 


Expected results:

Duplicates should have been detected. In reviewing the jQuery javascript code, duplicates are detected by first sorting the array of jQuery objects (wrapping HTML Element nodes). This results in jQuery eventually calling Array.sort() with a function parm to determine is one element is <, = or > than the other. In the function arg, jQuery sets a state variable that's later used to test the sorting state. This state variable was never changed and, upon investigation, it appears the culprit is NativeArray::js_sort() that, before calling our comparator, uses its own internal comparator, so our method is never called. Commenting out the internal comparator allows these test cases to all pass.

Comment 3

6 years ago
Thanks André, merged to git master:

https://github.com/mozilla/rhino/commit/a9bbc345f75ccbdeae77c8fbc0603ea8b45dce73
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.