chromium/third_party/blink/web_tests/fast/dom/Range/create-contextual-fragment-namespaces3.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" xml:lang="en" lang="en">
<body onload="onPageLoad()">
<p>Test of Range.createContextualFragment() with in-scope namespace prefixes, where the XML fragment introduces additional namespace prefixes. If the test succeeds you will see the word "PASS" below.</p>
<p id="result">Running test...</p>
<svg:svg xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <svg:defs id="defs"/>
</svg:svg>
<script type="text/javascript">//<![CDATA[
function onPageLoad() {
    if (window.testRunner)
        testRunner.dumpAsText();

    var result = document.getElementById("result");

    var defs = document.getElementById("defs"),
        range = document.createRange(),
        docFragment;

    range.setStart(defs, 0);
    docFragment = range.createContextualFragment("<svg:linearGradient id='gradient1'/>" +
                                                 "<a:aTest id='aTest' xmlns:a='urn:x-test:a' xmlns:b='urn:x-test:b' a:aAttr='aValue' xlink:href='#gradient1'>" +
                                                 "  <b:bTest id='bTest' a:aAttr='aValue2' b:bAttr='bValue'>" +
                                                 "    <xlink:testRedefiningXlink id='testRedefiningXlink' xlink:xlinkAttr='xlinkValue' xmlns:xlink='urn:x-test:xlink'/>" +
                                                 "    <svg:linearGradient id='gradient2' xlink:href='#gradient1'/>" +
                                                 "  </b:bTest>" +
                                                 "</a:aTest>");
    defs.appendChild(docFragment);

    var gradient1 = document.getElementById("gradient1");
    if (gradient1.namespaceURI != "http://www.w3.org/2000/svg") {
        result.textContent += ' - #gradient1 has the wrong namespaceURI';
        return;
    }

    var aTest = document.getElementById("aTest");
    if (aTest.namespaceURI != "urn:x-test:a") {
        result.textContent += ' - #aTest has the wrong namespaceURI';
        return;
    }
    if (aTest.getAttributeNS("urn:x-test:a", "aAttr") != "aValue") {
        result.textContent += ' - wrong value for the a:aAttr attribute of #aTest';
        return;
    }
    if (aTest.getAttributeNS("http://www.w3.org/1999/xlink", "href") != "#gradient1") {
        result.textContent += ' - wrong value for the xlink:href attribute of #aTest';
        return;
    }

    var bTest = document.getElementById("bTest");
    if (bTest.namespaceURI != "urn:x-test:b") {
        result.textContent += ' - #bTest has the wrong namespaceURI';
        return;
    }
    if (bTest.getAttributeNS("urn:x-test:a", "aAttr") != "aValue2") {
        result.textContent += ' - wrong value for the a:aAttr attribute of #bTest';
        return;
    }
    if (bTest.getAttributeNS("urn:x-test:b", "bAttr") != "bValue") {
        result.textContent += ' - wrong value for the b:bAttr attribute of #bTest';
        return;
    }

    var testRedefiningXlink = document.getElementById("testRedefiningXlink");
    if (testRedefiningXlink.namespaceURI != "urn:x-test:xlink") {
        result.textContent += ' - #testRedefiningXlink has the wrong namespaceURI';
        return;
    }
    if (testRedefiningXlink.getAttributeNS("urn:x-test:xlink", "xlinkAttr") != "xlinkValue") {
        result.textContent += ' - wrong value for the xlink:xlinkAttr attribute of #testRedefiningXlink';
        return;
    }

    var gradient2 = document.getElementById("gradient2");
    if (gradient2.namespaceURI != "http://www.w3.org/2000/svg") {
        result.textContent += ' - #gradient2 has the wrong namespaceURI';
        return;
    }
    if (gradient2.getAttributeNS("http://www.w3.org/1999/xlink", "href") != "#gradient1") {
        result.textContent += ' - wrong value for the xlink:href attribute of #gradient2';
        return;
    }

    if (result.textContent === "Running test...")
        result.textContent = "PASS";
}
//]]>
</script>
</body>
</html>