Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reflected attribute tests (html/dom/reflection.js) #44355

Merged
merged 7 commits into from
Feb 6, 2024

Conversation

tbroyer
Copy link
Contributor

@tbroyer tbroyer commented Feb 1, 2024

Fixes #44315

Without a toString:null in test values that are objects
with a valueOf method, the DOM attribute would actually
be set to "[object Object]" without ever calling the
valueOf method (effectively turning those tests into
behaving exactly the same as the {"test": 6} ones).

Most existing tests were passing because the implemented
algorithms would actually compute a WRONG expected value.
The only test that doesn't compute the expected value
("double") won't actually run because all reflected IDL
attributes of type "double" have custom getters.

Fixes web-platform-tests#44315
Setting -0 to the IDL attribute will set the DOM
attribute to "0" (per ECMAScript's ToString, from the
rules for the the best representation of a number as
a floating point number), and the rules for parsing
flowting-point number values won't ever turn that "0"
into a -0 value.

This test value is never actually being used though,
as all the reflected attributes of type "double" have
custom getters.
@tbroyer
Copy link
Contributor Author

tbroyer commented Feb 1, 2024

Various improvements, each in its own commit. Let me know if you'd prefer separate PRs.

html/dom/reflection.js Outdated Show resolved Hide resolved
Specifically leading non-ASCII whitespace following leading
ASCII whitespace (should be rejected), and trailing non-ASCII
whitespace (should be ignored)
Specifically "+" and "-" to exercise all possible code
paths of failures.
@tbroyer
Copy link
Contributor Author

tbroyer commented Feb 3, 2024

I ran the tests with coverage (a copy, in a different project that reuses them), which led me to add a few tests (including exponential notation) and revealed a bug in the parseFloat function implementing the HTML spec rules for parsing floating-point number values. Once the test harness was fixed, it didn't reveal any more bugs in browsers (phew!)

PR updated with the new tests and fixed harness.

Copy link
Member

@zcorpan zcorpan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, thanks! parseFloat I think matches the spec except for infinities. (Maybe the spec should have this structure instead of goto-style.)

html/dom/reflection.js Outdated Show resolved Hide resolved
html/dom/reflection.js Show resolved Hide resolved
@zcorpan zcorpan merged commit cdafbec into web-platform-tests:master Feb 6, 2024
20 checks passed
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 13, 2024
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Feb 15, 2024
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Feb 16, 2024
…ive values on setting. r=dom-core,edgar

Tests will be in WPT (web-platform-tests/wpt#44355)

Differential Revision: https://phabricator.services.mozilla.com/D200619

UltraBlame original commit: e62f150c6ffe94380dd9cd83d6058143065dea2c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Feb 20, 2024
…ive values on setting. r=dom-core,edgar

Tests will be in WPT (web-platform-tests/wpt#44355)

Differential Revision: https://phabricator.services.mozilla.com/D200619

UltraBlame original commit: e62f150c6ffe94380dd9cd83d6058143065dea2c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in html/dom/reflection.js around valueOf
5 participants