chromium/third_party/blink/web_tests/fast/xsl/xslt-string-parameters.html

<html>
<head>
    <script>
        function runTest() {
            if (window.testRunner)
                testRunner.dumpAsText();
                
            var sourceDoc = (new DOMParser).parseFromString('<test/>', 'text/xml');
            var sheetDoc = (new DOMParser).parseFromString('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' +
                                                           '<xsl:output method="text"/><xsl:param name="testParam"/>' + 
                                                           '<xsl:template match="/test"><xsl:value-of select="$testParam"/></xsl:template></xsl:stylesheet>', 'text/xml');
                                                           
            var processor = new XSLTProcessor();
            processor.importStylesheet(sheetDoc);

            processor.setParameter(null, 'testParam', 'text')
            var result = processor.transformToFragment(sourceDoc, document);
            if (result.textContent != 'text')
                return;

            processor.setParameter(null, 'testParam', 'text with spaces')
            var result = processor.transformToFragment(sourceDoc, document);
            if (result.textContent != 'text with spaces')
                return;
 
            processor.setParameter(null, 'testParam', 'Shakespeare\'s "Twelfth Night"')
            var result = processor.transformToFragment(sourceDoc, document);
            if (result.textContent != 'Shakespeare\'s "Twelfth Night"')
                return;
            
            document.getElementById('result').innerHTML = 'SUCCESS';
        }
    </script>
</head>
<body onload="runTest()">
    <p>This tests that passing string parameters to the XSLTProcessor works as expected. If this test is successful, the text "SUCCESS" will be shown below.</p>
    <div id="result">FAILURE</div>
</body>
</html>