Bug 264916 - Web Inspector: Support Custom Formatters
Summary: Web Inspector: Support Custom Formatters
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-11-15 18:13 PST by Daniel Compton
Modified: 2023-11-20 07:17 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Compton 2023-11-15 18:13:51 PST
Custom Formatters is a protocol to render objects logged to the console (and shown in the debugger) in a more readable format.

It was developed for Chrome, but is now supported in Firefox.

Custom Formatters are particularly important for ClojureScript developers, because ClojureScript's native data structures (maps, sets, vectors, keywords, etc.) do not print readably by default. https://github.com/binaryage/cljs-devtools provides custom formatters to print ClojureScript data structures in a much more readable fashion.

We (Clojurists Together) recently funded work to bring Custom Formatters to Firefox. We're interested in funding work to bring it to WebKit as well, but wanted to gauge interest in this work being done before we contract someone to work on it.

How does the WebKit team feel about support for Custom Formatters being added to WebKit?

Custom Formatters is not on a web standards track, as far as I can tell, but it is extremely helpful for developers. It is also disabled by default, and developers need to enable it to use it.

Spec: https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#heading=h.xuvxhsd2bp05
https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html#
https://fxdx.dev/firefox-devtools-custom-object-formatters/
https://www.clojuriststogether.org/news/funding-development-on-custom-formatters-for-firefox/
https://www.clojuriststogether.org/news/firefox-116.0-release/
Comment 1 Daniel Compton 2023-11-15 19:04:20 PST
I had a quick chat with dcrousso on WebKit Slack about this (https://webkit.slack.com/archives/CU65DUH7F/p1700101038513779)

dcrousso: as far as this particular feature, i haven't looked at custom formatters in a while, but generally speaking we've avoided things that expose whether Web Inspector is open and i think this may violate that
so that's probably be the first thing that needs to be addressed

dcrousso: if we can figure out a solution to that then anyone is welcome to create a PR and ask for reviews

Daniel Compton: Would custom formatters being disabled by default be a mitigating factor?

dcrousso: possibly? I'm very hesitant to expose anything that lets the page detect Web Inspector so directly (even if disabled by default).
The main concern being the page doing some sort of denial-of-service if Web Inspector is opened and i'm not sure if developers would think/know that custom formatters is a detection mechanism in order to disable it.
If it's something that has to be enabled each session i'm less concerned about a developer forgetting about it being enabled, but i also feel like the experience of that might suck, but if you're ok with that then i think it's perhaps worth exploring/prototyping 🙂

Daniel Compton: Yeah, enabling it every session wouldn't be much fun. I'll have a look at the spec and see what the options are.
Comment 2 Radar WebKit Bug Importer 2023-11-20 07:17:49 PST
<rdar://problem/118652555>