1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 3<head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 5 <title>SyntaxHighlighter Highlight Tests</title> 6 7 <!-- jQuery & QUnit --> 8 <script type="text/javascript" src="/components/jquery/jquery.min.js"></script> 9 <script type="text/javascript" src="/components/qunit/qunit/qunit.js"></script> 10 <link type="text/css" rel="stylesheet" href="/components/qunit/qunit/qunit.css"/> 11 12 <!-- SyntaxHighlighter --> 13 <script type="text/javascript" src="/components/xregexp/xregexp-all.js"></script> <!-- XRegExp is bundled with the final shCore.js during build --> 14 <script type="text/javascript" src="/src/js/shCore.js"></script> 15 <script type="text/javascript" src="/src/js/shLegacy.js"></script> 16 <script type="text/javascript" src="/src/js/shBrushAppleScript.js"></script> 17 <script type="text/javascript" src="/src/js/shBrushAS3.js"></script> 18 <script type="text/javascript" src="/src/js/shBrushBash.js"></script> 19 <script type="text/javascript" src="/src/js/shBrushColdFusion.js"></script> 20 <script type="text/javascript" src="/src/js/shBrushCpp.js"></script> 21 <script type="text/javascript" src="/src/js/shBrushCSharp.js"></script> 22 <script type="text/javascript" src="/src/js/shBrushCss.js"></script> 23 <script type="text/javascript" src="/src/js/shBrushDelphi.js"></script> 24 <script type="text/javascript" src="/src/js/shBrushDiff.js"></script> 25 <script type="text/javascript" src="/src/js/shBrushErlang.js"></script> 26 <script type="text/javascript" src="/src/js/shBrushGroovy.js"></script> 27 <script type="text/javascript" src="/src/js/shBrushJava.js"></script> 28 <script type="text/javascript" src="/src/js/shBrushJavaFx.js"></script> 29 <script type="text/javascript" src="/src/js/shBrushJScript.js"></script> 30 <script type="text/javascript" src="/src/js/shBrushPerl.js"></script> 31 <script type="text/javascript" src="/src/js/shBrushPhp.js"></script> 32 <script type="text/javascript" src="/src/js/shBrushPlain.js"></script> 33 <script type="text/javascript" src="/src/js/shBrushPowerShell.js"></script> 34 <script type="text/javascript" src="/src/js/shBrushPython.js"></script> 35 <script type="text/javascript" src="/src/js/shBrushRuby.js"></script> 36 <script type="text/javascript" src="/src/js/shBrushSass.js"></script> 37 <script type="text/javascript" src="/src/js/shBrushScala.js"></script> 38 <script type="text/javascript" src="/src/js/shBrushSql.js"></script> 39 <script type="text/javascript" src="/src/js/shBrushVb.js"></script> 40 <script type="text/javascript" src="/src/js/shBrushXml.js"></script> 41 42 <link type="text/css" rel="stylesheet" href="/pkg/styles/shCoreDefault.css"/> 43</head> 44 45<body> 46 47<h1 id="qunit-header">SyntaxHighlighter Highlight Lines Test</h1> 48<h2 id="qunit-banner"></h2> 49<div id="qunit-testrunner-toolbar"></div> 50<h2 id="qunit-userAgent"></h2> 51<ol id="qunit-tests"></ol> 52 53<button id="interaction">Run interaction tests</button> 54 55<div id="output"> 56</div> 57 58<style> 59body { 60 background: white; 61} 62 63#interaction { 64 margin-top: 1em; 65 padding: 1em; 66 font-size: 1.5em; 67} 68 69.test-wrap { 70 width: 45%; 71 height: 400px; 72 overflow: auto; 73 float: left; 74 margin: 1em 1em 0 0; 75 border: 5px solid silver; 76 background: gray; 77 font-family: Helvetica; 78} 79 80.test-wrap h3 { 81 margin: 1em 0 0 1em; 82 color: white; 83 font-size: 1em; 84 font-weight: normal; 85} 86</style> 87 88<script type="text/javascript"> 89var testQueue = [], 90 renderTests = [ 91 '001_basic', 92 '002_brushes', 93 '003_script_tag', 94 '004_url_parsing', 95 '005_no_gutter', 96 '006_pad_line_numbers', 97 '007_collapse', 98 '008_first_line', 99 '009_class_name', 100 '010_highlight', 101 '011_smart_tabs', 102 '012_server_side', 103 '013_html_script', 104 '014_legacy', 105 '015_xregexp' 106 ], 107 interactionTests = [ 108 '007_collapse_interaction' 109 ] 110 ; 111 112function queue(func) 113{ 114 testQueue.push(func); 115}; 116 117function ok_sh($sh) 118{ 119 ok($sh.length > 0, 'Element present'); 120 ok($sh.is('div'), 'Element is DIV'); 121 ok($sh.find('> div').is('.syntaxhighlighter'), 'Nested DIV is a .syntaxhighlighter'); 122}; 123 124function ok_toolbar($sh) 125{ 126 var $target = $sh.find('> .syntaxhighlighter > .toolbar'); 127 ok($target.length > 0, 'Toolbar present'); 128 ok($target.is(':visible'), 'Toolbar visible'); 129}; 130 131function ok_caption($sh, value) 132{ 133 var $target = $sh.find('> .syntaxhighlighter > table > caption'); 134 ok($target.length > 0, 'Caption present'); 135 ok($target.is(':visible'), 'Caption visible'); 136 137 if (value != null) 138 equal($target.text(), value, 'Caption text'); 139}; 140 141function ok_gutter($sh) 142{ 143 var $target = $sh.find('> .syntaxhighlighter > table > tbody > tr > .gutter'); 144 ok($target.length > 0, 'Gutter present'); 145 ok($target.is(':visible'), 'Gutter visible'); 146}; 147 148function ok_code($sh) 149{ 150 var $target = $sh.find('> .syntaxhighlighter > table > tbody > tr > .code'); 151 ok($target.length > 0, 'Code present'); 152 ok($target.is(':visible'), 'Code visible'); 153}; 154 155function ok_collapsed($sh) 156{ 157 ok($sh.find('> .syntaxhighlighter.collapsed').length == 1, '.collapsed present'); 158}; 159 160function loadTests(tests, addHtml) 161{ 162 var html = ''; 163 164 $.each(tests, function(index) 165 { 166 var name = this; 167 168 if (addHtml != false) 169 { 170 html += '<div class="test-wrap">\n' 171 html += '<h3>' + name + '</h3>\n'; 172 } 173 174 $.ajax({ 175 url: 'cases/' + name + '.html', 176 type: 'GET', 177 dataType: 'text', 178 async: false, 179 success: function(data) 180 { 181 html += data; 182 }, 183 error: function() 184 { 185 html += '<p>Not found...</p>'; 186 } 187 }); 188 189 if (addHtml != false) 190 { 191 html += '</div>\n'; 192 193 if (index % 2 != 0) 194 html += '<div style="clear:both"></div>\n'; 195 } 196 }); 197 198 // 199 // Looks like .html() is producing different results when it comes to 200 // content that has <script /> which type is NOT "text/javascript". 201 // $('#output').html(html); 202 // 203 $('#output')[0].innerHTML += html; 204 205 // 206 // However, if HTML assigned to to .innerHTML container <script/> tags, 207 // they are not executed, so we have to manually walk all of them and 208 // eval() the content. 209 // 210 $('#output script[type="text/javascript"][class!="executed"]').each(function() 211 { 212 eval($(this).text() || $(this).html()); 213 $(this).addClass('executed') 214 }); 215}; 216 217function runTestQueue() 218{ 219 220 $.each(testQueue, function() 221 { 222 this.apply(null); 223 }); 224 225 testQueue = []; 226}; 227 228$(document).ready(function() 229{ 230 loadTests(renderTests); 231 SyntaxHighlighter.highlight(); 232 runTestQueue(); 233 234 $('#interaction').click(function() 235 { 236 loadTests(interactionTests, false /* addHtml */); 237 runTestQueue(); 238 }); 239}); 240</script> 241 242</body> 243</html> 244