mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
70 lines
2.2 KiB
HTML
70 lines
2.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for Cross Site XMLHttpRequest</title>
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
var local = "http://example.com/tests/content/base/test/";
|
|
var post = "http://people.mozilla.com/cgi-bin/sicking/xhr/posttest.pl/";
|
|
|
|
var passFiles = [[local + 'file_CrossSiteXHR_pass1.xml', 'GET'],
|
|
[local + 'file_CrossSiteXHR_pass2.xml', 'GET'],
|
|
[local + 'file_CrossSiteXHR_pass3.xml', 'GET'],
|
|
[post + 'pass1', 'POST'],
|
|
[post + 'pass2', 'POST'],
|
|
[post + 'pass3', 'POST'],
|
|
];
|
|
|
|
var failFiles = [[local + 'file_CrossSiteXHR_fail1.xml', 'GET'],
|
|
[local + 'file_CrossSiteXHR_fail2.xml', 'GET'],
|
|
[local + 'file_CrossSiteXHR_fail3.xml', 'GET'],
|
|
[local + 'file_CrossSiteXHR_fail4.xml', 'GET'],
|
|
[post + 'fail1', 'POST'],
|
|
[post + 'fail2', 'POST'],
|
|
[post + 'fail3', 'POST'],
|
|
[post + 'fail4', 'POST'],
|
|
[post + 'fail5', 'POST'],
|
|
];
|
|
|
|
for (i = 0; i < passFiles.length; ++i) {
|
|
xhr = new XMLHttpRequest();
|
|
xhr.open(passFiles[i][1], passFiles[i][0], false);
|
|
xhr.send(null);
|
|
is(xhr.status, 200, "wrong status");
|
|
if (xhr.responseXML) {
|
|
is((new XMLSerializer()).serializeToString(xhr.responseXML.documentElement),
|
|
"<res>hello</res>",
|
|
"wrong response");
|
|
}
|
|
else {
|
|
is(xhr.responseText, "hello pass\n", "wrong response");
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < failFiles.length; ++i) {
|
|
xhr = new XMLHttpRequest();
|
|
success = false;
|
|
try {
|
|
xhr.open(failFiles[i][1], failFiles[i][0], false);
|
|
xhr.send(null);
|
|
}
|
|
catch (e) {
|
|
success = true;
|
|
}
|
|
ok(success, "should have thrown");
|
|
}
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|