-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo.html
69 lines (68 loc) · 2.28 KB
/
demo.html
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
<!doctype HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sandboxed jQuery demo</title>
</head>
<body>
<script src="javascript/Mental.js" type="text/javascript"></script>
<script>
function loadJQuery() {
var xhr = new XMLHttpRequest;
xhr.open('GET', 'javascript/jquery-1.8.2.js?'+ +Date, false);
xhr.send();
return xhr.responseText;
}
function demo(demoNum) {
var jqueryCode = loadJQuery(),
code = document.getElementById('demo'+demoNum).value,
js = MentalJS(), start = new Date();
js.parse({
options:{eval:true,dom:true},
global: true,
thisObject: window,
code:jqueryCode+code,
complete:function() {
var end = new Date(),
elapsedTime = (end - start);
document.getElementById('demo'+demoNum+'Parse').textContent = elapsedTime + 'ms';
}
});
}
window.addEventListener('DOMContentLoaded', function() {
MentalJS().init({
dom : true
});
}, false);
</script>
<fieldset>
<div>Parse time:<span id="demo1Parse"></span></div>
<legend>jQuery demos</legend>
<p>
<textarea cols="50" rows="6" id="demo1">$('#x').html("<img src=1 onerror=alert(location)>");</textarea>
<input type="button" value="Run" onclick="demo(1);" />
</p>
<p>
<div>Parse time:<span id="demo2Parse"></span></div>
<textarea cols="50" rows="6" id="demo2">alert($('div').length)</textarea>
<input type="button" value="Run" onclick="demo(2);" />
</p>
<p>
<div>Parse time:<span id="demo3Parse"></span></div>
<textarea cols="50" rows="6" id="demo3">$('#x').css("border", "5px solid red")</textarea>
<input type="button" value="Run" onclick="demo(3);" />
</p>
<p>
<div>Parse time:<span id="demo4Parse"></span></div>
<textarea cols="50" rows="6" id="demo4">$('<img src=1 onerror=alert(location)>')</textarea>
<input type="button" value="Run" onclick="demo(4);" />
</p>
<p>
<div>Parse time:<span id="demo5Parse"></span></div>
<textarea cols="50" rows="6" id="demo5">$("#x").attr("style","color:red").html("Hello jQuery")</textarea>
<input type="button" value="Run" onclick="demo(5);" />
</p>
</fieldset>
<div id="x">test</div>
</body>
</html>