mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.18k stars 851 forks source link

make sure, equivalentValues(Object) is used if available #1721

Closed rbri closed 6 days ago

rbri commented 2 weeks ago

The HTMLAllCollection implements some strange behavior - https://developer.mozilla.org/en-US/docs/Web/API/HTMLAllCollection#special_type_conversion_behavior. Of course we have to support this in HtmlUnit - see https://github.com/HtmlUnit/htmlunit/issues/896

Luckily Rhino supports this kind of customized equals behavior by overriding the ScriptableObject#equivalentValues() method.

But there are two bugs

This PR fixes both cases and also adds test cases.

rbri commented 1 week ago

any feedback for this? I need it for HtmlUnit and i like to know if there is a chance to have it in rhino or if i have to put it in my fork.

I did already some test and i did not see any negative performance impact.

gbrail commented 1 week ago

This makes sense to me -- I've been travelling a bit and haven't had a chance to test things myself yet. I'm also optimistic that a few of the optimizations like the ones in the bytecode here that you had to undo might be less necessary as we can keep working on dynamic linking -- I'll have some PRs for that coming up in the future. For now I'll check this out in detail later in the week.

gbrail commented 6 days ago

Looks good to me -- thanks!