mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
99 lines
2.1 KiB
HTML
99 lines
2.1 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
function doFail(msg)
|
|
{
|
|
document.write(msg + "<p>");
|
|
parent.location.hash = "#fail";
|
|
throw 1;
|
|
}
|
|
|
|
var local = "http://example.com/tests/content/base/test/";
|
|
|
|
var passFiles = [[local + 'file_CrossSiteXHR3_pass1.xml', 'GET']];
|
|
|
|
var failFiles = [];
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege(
|
|
"UniversalXPConnect UniversalBrowserWrite");
|
|
|
|
for (i = 0; i < passFiles.length; ++i)
|
|
{
|
|
xhr = new XMLHttpRequest();
|
|
if (!xhr)
|
|
doFail("Couldn't open request : " + passFiles[i][0]);
|
|
try {
|
|
xhr.open(passFiles[i][1], passFiles[i][0], false);
|
|
}
|
|
catch(e) {
|
|
doFail("Open failed : " + passFiles[i][0]);
|
|
}
|
|
|
|
// Do the send
|
|
try {
|
|
xhr.send(null);
|
|
}
|
|
catch(e) {
|
|
doFail("Sending failed : " + passFiles[i][0]);
|
|
}
|
|
|
|
// Check the Access-Control-Origin
|
|
var channel =
|
|
xhr.channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
|
var value = null;
|
|
try {
|
|
value = channel.getRequestHeader("Access-Control-Origin");
|
|
}
|
|
catch(e) {
|
|
doFail("Getting request header failed : " + passFiles[i][0]);
|
|
}
|
|
if (value != "http://sub2.xn--lt-uia.example.org")
|
|
doFail("Referer-root incorrect : " + value);
|
|
|
|
// Check the response
|
|
if (xhr.status != "200") {
|
|
doFail("Status incorrect : " + passFiles[i][0]);
|
|
}
|
|
if (xhr.responseXML) {
|
|
responseString = (new XMLSerializer()).serializeToString(xhr.responseXML.documentElement);
|
|
if (responseString != "<res>hello</res>") {
|
|
doFail("Response incorrect : " + passFiles[i][0]);
|
|
}
|
|
}
|
|
else {
|
|
doFail("No response : " + passFiles[i][0]);
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < failFiles.length; ++i)
|
|
{
|
|
xhr = new XMLHttpRequest();
|
|
if (!xhr)
|
|
doFail("Couldn't open request : " + passFiles[i][0]);
|
|
|
|
success = false;
|
|
try {
|
|
xhr.open(failFiles[i][1], failFiles[i][0], false);
|
|
xhr.send(null);
|
|
}
|
|
catch (e) {
|
|
success = true;
|
|
}
|
|
if (!success) {
|
|
doFail("Test did not fail : " + failFiles[i][0]);
|
|
}
|
|
}
|
|
|
|
document.write("Success!");
|
|
parent.location.hash = "#done";
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|