aboutsummaryrefslogtreecommitdiff
blob: 58e963f1a560d87a409943b25d2eca9b0f383d73 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!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">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>SyntaxHighlighter Highlight Tests</title>

	<!-- jQuery & QUnit -->
	<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
	<script type="text/javascript" src="js/qunit.js"></script>
	<link type="text/css" rel="stylesheet" href="js/qunit.css"/>

	<!-- SyntaxHighlighter -->
	<script type="text/javascript" src="/sh/scripts/XRegExp.js"></script> <!-- XRegExp is bundled with the final shCore.js during build -->
	<script type="text/javascript" src="/sh/scripts/shCore.js"></script>
	<script type="text/javascript" src="/sh/scripts/shLegacy.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushAppleScript.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushAS3.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushBash.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushColdFusion.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushCpp.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushCSharp.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushCss.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushDelphi.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushDiff.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushErlang.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushGroovy.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushJava.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushJavaFx.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushJScript.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushPerl.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushPhp.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushPlain.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushPowerShell.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushPython.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushRuby.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushSass.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushScala.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushSql.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushVb.js"></script>
	<script type="text/javascript" src="/sh/scripts/shBrushXml.js"></script>

	<link type="text/css" rel="stylesheet" href="/sh/styles/shCoreDefault.css"/>
</head>

<body>

<h1 id="qunit-header">SyntaxHighlighter Highlight Lines Test</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>

<button id="interaction">Run interaction tests</button>

<div id="output">
</div>

<style>
body {
	background: white;
}

#interaction {
	margin-top: 1em;
	padding: 1em;
	font-size: 1.5em;
}

.test-wrap {
	width: 45%;
	height: 400px;
	overflow: auto;
	float: left;
	margin: 1em 1em 0 0;
	border: 5px solid silver;
	background: gray;
	font-family: Helvetica;
}

.test-wrap h3 {
	margin: 1em 0 0 1em;
	color: white;
	font-size: 1em;
	font-weight: normal;
}
</style>

<script type="text/javascript">
var testQueue = [],
	renderTests = [
		'001_basic',
		'002_brushes',
		'003_script_tag',
		'004_url_parsing',
		'005_no_gutter',
		'006_pad_line_numbers',
		'007_collapse',
		'008_first_line',
		'009_class_name',
		'010_highlight',
		'011_smart_tabs',
		'012_server_side',
		'013_html_script',
		'014_legacy'
	],
	interactionTests = [
		'007_collapse_interaction'
	]
	;

function queue(func)
{
	testQueue.push(func);
};

function ok_sh($sh)
{
	ok($sh.length > 0, 'Element present');
	ok($sh.is('div'), 'Element is DIV');
	ok($sh.find('> div').is('.syntaxhighlighter'), 'Nested DIV is a .syntaxhighlighter');
};

function ok_toolbar($sh)
{
	var $target = $sh.find('> .syntaxhighlighter > .toolbar');
	ok($target.length > 0, 'Toolbar present');
	ok($target.is(':visible'), 'Toolbar visible');
};

function ok_caption($sh, value)
{
	var $target = $sh.find('> .syntaxhighlighter > table > caption');
	ok($target.length > 0, 'Caption present');
	ok($target.is(':visible'), 'Caption visible');
	
	if (value != null)
		equals($target.text(), value, 'Caption text');
};

function ok_gutter($sh)
{
	var $target = $sh.find('> .syntaxhighlighter > table > tbody > tr > .gutter');
	ok($target.length > 0, 'Gutter present');
	ok($target.is(':visible'), 'Gutter visible');
};

function ok_code($sh)
{
	var $target = $sh.find('> .syntaxhighlighter > table > tbody > tr > .code');
	ok($target.length > 0, 'Code present');
	ok($target.is(':visible'), 'Code visible');
};

function ok_collapsed($sh)
{
	ok($sh.find('> .syntaxhighlighter.collapsed').length == 1, '.collapsed present');
};

function loadTests(tests, addHtml)
{
	var html = '';
	
	$.each(tests, function(index)
	{
		var name = this;
		
		if (addHtml != false)
		{
			html += '<div class="test-wrap">\n'
			html += '<h3>' + name + '</h3>\n';
		}
		
		$.ajax({
			url: 'cases/' + name + '.html',
			type: 'GET',
			dataType: 'text',
			async: false,
			success: function(data)
			{
				html += data;
			},
			error: function()
			{
				html += '<p>Not found...</p>';
			}
		});
		
		if (addHtml != false)
		{
			html += '</div>\n';
		
			if (index % 2 != 0)
				html += '<div style="clear:both"></div>\n';
		}
	});

	//
	// Looks like .html() is producing different results when it comes to
	// content that has <script /> which type is NOT "text/javascript".
	// $('#output').html(html);
	//
	$('#output')[0].innerHTML += html;
		
	//
	// However, if HTML assigned to to .innerHTML container <script/> tags,
	// they are not executed, so we have to manually walk all of them and
	// eval() the content.
	//
	$('#output script[type="text/javascript"][class!="executed"]').each(function()
	{
		eval($(this).text() || $(this).html());
		$(this).addClass('executed')
	});
};

function runTestQueue()
{
	
	$.each(testQueue, function()
	{
		this.apply(null);
	});
	
	testQueue = [];
};

$(document).ready(function()
{
	loadTests(renderTests);
	SyntaxHighlighter.highlight();
	runTestQueue();
	
	$('#interaction').click(function()
	{
		loadTests(interactionTests, false /* addHtml */);
		runTestQueue();
	});
});
</script>


<!-- jinwei.me Baidu tongji analytics -->
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");

document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F91918ac6d6854623883a2b546ebc00ac' type='text/javascript'%3E%3C/script%3E"));

</script>

</body>
</html>
Powered by cgit v1.2.3 (git 2.41.0)