blob: 43e25f26d3cdc19e7bb5c52853047c1d1726dc43 (
plain)
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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>QWebSecurityOrigin test page</title>
<script Language="JavaScript">
function runTest(url)
{
var result = "";
function trace(point)
{
var el = document.createElement("P");
el.innerHTML = point + ": Result is:\"" + result + "\""
document.getElementById("Console").appendChild(el);
}
try {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET',url, false);
xmlhttp.onreadystatechange = done;
xmlhttp.onerror = error;
xmlhttp.send(null);
result = xmlhttp.responseText;
} catch (e) {
if (result == "") {
result = e;
trace("Catch1");
} else
trace("Catch2");
}
function done()
{
if (result.length < 5) {
result = "" + xmlhttp.readyState;
trace("Done1");
} else
trace("Done2");
}
function error()
{
result = "FAILED";
trace("Error");
}
trace("Exit");
return result == "Test";
}
</script>
</head>
<body>
<input type="button" onclick="javascript:alert(runTest('http://www.google.com'))" value="Run Test"/><br/>
<div id="Console"/>
</body>
</html>
|