chromium/third_party/blink/web_tests/paint/invalidation/svg/pending-resource-after-removal.xhtml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../resources/text-based-repaint.js"></script>
<title>The rectangle should be green.</title></head>
<script>
window.testIsAsync = true;

var W = 200;
var H = 200;
var SVGNS = "http://www.w3.org/2000/svg";
var currentColor = 0;
var colors = ["red", "green"];

function resetFill(parentNode) {
    var rootPattern = document.createElementNS(SVGNS, "pattern");
    rootPattern.setAttribute("id", "pat");
    rootPattern.setAttribute("patternUnits", "userSpaceOnUse");
    rootPattern.setAttribute("width", W);
    rootPattern.setAttribute("height", H);
    parentNode.appendChild(rootPattern);

    var rect = document.createElementNS(SVGNS, "rect");
    rect.setAttribute("width", W);
    rect.setAttribute("height", H);
    rect.setAttribute("fill", colors[currentColor++]);
    rootPattern.appendChild(rect);
    
    return rect;
}

function updateFill() {
    var el = document.getElementById("shape");
    var defs = document.getElementById("defs");

    while (defs.firstChild)
        defs.removeChild(defs.firstChild);

    resetFill(defs);

    el.setAttribute("fill", "url(#pat)");

    if(currentColor == 2)
        finishRepaintTest();
}

function repaintTest() {
    updateFill();
    // FIXME: we need a better way of waiting for layout/repainting to happen
    setTimeout("updateFill()", 1);
}
</script>
<body onload="runRepaintAndPixelTest()">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%">
<defs id="defs"></defs>
<rect id="shape" width="200" height="200"></rect>
</svg>
</body>
</html>