← Back to release summary

SVG foreignObject does not taint the canvas for blob URLs

Category
Graphics
Type
Chromium catches up
Status
In development (Chrome In development)
Intent stage
None

WPT details: The CL that enables the feature will include comprehensive canvas tests. Existing tests cover the various privacy concerns, such as ensuring the SVG content is indeed non-interactive.

Summary

The ability to use an <img> element with an SVG source in a HTML canvas drawImage operation has long been supported by all browsers, but the canvas tainting behavior varies across platforms. All browsers taint the canvas when the SVG source includes a foreignObject tag and is referenced via a HTTP URI scheme. When the same SVG is referenced through a data URI all browsers agree not to taint the canvas. However, when a blob URI is used both Chromium (before this change) and WebKit taint the canvas, but Gecko does not. When this feature is shipped Chromium's behavior will match that of Gecko, allowing a wider range of SVG content to be used in canvas drawImage calls without tainting.

Motivation

The feature is currently the only way to include HTML content in a canvas (though the content is non-interactive). Developers have long requested support for Blob-URI based SVG foreignObject content that does not taint the canvas, and we will finally catch up to Gecko in providing this functionality. In practice, this is a performance issue because Blob-URI are much faster to process than Data-URIs that we currently require for this use case.

Standards & signals

Ecosystem

View on chromestatus.com