summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/websockets/interfaces/WebSocket/send
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/websockets/interfaces/WebSocket/send')
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/001.html15
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/002.html15
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/003.html15
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/004.html25
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/005.html18
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/006.html25
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/007.html26
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/008.html25
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/009.html26
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/010.html41
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/011.html27
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/012.html27
12 files changed, 285 insertions, 0 deletions
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/001.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/001.html
new file mode 100644
index 000000000..3a22420ad
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/001.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>WebSockets: send() with no args</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_throws(new TypeError(), function(){ws.send()});
+});
+</script>
+
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/002.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/002.html
new file mode 100644
index 000000000..f5c7e4feb
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/002.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>WebSockets: replacing send</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+test(function() {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ ws.send = 5;
+ assert_equals(ws.send, 5);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/003.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/003.html
new file mode 100644
index 000000000..08aadbf46
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/003.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>WebSockets: send() when readyState is CONNECTING</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_throws("INVALID_STATE_ERR", function(){ws.send('a')});
+});
+</script>
+
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/004.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/004.html
new file mode 100644
index 000000000..af906b553
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/004.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>WebSockets: send() with unpaired surrogate when readyState is CONNECTING</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_throws("INVALID_STATE_ERR", function(){ws.send('a\uDC00x')});
+}, "lone low surrogate");
+
+test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_throws("INVALID_STATE_ERR", function(){ws.send('a\uD800x')});
+}, "lone high surrogate");
+
+test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_throws("INVALID_STATE_ERR", function(){ws.send('a\uDC00\uD800x')});
+}, "surrogates in wrong order");
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/005.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/005.html
new file mode 100644
index 000000000..69e727d11
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/005.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>WebSockets: send() return value</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+async_test(function(t){
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.onopen = t.step_func(function(e) {
+ assert_equals(ws.send('test'), undefined);
+ t.done();
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/006.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/006.html
new file mode 100644
index 000000000..ce871a106
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/006.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>WebSockets: send() with unpaired surrogate when readyState is OPEN</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id="log"></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.onopen = t.step_func(function(e) {
+ // lone low surrogate, lone high surrogate + surrogates in wrong order.
+ ws.send('a\uDC00xb\uD800xc\uDC00\uD800x');
+ })
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, 'a\uFFFDxb\uFFFDxc\uFFFD\uFFFDx');
+ ws.onclose = t.step_func(function(e) {
+ ws.onclose = t.step_func(function() {assert_unreached()});
+ setTimeout(function() {t.done();}, 50);
+ });
+ ws.close();
+ })
+ });
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/007.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/007.html
new file mode 100644
index 000000000..73dd08930
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/007.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>WebSockets: close() followed by send()</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.onopen = t.step_func(function(e) {
+ // test that nothing strange happens if we send something after close()
+ ws.close();
+ var sent = ws.send('test');
+ assert_equals(sent, undefined);
+ });
+ ws.onclose = t.step_func(function(e) {
+ ws.onclose = t.step_func(function() {assert_unreached()});
+ setTimeout(function() {t.done()}, 50);
+ });
+ ws.onerror = ws.onmessage = t.step_func(function() {assert_unreached()});
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/008.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/008.html
new file mode 100644
index 000000000..c5fc34bd8
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/008.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>WebSockets: send() in onclose</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.onopen = t.step_func(function(e) {
+ ws.send('Goodbye');
+ })
+ ws.onclose = t.step_func(function(e) {
+ // test that nothing strange happens when send()ing in closed state
+ var sent = ws.send('test');
+ assert_equals(sent, undefined);
+ ws.onclose = t.step_func(function() {assert_unreached()});
+ setTimeout(function() {t.done()}, 50);
+ })
+ ws.onerror = t.step_func(function() {assert_unreached()});
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/009.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/009.html
new file mode 100644
index 000000000..8f9417e77
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/009.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>WebSockets: send('')</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+async_test(function(t){
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
+ ws.onopen = t.step_func(function(e) {
+ ws.send('');
+ })
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, 'pass');
+ ws.close();
+ });
+ ws.onclose = t.step_func(function(e) {
+ ws.onclose = t.step_func(function() {assert_unreached()});
+ setTimeout(function() {t.done()}, 50);
+ });
+ ws.onerror = t.step_func(function() {assert_unreached()});
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/010.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/010.html
new file mode 100644
index 000000000..f6680c66f
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/010.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<title>WebSockets: sending non-strings</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+async_test(function(outer) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ var stuffToSend = [null, undefined, 1, window, document.body, {}, [], ws, function(){}, new Error()]
+ var tests = [];
+
+ for (var i=0; i<stuffToSend.length; i++) {
+ tests.push(async_test(document.title + " (" + stuffToSend[i] + ")"));
+ }
+
+ i = 0;
+ function sendNext() {
+ if (i === stuffToSend.length) {
+ outer.done()
+ ws.close();
+ } else {
+ var t = tests[i];
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, String(stuffToSend[i]));
+ i++;
+ sendNext();
+ t.done();
+ });
+ ws.onclose = ws.onerror = t.step_func(function() {assert_unreached()});
+ ws.send(stuffToSend[i]);
+ }
+ }
+ ws.onopen = outer.step_func(function(e) {
+ sendNext();
+ });
+}, "Constructor succeeds");
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/011.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/011.html
new file mode 100644
index 000000000..c00fa7f33
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/011.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<title>WebSockets: sending non-ascii, combining chars and non-BMP</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.onopen = t.step_func(function(e) {
+ ws.send('\u00E5 a\u030A \uD801\uDC7E');
+ });
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, '\u00E5 a\u030A \uD801\uDC7E');
+ ws.onclose = t.step_func(function(e) {
+ ws.onclose = t.step_func(function() {assert_unreached()});
+ setTimeout(function() {t.done()}, 50);
+ })
+ ws.close();
+ })
+ ws.onclose = ws.onerror = t.step_func(function() {assert_unreached()});
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/send/012.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/012.html
new file mode 100644
index 000000000..af5b935c6
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/012.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<title>WebSockets: sending null</title>
+
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.js?pipe=sub></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+
+async_test(function(t){
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.onopen = t.step_func(function(e) {
+ ws.send(null);
+ });
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, 'null');
+ ws.onclose = t.step_func(function(e) {
+ ws.onclose = t.step_func(function() {assert_unreached()});
+ setTimeout(function() {t.done()}, 50);
+ })
+ ws.close();
+ });
+ ws.onclose = ws.onerror = t.step_func(function() {assert_unreached()});
+});
+</script>