Bug 237208

Summary: Web Inspector: `console.screenshot` like API that returns image object
Product: WebKit Reporter: Christopher Atlan <catlan>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: inspector-bugzilla-changes, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: All   
OS: All   

Description Christopher Atlan 2022-02-25 06:37:21 PST
We would be interested in a API like `console.screenshot` that would return an image object instead of displaying the image inaccessible on the console.

Our Safari Web Extension allows users to send HTML or CSS to Kaleidoscope, for a visual text comparison. With the current API we are able to send the HTML or computed CSS of an element via context menu action to Kaleidoscope. We also provide a javascript function, so developers can send any textual content to the app over the Web Inspector Console Command Line: 

> ksdiff($0.innerHTML)

It would be great if we could also provide image comparison in a similar manner like:

> ksdiff(inspector.screenshot($0))
Comment 1 Radar WebKit Bug Importer 2022-02-25 09:55:44 PST
<rdar://problem/89479439>
Comment 2 Sam Sneddon [:gsnedders] 2022-05-16 08:50:19 PDT
See also https://github.com/whatwg/console/issues/160 with regards to adding screenshot to the Console spec; we'd want to propose/discuss something like this there as well. One option would be to just make it return something like a blob URL and then auto-magically show that in the Console.