| Index: LayoutTests/http/tests/eventsource/script-tests/eventsource-status-code-states.js
|
| diff --git a/LayoutTests/http/tests/eventsource/eventsource-status-code-states.html b/LayoutTests/http/tests/eventsource/script-tests/eventsource-status-code-states.js
|
| similarity index 69%
|
| copy from LayoutTests/http/tests/eventsource/eventsource-status-code-states.html
|
| copy to LayoutTests/http/tests/eventsource/script-tests/eventsource-status-code-states.js
|
| index 206b1f87db870330af72d519552ee2a1a4886cf0..c6e078a7309f507f639907194a70b5f28b3342d7 100644
|
| --- a/LayoutTests/http/tests/eventsource/eventsource-status-code-states.html
|
| +++ b/LayoutTests/http/tests/eventsource/script-tests/eventsource-status-code-states.js
|
| @@ -1,11 +1,9 @@
|
| -<html>
|
| -<body>
|
| -<p>Test EventSource states for different status codes. 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 (self.importScripts)
|
| + importScripts("/js-test-resources/js-test.js");
|
| +
|
| +description("Test EventSource states for different status codes.");
|
| +
|
| +self.jsTestIsAsync = true;
|
|
|
| function arrayCompare(a1, a2) {
|
| if (a1.length != a2.length)
|
| @@ -31,16 +29,18 @@ var tests = [{"code": 200, "expectedStates": [CONNECTING, OPEN, OPEN, CONNECTING
|
| {"code": 404, "expectedStates": [CONNECTING,,, CLOSED, CLOSED]}]; // any other
|
| var count = 0;
|
|
|
| +var es;
|
| +var states = [];
|
| +
|
| function runTest() {
|
| if (count >= tests.length) {
|
| - log("DONE");
|
| - if (window.testRunner)
|
| - testRunner.notifyDone();
|
| + debug("DONE");
|
| + finishJSTest();
|
| return;
|
| }
|
|
|
| - var states = [];
|
| - var es = new EventSource("resources/status-codes.php?status-code=" + tests[count].code);
|
| + states = [];
|
| + es = new EventSource("/eventsource/resources/status-codes.php?status-code=" + tests[count].code);
|
| states[0] = es.readyState;
|
|
|
| es.onopen = function () {
|
| @@ -56,23 +56,14 @@ function runTest() {
|
| es.close();
|
| states[4] = es.readyState;
|
|
|
| - var result = arrayCompare(states, tests[count].expectedStates) ? "PASS" : "FAIL";
|
| - result += ": status code " + tests[count].code + " resulted in states ";
|
| + shouldBeTrue("arrayCompare(states, tests[count].expectedStates)");
|
| + result = "status code " + tests[count].code + " resulted in states ";
|
| for (var i in states)
|
| result += (i != 0 ? ", " : "") + stateNames[states[i]];
|
| - log(result);
|
| + testPassed(result);
|
|
|
| - setTimeout(runTest, 0);
|
| count++;
|
| + setTimeout(runTest, 0);
|
| };
|
| }
|
| -
|
| -if (window.testRunner) {
|
| - testRunner.dumpAsText();
|
| - testRunner.waitUntilDone();
|
| -}
|
| -
|
| runTest();
|
| -</script>
|
| -</body>
|
| -</html>
|
|
|