diff options
Diffstat (limited to 'test/wpt/tests/websockets/interfaces/WebSocket/constants')
6 files changed, 124 insertions, 0 deletions
diff --git a/test/wpt/tests/websockets/interfaces/WebSocket/constants/001.html b/test/wpt/tests/websockets/interfaces/WebSocket/constants/001.html new file mode 100644 index 0000000..7d79bf5 --- /dev/null +++ b/test/wpt/tests/websockets/interfaces/WebSocket/constants/001.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>WebSockets: getting constants on constructor</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=../../../constants.sub.js></script> +<meta name="variant" content="?default"> +<meta name="variant" content="?wss"> +<div id=log></div> +<script> +var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; +for (var i = 0; i < constants.length; ++i) { + test(function(){ + var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/'); + assert_equals(WebSocket[constants[i]], i, 'WebSocket.'+constants[i]); + }, "Constants on constructors " + constants[i]); +}; +</script> diff --git a/test/wpt/tests/websockets/interfaces/WebSocket/constants/002.html b/test/wpt/tests/websockets/interfaces/WebSocket/constants/002.html new file mode 100644 index 0000000..6810bc6 --- /dev/null +++ b/test/wpt/tests/websockets/interfaces/WebSocket/constants/002.html @@ -0,0 +1,24 @@ +<!doctype html> +<title>WebSockets: setting constants</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=../../../constants.sub.js></script> +<meta name="variant" content="?default"> +<meta name="variant" content="?wss"> +<div id=log></div> +<script> +// this test is testing WebIDL stuff +var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/'); +var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; +for (var i = 0; i < constants.length; ++i) { + test(function() { + WebSocket[constants[i]] = 5; // should be ignored, has { ReadOnly } + WebSocket.prototype[constants[i]] = 5; // should be ignored, has { ReadOnly } + ws[constants[i]] = 5; // should be ignored, { ReadOnly } is inherited from prototype + assert_equals(WebSocket[constants[i]], i, 'WebSocket.'+constants[i]); + assert_equals(WebSocket.prototype[constants[i]], i, 'WebSocket.prototype.'+constants[i]); + assert_equals(ws[constants[i]], i, 'ws.'+constants[i]); + }, "Readonly constants " + constants[i]); +}; +</script> + diff --git a/test/wpt/tests/websockets/interfaces/WebSocket/constants/003.html b/test/wpt/tests/websockets/interfaces/WebSocket/constants/003.html new file mode 100644 index 0000000..4a86af8 --- /dev/null +++ b/test/wpt/tests/websockets/interfaces/WebSocket/constants/003.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>WebSockets: deleting constants</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=../../../constants.sub.js></script> +<meta name="variant" content="?default"> +<meta name="variant" content="?wss"> +<div id=log></div> +<script> +var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; +for (var i = 0; i < constants.length; ++i) { + test(function(){ + var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/'); + delete WebSocket[constants[i]]; // should be ignored, has { DontDelete } + delete WebSocket.prototype[constants[i]]; // should be ignored, has { DontDelete } + delete ws[constants[i]]; // should be ignored, there is no such property on the object + assert_equals(WebSocket[constants[i]], i, 'WebSocket.'+constants[i]); + assert_equals(WebSocket.prototype[constants[i]], i, 'WebSocket.prototype.'+constants[i]); + assert_equals(ws[constants[i]], i, 'ws.'+constants[i]); + }) +}; +</script> diff --git a/test/wpt/tests/websockets/interfaces/WebSocket/constants/004.html b/test/wpt/tests/websockets/interfaces/WebSocket/constants/004.html new file mode 100644 index 0000000..2ca3830 --- /dev/null +++ b/test/wpt/tests/websockets/interfaces/WebSocket/constants/004.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>WebSockets: getting constants on prototype and object</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=../../../constants.sub.js></script> +<meta name="variant" content="?default"> +<meta name="variant" content="?wss"> +<div id=log></div> +<script> +var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; +for (var i = 0; i < constants.length; ++i) { + test(function() { + var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/'); + assert_equals(WebSocket.prototype[constants[i]], i); + }, 'WebSocket.prototype.'+constants[i]); + test(function() { + var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/'); + assert_equals(ws[constants[i]], i); + }, 'ws.'+constants[i]); +}; +</script> diff --git a/test/wpt/tests/websockets/interfaces/WebSocket/constants/005.html b/test/wpt/tests/websockets/interfaces/WebSocket/constants/005.html new file mode 100644 index 0000000..26d5b24 --- /dev/null +++ b/test/wpt/tests/websockets/interfaces/WebSocket/constants/005.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>WebSockets: defineProperty getter for constants</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=../../../constants.sub.js></script> +<meta name="variant" content="?default"> +<meta name="variant" content="?wss"> +<div id=log></div> +<script> +var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; +for (var i = 0; i < constants.length; ++i) { + test(function() { + assert_throws_js(TypeError, function() { + Object.defineProperty(WebSocket.prototype, constants[i], { + get: function() { return 'foo'; } + }); + }); + }, "defineProperty getter " + constants[i]); +}; +</script> diff --git a/test/wpt/tests/websockets/interfaces/WebSocket/constants/006.html b/test/wpt/tests/websockets/interfaces/WebSocket/constants/006.html new file mode 100644 index 0000000..78126c8 --- /dev/null +++ b/test/wpt/tests/websockets/interfaces/WebSocket/constants/006.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>WebSockets: defineProperty setter for constants</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=../../../constants.sub.js></script> +<meta name="variant" content="?default"> +<meta name="variant" content="?wss"> +<div id=log></div> +<script> +var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; +for (var i = 0; i < constants.length; ++i) { + test(function() { + assert_throws_js(TypeError, function(){ + Object.defineProperty(WebSocket.prototype, constants[i], { + set: function() { return 'foo'; } + }); + }); + }, "defineProperty setter " + constants[i]) +}; +</script> |