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

Unified Diff: LayoutTests/http/tests/eventsource/script-tests/eventsource-status-code-states.js

Issue 347043002: Rework EventSource tests for better Worker test coverage. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move out CORS tests 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/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>

Powered by Google App Engine
This is Rietveld 408576698