Improve stderr/stdout output for Maps
Categories
(DevTools :: Console, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: Gijs, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
+++ This bug was initially created as a clone of Bug #1823934 +++
As noted in https://phabricator.services.mozilla.com/D171473#inline-946057 it would be nice if the stdout/stderr output from console.log
and friends was more useful for Map and Set types.
To fix this we'd need to add a case here
JS::Rooted<JS::Value> v(aCx, aData[i]);
if (v.isObject()) {
Element* element = nullptr;
if (NS_SUCCEEDED(UNWRAP_OBJECT(Element, &v, element))) {
if (i != 0) {
message.AppendLiteral(" ");
}
StringifyElement(element, message);
continue;
}
}
That specifically checks for Maps. Looks like in JS land these are implemented using MapObject
, and there are various APIs to iterate over them. It would probably be best to check with the spidermonkey channel on matrix how best to do the specific iteration over the map - but even just printing Map(N)
where N
is the size of the map would be an improvement over the status quo (which logs {}
).
It looks like the devtools console's UI prints the contents of a string-based Map like this:
Map { foo → "bar", blah → "boink" }
I don't know what happens if the keys are not strings (e.g. document objects or nodes or similar), or when there are many, many keys.
It may make sense to do Set
objects first.
Updated•2 years ago
|
Description
•