mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
61 lines
1.8 KiB
HTML
61 lines
1.8 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 passFiles = [[local + 'file_CrossSiteXHR_pass1.xml', 'GET'],
|
|
[local + 'file_CrossSiteXHR_pass2.xml', 'GET'],
|
|
[local + 'file_CrossSiteXHR_pass3.xml', 'GET'],
|
|
];
|
|
|
|
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'],
|
|
];
|
|
|
|
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>
|