Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!doctype html>
<meta charset=utf-8>
<title>CSP: img-src is enforced on external SVG masks from a memory-cached shared stylesheet</title>
<link rel="author" title="Dileep Maurya" href="mailto:dileepmaurya@microsoft.com">
<link rel="match" href="shared-stylesheet-mask-cache-bypass-ref.html">
<!--
Regression test for crbug.com/504107363 (external SVG mask variant).
This top-level document has no CSP and applies an external SVG mask
(mask-image: url(x.svg#m)) through a shared (memory-cached) stylesheet, which
caches the resolved image and its SVGResource on the stylesheet's shared
CSSImageValue. A same-origin iframe served with Content-Security-Policy:
img-src 'none' then links the same stylesheet. It must NOT reuse the cached
mask; enforcing its own CSP, its mask fetch fails, the element is masked out,
and the box must paint blank, matching the reference.
The mask covers the full box, so if the cached mask were wrongly reused the
green background would show through (a visible, non-blank box) and the test
would fail.
-->
<link rel="stylesheet" href="support/shared-stylesheet-mask-cache-bypass.css">
<style>
html, body { margin: 0; }
/* Prime the shared CSSImageValue off-screen so only the iframe is compared. */
#primer { position: absolute; top: -9999px; left: -9999px; }
iframe { border: none; width: 100px; height: 100px; display: block; }
</style>
<script>document.documentElement.classList.add('reftest-wait');</script>
<div class="bypass-mask" id="primer"></div>
<script>
'use strict';
// Ensure the shared mask resource is fully loaded and the primer element's
// CSSImageValue has cached it before the strict iframe resolves style.
const primer = new Image();
primer.onload = () => {
requestAnimationFrame(() => requestAnimationFrame(() => {
const iframe = document.createElement('iframe');
iframe.src = 'support/shared-stylesheet-mask-cache-bypass-strict.html';
window.addEventListener('message', e => {
if (e.source === iframe.contentWindow && e.data === 'ready') {
requestAnimationFrame(() => requestAnimationFrame(() => {
document.documentElement.classList.remove('reftest-wait');
}));
}
});
document.body.appendChild(iframe);
}));
};
primer.src = 'support/shared-stylesheet-mask-cache-bypass.svg';
</script>