summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/websockets/interfaces/WebSocket/close
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/websockets/interfaces/WebSocket/close
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/websockets/interfaces/WebSocket/close')
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-basic.html26
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-connecting.html25
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-multiple.html29
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-nested.html28
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-replace.html15
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-return.html14
6 files changed, 137 insertions, 0 deletions
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-basic.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-basic.html
new file mode 100644
index 0000000000..b905941495
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-basic.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>WebSockets: close()</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.sub.js></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+'/');
+ ws.onclose = t.step_func(function(e) {
+ assert_equals(e instanceof CloseEvent, true, 'e instanceof CloseEvent');
+ assert_equals(e.wasClean, false, 'e.wasClean');
+ e.wasClean = true;
+ assert_equals(e.wasClean, false, 'e.wasClean = true');
+ delete e.wasClean;
+ assert_equals(e.wasClean, false, 'delete e.wasClean');
+ delete CloseEvent.prototype.wasClean;
+ assert_equals(e.wasClean, undefined, 'delete CloseEvent.prototype.wasClean');
+ t.done();
+ });
+ ws.close();
+ assert_equals(ws.readyState, ws.CLOSING);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-connecting.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-connecting.html
new file mode 100644
index 0000000000..6151b7b1a7
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-connecting.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>WebSockets: close() when connecting</title>
+<meta name=timeout content=long>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.sub.js></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+'/sleep_10_v13');
+ t.step_timeout(function() {
+ assert_equals(ws.readyState, ws.CONNECTING);
+ ws.close();
+ assert_equals(ws.readyState, ws.CLOSING);
+ ws.onclose = t.step_func(function(e) {
+ assert_equals(ws.readyState, ws.CLOSED);
+ assert_equals(e.wasClean, false);
+ t.done();
+ });
+ }, 1000);
+ ws.onopen = ws.onclose = t.unreached_func();
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-multiple.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-multiple.html
new file mode 100644
index 0000000000..7c6192555a
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-multiple.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<title>WebSockets: close() several times</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.sub.js></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+var i = 0;
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ ws.onclose = t.step_func(function(e) {
+ i++;
+ });
+ ws.close();
+ ws.close();
+ ws.close();
+ var f = t.step_func(function() {
+ if (i < 1) {
+ t.step_timeout(f, 500);
+ return;
+ }
+ assert_equals(i, 1);
+ t.done()
+ });
+ t.step_timeout(f, 500);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-nested.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-nested.html
new file mode 100644
index 0000000000..0a1c86ccd0
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-nested.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<title>WebSockets: close() in close event handler</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.sub.js></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+'/');
+ var i = 0;
+ ws.onclose = t.step_func(function(e) {
+ i++;
+ if (i == 1) {
+ assert_equals(ws.readyState, ws.CLOSED);
+ ws.close();
+ assert_equals(ws.readyState, ws.CLOSED);
+ }
+ t.step_timeout(function() {
+ assert_equals(i, 1);
+ t.done();
+ }, 50);
+ });
+ ws.close();
+ assert_equals(ws.readyState, ws.CLOSING);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-replace.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-replace.html
new file mode 100644
index 0000000000..3607f8d8c3
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-replace.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>WebSockets: replacing close</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.sub.js></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.close = 5;
+ assert_equals(ws.close, 5);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-return.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-return.html
new file mode 100644
index 0000000000..5988605cf6
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/close/close-return.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>WebSockets: close() return value</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=../../../constants.sub.js></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<div id=log></div>
+<script>
+test(function() {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_equals(ws.close(), undefined);
+});
+</script>