diff options
Diffstat (limited to 'testing/web-platform/tests/websockets/interfaces/WebSocket/readyState')
8 files changed, 141 insertions, 0 deletions
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/001.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/001.html new file mode 100644 index 000000000..aa5d9fdf1 --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/001.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>WebSockets: getting readyState in 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) { + assert_equals((new WebSocket(SCHEME_DOMAIN_PORT+'/')).readyState, WebSocket.CONNECTING); +}); +</script> diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/002.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/002.html new file mode 100644 index 000000000..9e97416f3 --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/002.html @@ -0,0 +1,15 @@ +<!doctype html> +<title>WebSockets: setting readyState</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+'/'); + ws.readyState = 5; + assert_equals(ws.readyState, ws.CONNECTING); +}); +</script> diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/003.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/003.html new file mode 100644 index 000000000..93d72b64b --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/003.html @@ -0,0 +1,18 @@ +<!doctype html> +<title>WebSockets: delete readyState</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+'/'); + ws.close(); + delete ws.readyState; + assert_equals(ws.readyState, ws.CLOSING, 'delete ws.readyState'); + delete WebSocket.prototype.readyState; + assert_equals(ws.readyState, undefined, 'delete WebSocket.prototype.readyState'); +}); +</script> diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/004.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/004.html new file mode 100644 index 000000000..fbe326a10 --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/004.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>WebSockets: defineProperty getter for readyState</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() { + Object.defineProperty(WebSocket.prototype, 'readyState', { + get: function() { return 'foo'; } + }); + var ws = new WebSocket('ws://example.invalid/'); + assert_equals(ws.readyState, 'foo'); +}); +</script> diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/005.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/005.html new file mode 100644 index 000000000..3ca870529 --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/005.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>WebSockets: defineProperty setter for readyState</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(){ + window.setter_ran = false; + Object.defineProperty(WebSocket.prototype, 'readyState', { + set: function(v) { window[v] = true; } + }); + var ws = new WebSocket('ws://example.invalid/'); + ws.readyState = 'setter_ran'; + assert_true(setter_ran); +}); +</script> diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/006.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/006.html new file mode 100644 index 000000000..e0be938ab --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/006.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>WebSockets: getting readyState in 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) { + assert_equals(ws.readyState, ws.OPEN); + ws.close(); + t.done(); + }); + ws.onerror = ws.onmessage = ws.onclose = t.step_func(function() {assert_unreached()}); +}); +</script> diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/007.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/007.html new file mode 100644 index 000000000..12a4cd087 --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/007.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>WebSockets: getting readyState in closing</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.close(); + assert_equals(ws.readyState, ws.CLOSING); + t.done(); + }); + ws.onerror = ws.onmessage = ws.onclose = t.step_func(function() {assert_unreached()}); +}); +</script> diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/008.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/008.html new file mode 100644 index 000000000..c83ead4e7 --- /dev/null +++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/008.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>WebSockets: getting readyState in closed</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.onclose = t.step_func(function(e) { + assert_equals(ws.readyState, ws.CLOSED); + t.done(); + }) + ws.close(); + }); + ws.onerror = ws.onmessage = ws.onclose = t.step_func(function() {assert_unreached()}); +}); +</script> |