forked from linkeddata/rdflib.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.js
More file actions
63 lines (57 loc) · 2.07 KB
/
test_utils.js
File metadata and controls
63 lines (57 loc) · 2.07 KB
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
// some utility functions used throughout the test cases detailed view
function viewSource (fileName, offlineMode) {
$('#viewSourceCode').attr('disabled', 'disabled')
$.ajax({
url: fileName,
dataType: 'script',
success: function (data) {
var cmdStyle = 'color: black; font-weight: bold; border-bottom: 1px solid #9f9f9f; padding: 0.1em; width:100%'
var sourceStyle = 'position: static; top: 1em; left: 4em; -moz-box-shadow:0 0 6px rgba(0, 0, 0, 0.5); -moz-border-radius: 2px; padding: 0.1em; background: white; width:90%'
var sourceCmd = "<div style='" + cmdStyle + "'><button id='closeSourceView'>close</button> " + fileName + '</div>'
var sourceContent = "<div id='sourceView' style='" + sourceStyle + "'>" + sourceCmd + "<pre style='margin-left: 0.5em;'>" + escapeEntities(data) + '</pre></div>'
if (offlineMode) $('#header').after(sourceContent)
else $('#header').before(sourceContent)
},
error: function (msg) {
alert("Can't display " + fileName)
}
})
}
function hideSource () {
$('#sourceView').remove()
$('#viewSourceCode').removeAttr('disabled')
}
function escapeEntities (text) {
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
}
function startBusy () {
$('#header').after("<div id='busy'><img src='../img/busy.gif' width='32px' alt='busy /></div>")
}
function stopBusy () {
$('#busy').remove()
}
function stackString (e) {
var str = '' + e + '\n'
if (!e.stack) {
return str + 'No stack available.\n'
}
var lines = e.stack.toString().split('\n')
var toprint = []
for (var i = 0; i < lines.length; i++) {
var line = lines[i]
if (line.indexOf('ecmaunit.js') > -1) {
// remove useless bit of traceback
break
}
if (line.charAt(0) == '(') {
line = 'function' + line
}
var chunks = line.split('@')
toprint.push(chunks)
}
// toprint.reverse(); No - I prefer the latest at the top by the error message -tbl
for (var i = 0; i < toprint.length; i++) {
str += ' ' + toprint[i][1] + '\n ' + toprint[i][0]
}
return str
}