1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xslt/tests/mochitest/test_exslt_regex.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +Test EXSLT Regular Expression Extension 1.8 +http://www.exslt.org/regexp/index.html 1.9 +--> 1.10 +<head> 1.11 + <title>Test for EXSLT Regular Expression Extensions</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"></div> 1.18 +<pre id="test"> 1.19 +<script type="application/javascript"> 1.20 + var tests = [ 1.21 + { descr: "Testing regexp:test", 1.22 + expr: "regexp:test('XSLT is great', 'XSLT', '')", 1.23 + expResult: "true" }, 1.24 + 1.25 + { descr: "Testing regexp:match", 1.26 + expr: "regexp:match('XSLT is great', 'XSL.', '')[1]", 1.27 + expResult: "XSLT" }, 1.28 + 1.29 + { descr: "Testing regexp:replace", 1.30 + expr: "regexp:replace('Food is great', 'Fo.d', '', 'XSLT')", 1.31 + expResult: "XSLT is great" } 1.32 + ]; 1.33 + 1.34 + for (test of tests) { 1.35 + var style = 1.36 + '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' + 1.37 + 'xmlns:regexp="http://exslt.org/regular-expressions" '+ 1.38 + 'version="1.0">' + 1.39 + '<xsl:output method="html"/>' + 1.40 + '<xsl:template match="/">' + 1.41 + '<xsl:value-of select="'+test.expr+'" /> ' + 1.42 + '</xsl:template>' + 1.43 + '</xsl:stylesheet>'; 1.44 + var styleDoc = new DOMParser().parseFromString (style, "text/xml"); 1.45 + 1.46 + var data = '<root/>'; 1.47 + var originalDoc = new DOMParser().parseFromString(data, "text/xml"); 1.48 + 1.49 + var processor = new XSLTProcessor(); 1.50 + processor.importStylesheet(styleDoc); 1.51 + 1.52 + var fragment = processor.transformToFragment(originalDoc, document); 1.53 + var content = document.getElementById("content"); 1.54 + content.appendChild(fragment); 1.55 + is(content.innerHTML, test.expResult, test.descr); 1.56 + 1.57 + content.innerHTML = ''; 1.58 + } 1.59 + 1.60 +</script> 1.61 +</pre> 1.62 +</body> 1.63 +</html>