blob: 20ef00d06d1e801237d192254084a211665de072 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<!DOCTYPE HTML>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>Test new CORS console messages</title>
</head>
<body onload="initTest()">
<p id="display">
<iframe id=loader></iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="application/javascript">
let gen;
let number_of_tests = 0;
function initTest() {
window.addEventListener("message", function(e) {
gen.next(e.data);
if (number_of_tests == 2) {
document.location.href += "#finishedTestTwo";
}
});
gen = runTest();
gen.next();
}
function* runTest() {
let loader = document.getElementById("loader");
let loaderWindow = loader.contentWindow;
loader.onload = function() { gen.next(); };
loader.src = "http://example.org/browser/dom/security/test/cors/file_CrossSiteXHR_inner.html";
origin = "http://example.org";
yield undefined;
let tests = [
// Loading URLs other than http(s) should throw 'CORS request
// not http' console message.
{ baseURL: "ftp://mochi.test:8888/browser/dom/security/test/cors/file_CrossSiteXHR_server.sjs",
method: "GET",
},
// (https://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0)
// CORs preflight external redirect should throw 'CORS request
// external redirect not allowed' error.
// This will also throw 'CORS preflight channel did not succeed'
// and 'CORS request did not succeed' console messages.
{
baseURL: "http://mochi.test:8888/browser/dom/security/test/cors/bug1456721.sjs?redirect",
method: "OPTIONS",
},
];
for (let test of tests) {
let req = {
url: test.baseURL,
method: test.method
};
loaderWindow.postMessage(JSON.stringify(req), origin);
number_of_tests++;
yield;
}
}
</script>
</pre>
</body>
</html>
|