Skip to content

console.debug() does not support sprintf-style substitutions #43827

@webbedspace

Description

@webbedspace

Describe the bug:
See example. Spotted on the Wayback Machine in https://web-static.archive.org/_static/js/bundle-playback.js . The spec indicates this is implementation-defined, but basically everything seems to converge on supporting at least %s, %d %i and %f.

To Reproduce:

<script>
  console.debug("String %s Int %d  Int %i Float %f", "string", 32, 46, Math.PI);
  console.debug("String %s Int %d  Int %i Float %f", 89, "foo", Math.PI, "bar");
</script>

Firefox:

String string Int 32  Int 46 Float 3.141593
String 89 Int 0  Int 3 Float NaN

Chrome:

String string Int 32  Int 46 Float 3.141592653589793
String 89 Int NaN  Int 3 Float NaN

NodeJS (for comparison):

Welcome to Node.js v24.13.0.
Type ".help" for more information.
>   console.debug("String %s Int %d  Int %i Float %f", "string", 32, 46, Math.PI);
String string Int 32  Int 46 Float 3.141592653589793
undefined
>   console.debug("String %s Int %d  Int %i Float %f", 89, "foo", Math.PI, "bar");
String 89 Int NaN  Int 3 Float NaN
undefined
>

Servo:

String %s Int %d  Int %i Float %f string 32 46 3.141592653589793
String %s Int %d  Int %i Float %f 89 foo 3.141592653589793 bar

Platform:
Windows 10, Servo latest

Metadata

Metadata

Assignees

Labels

A-content/domInteracting with the DOM from web contentC-assignedThere is someone working on resolving the issueC-has-manual-testcaseE-less-complexStraightforward. Recommended for a new contributor.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions