Open hemanth opened 6 months ago
This is a problematic feature: taking a screenshot of an element is something that should not require user consent: after all, the API would be triggered by its own page
On the other hand, I believe being able to capture tainted canvas
es and crossorigin iframes should not be allowed even by user consent: the user is likely not aware of what parts of the page are tainted or iframed: their consent is mostly meaningless
What problem are you trying to solve?
Proposal for
window.screenshot
APIUse Cases
The primary use case for a
window.screenshot
API is to enable web applications to capture and manipulate screenshots directly within the browser. Here are specific scenarios where such an API would be beneficial:Web-based Design Tools
Bug Reporting
Educational Tools
Requirements
To meet these use cases, the
window.screenshot
API must provide the following capabilities:Comparison with Existing APIs
Currently, there is no direct equivalent to a
window.screenshot
API in the existing web platform. While the Canvas API can be used to capture and manipulate images, it requires complex and verbose code. The proposedwindow.screenshot
API would simplify this process significantly, making it more accessible to developers.Conclusion
The
window.screenshot
API addresses a clear need for capturing and manipulating screenshots within web applications. By focusing on essential requirements and learning from past experiences with storage APIs, we can introduce a robust and secure API that enhances the web platform's capabilities. This proposal aims to gather feedback and iterate towards a solution that meets developer needs while ensuring user security and performance efficiency.What solutions exist today?
How would you solve it?
Implementation Proposal
API Design
window.screenshot.capture(options)
options
can include:target
: Element or full viewportformat
: Desired image formatquality
: Quality setting for lossy formats like JPEGwindow.screenshot.export(options)
options
can include:format
: Desired export formatfilename
: Suggested filename for downloadSecurity Considerations
Performance Considerations
Anything else?
Maybe we can have a single API to capture screenshot as well as record the screen.