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

Unified Diff: LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials.html

Issue 345813005: Rework EventSource CORS tests to be usable from Workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Generalize redirect.php?cors_enabled to cors_allow_origin Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials.html
diff --git a/LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials.html b/LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials.html
index 68c429ed43f6438bca2d9a8fe60624d781b803e8..c50ab0f78df99b223e05575f69377a59c20ebe3b 100644
--- a/LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials.html
+++ b/LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials.html
@@ -1,82 +1,3 @@
-<html>
-<body>
-<p>Test that EventSource cross-origin requests with credentials fail until the correct CORS headers are sent. Should print a series of PASS messages followed by DONE.</p>
-<div id="result"></div>
-<script>
-function log(msg) {
- document.getElementById("result").innerHTML += msg + "<br>";
-}
-
-if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
-}
-
-function end() {
- if (window.testRunner)
- testRunner.notifyDone();
-}
-
-var count = 1;
-var base_url = location.href.substr(0, location.href.lastIndexOf('/')).replace("127.0.0.1", "localhost");
-
-function create_es() {
- try {
- var es = new EventSource(base_url + "/resources/es-cors-credentials.php?count=" + count, {"withCredentials": true});
- }
- catch (ex) {
- log("FAIL: EventSource constructor threw exception: " + ex);
- end();
- return;
- }
-
- if (!es.withCredentials) {
- log("FAIL: withCredentials is false");
- es.close();
- end();
- }
-
- es.onerror = function () {
- if (es.readyState == es.CLOSED) {
- if (count != 4 && count != 5) {
- log("PASS: got error event and readyState is CLOSED");
- count++;
- setTimeout(create_es);
- }
- else {
- log("FAIL: got unexpected error event");
- end();
- }
- }
- else if (count != 5) {
- log("FAIL: got error event but readyState is not CLOSED");
- es.close();
- end();
- }
- };
-
- es.onmessage = function (evt) {
- if (evt.origin != location.origin && !evt.origin.indexOf("http://localhost")) {
- if (count == 4 && evt.data == "DATA1" && evt.lastEventId == "77") {
- log("PASS: got cross-origin message event with data \"DATA1\" and lastEventId \"77\"");
- count++;
- return;
- }
- if (count == 5 && evt.data == "DATA2") {
- log("PASS: got cross-origin message event with data \"DATA2\"");
- log("DONE");
- }
- else
- log("FAIL: got unexpected cross-origin message event");
- }
- else
- log("FAIL: got message event from same or unexpected origin");
-
- es.close();
- end();
- };
-}
-create_es();
-</script>
-</body>
-</html>
+<!DOCTYPE HTML>
+<script src="/js-test-resources/js-test.js"></script>
+<script src="script-tests/eventsource-cors-with-credentials.js"></script>

Powered by Google App Engine
This is Rietveld 408576698