Index: LayoutTests/http/tests/eventsource/eventsource-cors-basic.html |
diff --git a/LayoutTests/http/tests/eventsource/eventsource-cors-basic.html b/LayoutTests/http/tests/eventsource/eventsource-cors-basic.html |
index 9f9573b38ad81bf1b2ee7be178aa67a38deaf1bf..be9a7dacf24e2d8c6c6680ff3c6d052623db6d05 100644 |
--- a/LayoutTests/http/tests/eventsource/eventsource-cors-basic.html |
+++ b/LayoutTests/http/tests/eventsource/eventsource-cors-basic.html |
@@ -1,82 +1,3 @@ |
-<html> |
-<body> |
-<p>Test that basic EventSource cross-origin requests fail until they are allowed by the Access-Control-Allow-Origin header. 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-basic.php?count=" + count); |
- } |
- catch (ex) { |
- log("FAIL: EventSource constructor threw exception: " + ex); |
- end(); |
- return; |
- } |
- |
- if (es.withCredentials) { |
- log("FAIL: withCredentials is true"); |
- es.close(); |
- end(); |
- } |
- |
- es.onerror = function () { |
- if (es.readyState == es.CLOSED) { |
- if (count != 3 && count != 4) { |
- log("PASS: got error event and readyState is CLOSED"); |
- count++; |
- setTimeout(create_es); |
- } |
- else { |
- log("FAIL: got unexpected error event"); |
- end(); |
- } |
- } |
- else if (count != 4) { |
- 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 == 3 && evt.data == "DATA1" && evt.lastEventId == "77") { |
- log("PASS: got cross-origin message event with data \"DATA1\" and lastEventId \"77\""); |
- count++; |
- return; |
- } |
- if (count == 4 && 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-basic.js"></script> |