Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: LayoutTests/http/tests/xmlhttprequest/cross-origin-no-authorization.html

Issue 14195011: Removed WONTFIX tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <button onclick="presetAuthorization()">Start</button>
2 <pre id="console"></pre>
3 <script>
4 if (window.testRunner) {
5 testRunner.dumpAsText();
6 testRunner.waitUntilDone();
7 testRunner.setCanOpenWindows();
8 }
9
10 function log(message)
11 {
12 document.getElementById('console').appendChild(document.createTextNode(messa ge + '\n'));
13 }
14
15 function presetAuthorization()
16 {
17 window.addEventListener("message", test, false);
18 window.open("http://localhost:8000/xmlhttprequest/resources/cross-origin-pre set-authorization-frame.html");
19 }
20
21 function test()
22 {
23 log("Trying different ways to access a password protected resource from anot her origin. The UA already has login and password for this protection space.\n")
24 log("You should see several PASS messages followed by a DONE\n");
25 log("SCRIPT SRC='...' Should succeed, since authorization is sent for cross- origin subresource loads.");
26 var scriptElement = document.createElement("script");
27 scriptElement.setAttribute("src", "http://localhost:8000/xmlhttprequest/reso urces/cross-origin-no-authorization.php");
28 scriptElement.setAttribute("onload", "test_sync_auth_stored()");
29 scriptElement.setAttribute("onerror", "test_sync_auth_stored()");
30 document.body.appendChild(scriptElement);
31 }
32
33 function test_sync_auth_stored()
34 {
35 log("Cross-origin XMLHttpRequest (sync), authorization will not be sent, bec ause withCredentials is false.");
36
37 var req = new XMLHttpRequest;
38 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -no-authorization.php", false);
39 try {
40 req.send();
41 log((req.status == 401) ? "PASS: 401 Authorization required" : "FAIL: Lo aded");
42 } catch (ex) {
43 log("PASS: Got an exception. " + ex);
44 }
45 test_sync_auth_stored_with_credentials();
46 }
47
48 function test_sync_auth_stored_with_credentials()
49 {
50 log("Cross-origin XMLHttpRequest (sync), testing authorization that's not al lowed by the server (withCredentials is true, but access control headers are not set).");
51
52 var req = new XMLHttpRequest;
53 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -no-authorization.php", false);
54 req.withCredentials = true;
55 try {
56 req.send();
57 log((req.status == 401) ? "PASS: 401 Authorization required" : "FAIL: Lo aded");
58 } catch (ex) {
59 log("PASS: Got an exception. " + ex);
60 }
61 test_sync_cookies();
62 }
63
64 function test_sync_cookies()
65 {
66 log("Cross-origin XMLHttpRequest (sync), testing cookies.");
67
68 var req = new XMLHttpRequest;
69 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -check-cookies.php", false);
70 req.send();
71 log(req.responseText.match(/WK\-cross\-origin/) ? "FAIL" : "PASS");
72 test_async_auth_stored();
73 }
74
75 function test_async_auth_stored()
76 {
77 log("Cross-origin XMLHttpRequest (async), authorization will not be sent, be cause withCredentials is false.");
78
79 var req = new XMLHttpRequest;
80 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -no-authorization.php", true);
81 req.send();
82 req.onload = function() {
83 log((req.status == 401) ? "PASS: 401 Authorization required" : "FAIL: Lo aded");
84 test_async_auth_stored_with_credentials();
85 }
86 req.onerror = function() {
87 log("PASS: Received error event.");
88 test_async_auth_stored_with_credentials();
89 }
90 }
91
92 function test_async_auth_stored_with_credentials()
93 {
94 log("Cross-origin XMLHttpRequest (async), testing authorization that's not a llowed by the server (withCredentials is true, but access control headers are no t set).");
95
96 var req = new XMLHttpRequest;
97 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -no-authorization.php", true);
98 req.withCredentials = true;
99 req.send();
100 req.onload = function() {
101 log((req.status == 401) ? "PASS: 401 Authorization required" : "FAIL: Lo aded");
102 test_async_cookies();
103 }
104 req.onerror = function() {
105 log("PASS: Received error event.");
106 test_async_cookies();
107 }
108 }
109
110 function test_async_cookies()
111 {
112 log("Cross-origin XMLHttpRequest (async), testing cookies.");
113
114 var req = new XMLHttpRequest;
115 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -check-cookies.php", true);
116 req.send();
117 req.onload = function() {
118 log(req.responseText.match(/WK\-cross\-origin/) ? "FAIL" : "PASS");
119 test_sync_auth_explicit();
120 }
121 }
122
123 function test_sync_auth_explicit()
124 {
125 log("Cross-origin XMLHttpRequest (sync), testing authorization with explicit ly provided credentials that should be ignored.");
126
127 var req = new XMLHttpRequest;
128 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -no-authorization.php", false, "test", "test");
129 try {
130 req.send();
131 log((req.status == 401) ? "PASS: 401 Authorization required" : "FAIL: Lo aded");
132 } catch (ex) {
133 log("PASS: Got an exception. " + ex);
134 }
135 test_async_auth_explicit();
136 }
137
138
139 function test_async_auth_explicit()
140 {
141 log("Cross-origin XMLHttpRequest (async), testing authorization with explici tly provided credentials that should be ignored.");
142
143 var req = new XMLHttpRequest;
144 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin -no-authorization.php", true, "test", "test");
145 req.send();
146 req.onload = function() {
147 log((req.status == 401) ? "PASS: 401 Authorization required" : "FAIL: Lo aded");
148 log("DONE");
149 if (window.testRunner)
150 testRunner.notifyDone();
151 }
152 req.onerror = function() {
153 log("PASS: Received error event.");
154 log("DONE");
155 if (window.testRunner)
156 testRunner.notifyDone();
157 }
158 }
159
160 if (window.testRunner)
161 presetAuthorization();
162 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698