Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerSentEvents: MOSQUITO submission #61

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ServerSentEvents/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EventSource tests require the use of a server on the same domain.

sse.js contains the server-side code to be used on a node.js server (http://nodejs.org).
34 changes: 34 additions & 0 deletions ServerSentEvents/absolute-url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<title>The url attribute must return the absolute URL that resulted from resolving the value that was passed to the constructor:</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>The url attribute must return the absolute URL that resulted from resolving the value that was passed to the constructor:</h1>
<div id="log"></div>
<script>
var url = "http://html5.mosquito-fp7.eu/messages/t0012";
var source = new EventSource(url);
test(function(){assert_equals(source.url, url)}, "The 'url' attribute is the absolute url.");
test(function(){assert_equals(source.URL, url)}, "The 'URL' attribute is the absolute url.");

source.addEventListener('message', function(e){
}, false);
source.addEventListener('open', function(e){ /* Connection opened. */

}, false);
source.addEventListener('error', function(e){
/* Connection closed. */
}, false);
</script>
</div>
</body>
</html>
39 changes: 39 additions & 0 deletions ServerSentEvents/accept-header-include-text-event-stream.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>For HTTP connections, the Accept header may be included; if included, it must contain only formats of event framing that are supported by the user agent (one of which must be text/event-stream, as described below):</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>For HTTP connections, the Accept header may be included; if included, it must contain only formats of event framing that are supported by the user agent (one of which must be text/event-stream, as described below):</h1>
<div id="log"></div>
<script>
var s = new EventSource('http://html5.mosquito-fp7.eu/messages/t0030');
ttext = async_test("accept header include 'text/event-stream'");

s.onopen = function(e){
/* Connection opened. */
};

s.onmessage = function(e){
console.log(e.data);
var dat = e.data.split("\n");
ttext.step(function(){assert_equals(dat[1].toString(), "text/event-stream")});
ttext.done();
};

s.onerror = function(e){
/* Connection closed. */
};

</script>
</div>
</body>
</html>
23 changes: 23 additions & 0 deletions ServerSentEvents/event-type-eventsource.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>When the EventSource() constructor is invoked, the UA must run these steps: Create a new EventSource object:</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>When the EventSource() constructor is invoked, the UA must run these steps: Create a new EventSource object:</h1>
<div id="log"></div>
<script>
var source = new EventSource('http://html5.mosquito-fp7.eu/messages/t0002');
test(function(){assert_true((source.constructor.toString().indexOf("EventSource") != -1))},"The object is EventSource.");
</script>
</div>
</body>
</html>
39 changes: 39 additions & 0 deletions ServerSentEvents/eventsource-aborted-after-close-method.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>The close() method must abort any instances of the fetch algorithm started for this EventSource object, and must set the readyState attribute to CLOSED:</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>The close() method must abort any instances of the fetch algorithm started for this EventSource object, and must set the readyState attribute to CLOSED:</h1>
<div id="log"></div>
<script>
setup({timeout:10000});
var source = new EventSource('http://html5.mosquito-fp7.eu/messages/t0022');
var tclose = async_test("The close() method must set the readyState attribute to CLOSED (2)");

source.addEventListener('open', function(e){
/* Connection opened. */
}, false);

source.addEventListener('message', function(e){
source.close();
tclose.step(function() {assert_equals(source.readyState, EventSource.CLOSED)});
tclose.done();
}, false);

source.addEventListener('error', function(e){
/* Connection closed. */
}, false);

</script>
</div>
</body>
</html>
54 changes: 54 additions & 0 deletions ServerSentEvents/field-name-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<title>The steps to process the field given a field name and a field value depend on the field name: The field name is "data":</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>The steps to process the field given a field name and a field value depend on the field name: The field name is "data":</h1>
<div id="log"></div>
<script>
setup({timeout:1500});
var s = new EventSource('http://html5.mosquito-fp7.eu/messages/t0075');
vt = null;
i = null;
t1 = async_test("field name is 'data' and append any U+000A LINE FEED (LF) character to the data buffer: Append the next field value and data buffer on the same line.");
t2 = async_test("field name is 'data' and append a single U+000A LINE FEED (LF) character to the data buffer: Append the field value to the data buffer.");
t3 = async_test("field name is 'data' and append two U+000A LINE FEED (LF) characters to the data buffer: Send a new data buffer, append the field value to the data buffer.");

s.onopen = function(e){
/* Connection opened. */
};

s.onmessage = function(e){
var dat = e.data.split("\n");
console.log(e.data.split("\n"));
t1.step(function(){assert_equals(dat[1], "data bufferdata: no LF")});
t2.step(function(){assert_equals(dat[2], "one LF")});
t1.done();
t2.done();
if(i == null){
i=1;
}else{
t3.step(function(){assert_equals(dat[0], "two LF")});
t3.done()
};
};

// console.log(s.testevent);
s.onerror = function(e){
/* Connection closed. */
};


</script>
</div>
</body>
</html>
40 changes: 40 additions & 0 deletions ServerSentEvents/field-name-event.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>The steps to process the field given a field name and a field value depend on the field name: The field name is "event":</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>The steps to process the field given a field name and a field value depend on the field name: The field name is "event":</h1>
<div id="log"></div>
<script>
setup({timeout:1500});
var s = new EventSource('http://html5.mosquito-fp7.eu/messages/t0074');
vt = null;
t = async_test("field name is 'event': set the event name buffer to field value.");
s.onopen = function(e){
/* Connection opened. */
};

s.addEventListener("testevent", function(e){
t.step(function(){assert_equals(e.type, "testevent")});
t.done();
}, false);

// console.log(s.testevent);
s.onerror = function(e){
/* Connection closed. */
};


</script>
</div>
</body>
</html>
48 changes: 48 additions & 0 deletions ServerSentEvents/field-name-id.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<title>The steps to process the field given a field name and a field value depend on the field name: The field name is "id":</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>The steps to process the field given a field name and a field value depend on the field name: The field name is "id":</h1>
<p id="w">waiting...</p>
<div id="log"></div>
<script>
setup({timeout:6000});
var s = new EventSource('http://html5.mosquito-fp7.eu/messages/t0076');
lei = null;
t = async_test("The field name is 'id': set the last event ID buffer to the field value.");

s.onopen = function(e){
/* Connection opened. */
};

s.onmessage = function(e){
if(lei == null){
lei = e.lastEventId;
console.log("lei :"+lei);
}else{
t.step(function(){assert_true(lei != e.lastEventId)});
t.done();
document.getElementById("w").innerHTML = "";
}
};

// console.log(s.testevent);
s.onerror = function(e){
/* Connection closed. */
};


</script>
</div>
</body>
</html>
45 changes: 45 additions & 0 deletions ServerSentEvents/field-name-other.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<title>The steps to process the field given a field name and a field value depend on the field name: Other:</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>The steps to process the field given a field name and a field value depend on the field name: Other:</h1>
<div id="log"></div>
<script>
setup({timeout:6000});
var s = new EventSource('http://html5.mosquito-fp7.eu/messages/t0078');
t = async_test("The field name is other: the field is not 'data'.");
u = async_test("The field name is other: the field is not 'id'.");

s.onopen = function(e){
/* Connection opened. */
};

s.onmessage = function(e){
console.log(e.type);
var dat = e.data.split("\n");
t.step(function(){assert_true(dat[1] != "other")});
u.step(function(){assert_true(e.lastEventId != "other")});
t.done();
u.done();
};

// console.log(s.testevent);
s.onerror = function(e){
/* Connection closed. */
};


</script>
</div>
</body>
</html>
53 changes: 53 additions & 0 deletions ServerSentEvents/field-name-retry.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<title>The steps to process the field given a field name and a field value depend on the field name: The field name is "retry":</title>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="http://w3c-test.org/resources/WebIDLParser.js"></script>
<script src="http://w3c-test.org/resources/idlharness.js"></script>
</head>
<body>
<h1>The steps to process the field given a field name and a field value depend on the field name: The field name is "retry":</h1>
<p id="w">waiting...</p>
<div id="log"></div>
<script>
setup({timeout:6000});
vt = null;
var s = new EventSource('http://html5.mosquito-fp7.eu/messages/t0077');
t = async_test("The field name is 'retry': check if the event try to reconnect after 'retry' value.");

s.onopen = function(e){
/* Connection opened. */
};

s.onmessage = function(e){
//s.close();
// t.step(function(){assert_true(lei != e.lastEventId)});
// t.done();
};

// console.log(s.testevent);
s.onerror = function(e){
if(e.eventPhase == EventSource.CLOSED){
/* Connection closed. */
if(vt == null){
vt = 2000;
console.log(e.data);
}else{
t.step(function(){assert_equals(vt, 2000)});
t.done();
}
document.getElementById("w").innerHTML = "";
}
};


</script>
</div>
</body>
</html>
Loading