Skip to content

Commit

Permalink
Fix reflection tests wrt valueOf
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tbroyer committed Feb 1, 2024
1 parent 3d0bc46 commit 558a169
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions html/dom/reflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ ReflectionTests.typeMap = {
undefined, 1.5, "5%", "+100", ".5", true, false, {"test": 6}, NaN, +Infinity,
-Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
{valueOf:function() {return 3;}, toString: null}],
"domExpected": function(val) {
var parsed = ReflectionTests.parseInt(String(val));
if (parsed === false || parsed > maxInt || parsed < minInt) {
Expand Down Expand Up @@ -324,7 +324,7 @@ ReflectionTests.typeMap = {
undefined, 1.5, "5%", "+100", ".5", true, false, {"test": 6}, NaN, +Infinity,
-Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
{valueOf:function() {return 3;}, toString: null}],
"domExpected": function(val) {
var parsed = ReflectionTests.parseNonneg(String(val));
if (parsed === false || parsed > maxInt || parsed < minInt) {
Expand Down Expand Up @@ -360,7 +360,7 @@ ReflectionTests.typeMap = {
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
{valueOf:function() {return 3;}, toString: null}],
"domExpected": function(val) {
var parsed = ReflectionTests.parseNonneg(String(val));
// Note maxInt, not maxUnsigned.
Expand Down Expand Up @@ -402,7 +402,7 @@ ReflectionTests.typeMap = {
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
{valueOf:function() {return 3;}, toString: null}],
"domExpected": function(val) {
var parsed = ReflectionTests.parseNonneg(String(val));
// Note maxInt, not maxUnsigned.
Expand Down Expand Up @@ -442,7 +442,7 @@ ReflectionTests.typeMap = {
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
{valueOf:function() {return 3;}, toString: null}],
"domExpected": function(val) {
var parsed = ReflectionTests.parseNonneg(String(val));
// Note maxInt, not maxUnsigned.
Expand Down Expand Up @@ -481,7 +481,7 @@ ReflectionTests.typeMap = {
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
{valueOf:function() {return 3;}, toString: null}],
"idlTests": [0, 1, 257, maxInt, "-0", maxInt + 1, maxUnsigned],
"idlDomExpected": [0, 1, 257, maxInt, 0, null, null],
},
Expand Down Expand Up @@ -522,7 +522,7 @@ ReflectionTests.typeMap = {
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
{valueOf:function() {return 3;}, toString: null}],
"domExpected": [minInt - 1, minInt, -36, -1, 0, 1, maxInt,
maxInt + 1, maxUnsigned, maxUnsigned + 1, null,
// Leading whitespace tests
Expand Down

0 comments on commit 558a169

Please sign in to comment.