test_sorting_invalid_lang.html (2212B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1734679 5 --> 6 <head> 7 <title>Test sorting with invalid lang</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1734679">Mozilla Bug 1734679</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script class="testbody" type="text/javascript"> 19 20 /** 21 * Test for Bug 1734679. Invalid language tags should not throw an error, and should 22 * fall back to the app's locale. 23 */ 24 25 var xmldoc, xsltdoc; 26 27 xmldoc = new DOMParser().parseFromString('<?xml version="1.0" encoding="UTF-8"?>\n\ 28 <?xml-stylesheet type="text/xsl" href="sort-lang.xsl" ?>\n\ 29 <list>\n\ 30 <entry>\n\ 31 <technology>CSS</technology>\n\ 32 <term>text-direction</term>\n\ 33 </entry>\n\ 34 <entry>\n\ 35 <technology>JavaScript</technology>\n\ 36 <term>Array.prototype.sort</term>\n\ 37 </entry>\n\ 38 </list>\n\ 39 ', "text/xml"); 40 41 xsltdoc = new DOMParser().parseFromString('<?xml version="1.0" encoding="UTF-8"?>\n\ 42 <xsl:stylesheet version="1.0"\n\ 43 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n\ 44 <xsl:template match="/">\n\ 45 <html>\n\ 46 <body>\n\ 47 <table border="1">\n\ 48 <tr bgcolor="#9acd32">\n\ 49 <th>Technology</th>\n\ 50 <th>Term</th>\n\ 51 </tr>\n\ 52 <xsl:for-each select="list/entry">\n\ 53 <xsl:sort select="term" lang="$invalidLanguageTag"/>\n\ 54 <tr>\n\ 55 <td><xsl:value-of select="technology"/></td>\n\ 56 <td><xsl:value-of select="term"/></td>\n\ 57 </tr>\n\ 58 </xsl:for-each>\n\ 59 </table>\n\ 60 </body>\n\ 61 </html>\n\ 62 </xsl:template>\n\ 63 \n\ 64 </xsl:stylesheet>\n\ 65 ', "text/xml"); 66 67 var processor = new XSLTProcessor; 68 processor.importStylesheet(xsltdoc); 69 70 try 71 { 72 var result = processor.transformToDocument(xmldoc); 73 } 74 catch (e) 75 { 76 ok(false, "There was an error."); 77 } 78 ok(result && result instanceof Document, "XSLT transform should have created a document"); 79 </script> 80 </pre> 81 </body> 82 </html>