summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/websockets/interfaces
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/websockets/interfaces
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/websockets/interfaces')
-rw-r--r--testing/web-platform/tests/websockets/interfaces/CloseEvent/clean-close.html24
-rw-r--r--testing/web-platform/tests/websockets/interfaces/CloseEvent/constructor.html35
-rw-r--r--testing/web-platform/tests/websockets/interfaces/CloseEvent/historical.html12
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-arraybuffer.html27
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-blob.html28
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-getter.html18
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-setter.html20
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-deleting.html23
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-getting.html54
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-initial.html15
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large.html29
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-readonly.html16
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-unicode.html25
-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
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/constants/001.html17
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/constants/002.html24
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/constants/003.html22
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/constants/004.html21
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/constants/005.html20
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/constants/006.html20
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/001.html18
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/002.html20
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/003.html21
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/004.html16
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/006.html17
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/007.html22
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/008.html24
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/009.html21
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/010.html21
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/011.html18
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/012.html18
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/013.html20
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/014.html21
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/015.html36
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/016.html39
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/017.html56
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/018.html52
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/019.html31
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/events/020.html17
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/extensions/001.html14
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/protocol/protocol-initial.html14
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/001.html13
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/002.html15
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/003.html18
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/004.html17
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/005.html19
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/006.html19
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/007.html19
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/readyState/008.html21
-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.html19
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/006.html28
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/007.html27
-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.html27
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/010.html42
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/011.html28
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/send/012.html28
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/url/001.html13
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/url/002.html15
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/url/003.html17
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/url/004.html17
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/url/005.html17
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/url/006.html19
-rw-r--r--testing/web-platform/tests/websockets/interfaces/WebSocket/url/resolve.html14
73 files changed, 1650 insertions, 0 deletions
diff --git a/testing/web-platform/tests/websockets/interfaces/CloseEvent/clean-close.html b/testing/web-platform/tests/websockets/interfaces/CloseEvent/clean-close.html
new file mode 100644
index 0000000000..db253761f6
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/CloseEvent/clean-close.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<title>WebSockets: wasClean, true</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">
+<meta name="variant" content="?wpt_flags=h2">
+<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('Test');
+ });
+ ws.onmessage = t.step_func(function(e) {
+ ws.close();
+ });
+ ws.onclose = t.step_func(function(e) {
+ assert_equals(e.wasClean,true);
+ t.done();
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/CloseEvent/constructor.html b/testing/web-platform/tests/websockets/interfaces/CloseEvent/constructor.html
new file mode 100644
index 0000000000..1ed86bdf8f
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/CloseEvent/constructor.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>CloseEvent: constructor</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var event = new CloseEvent("foo");
+ assert_true(event instanceof CloseEvent, "should be a CloseEvent");
+ assert_equals(event.type, "foo");
+ assert_false(event.bubbles, "bubbles");
+ assert_false(event.cancelable, "cancelable");
+ assert_false(event.wasClean, "wasClean");
+ assert_equals(event.code, 0);
+ assert_equals(event.reason, "");
+}, "new CloseEvent() without dictionary");
+
+test(function() {
+ var event = new CloseEvent("foo", {
+ bubbles: true,
+ cancelable: true,
+ wasClean: true,
+ code: 7,
+ reason: "x",
+ });
+ assert_true(event instanceof CloseEvent, "should be a CloseEvent");
+ assert_equals(event.type, "foo");
+ assert_true(event.bubbles, "bubbles");
+ assert_true(event.cancelable, "cancelable");
+ assert_true(event.wasClean, "wasClean");
+ assert_equals(event.code, 7);
+ assert_equals(event.reason, "x");
+}, "new CloseEvent() with dictionary");
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/CloseEvent/historical.html b/testing/web-platform/tests/websockets/interfaces/CloseEvent/historical.html
new file mode 100644
index 0000000000..24528a86fb
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/CloseEvent/historical.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>CloseEvent: historical initialization</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ assert_false("initCloseEvent" in CloseEvent.prototype);
+ assert_false("initCloseEvent" in new CloseEvent('close'));
+}, "initCloseEvent");
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-arraybuffer.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-arraybuffer.html
new file mode 100644
index 0000000000..258eaa7827
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-arraybuffer.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: bufferedAmount for ArrayBuffer</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ var datasize = 10;
+ ws.onopen = t.step_func(function(e) {
+ ws.binaryType = "arraybuffer";
+ var data = new ArrayBuffer(datasize);
+ ws.send(data);
+ assert_equals(ws.bufferedAmount, data.byteLength);
+ })
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data.byteLength, datasize);
+ t.done();
+ })
+ ws.onclose = t.unreached_func('close event should not fire');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-blob.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-blob.html
new file mode 100644
index 0000000000..ac5140de6c
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-blob.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: bufferedAmount for blob</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ var datasize = 10;
+ ws.onopen = t.step_func(function(e) {
+ ws.binaryType = "blob";
+ var data = new ArrayBuffer(datasize);
+ ws.send(data);
+ assert_equals(ws.bufferedAmount, data.byteLength);
+ });
+ ws.onmessage = t.step_func(function(e) {
+ assert_true(e.data instanceof Blob);
+ assert_equals(e.data.size, datasize);
+ t.done();
+ });
+ ws.onclose = t.unreached_func('close event should not fire');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-getter.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-getter.html
new file mode 100644
index 0000000000..df1c3a5bb2
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-getter.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: defineProperty getter for bufferedAmount</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(){
+ Object.defineProperty(WebSocket.prototype, 'bufferedAmount', {
+ get: function() { return 'foo'; }
+ });
+ var ws = new WebSocket('ws://example.invalid/');
+ assert_equals(ws.bufferedAmount, 'foo');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-setter.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-setter.html
new file mode 100644
index 0000000000..b65ed9e9b7
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-defineProperty-setter.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: defineProperty setter for bufferedAmount</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() {
+ window.setter_ran = false;
+ Object.defineProperty(WebSocket.prototype, 'bufferedAmount', {
+ set: function(v) { window[v] = true; }
+ });
+ var ws = new WebSocket('ws://example.invalid/');
+ ws.bufferedAmount = 'setter_ran';
+ assert_true(setter_ran);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-deleting.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-deleting.html
new file mode 100644
index 0000000000..0d8c456e5c
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-deleting.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: delete bufferedAmount</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+'/echo');
+ assert_equals(ws.bufferedAmount, 0, 'after creation');
+ ws.close();
+ delete ws.bufferedAmount;
+ assert_equals(ws.bufferedAmount, 0,
+ 'after attempt to delete ws.bufferedAmount');
+ delete WebSocket.prototype.bufferedAmount;
+ assert_equals(ws.bufferedAmount, undefined,
+ 'after attempt to delete WebSocket.prototype.bufferedAmount');
+});
+</script>
+
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-getting.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-getting.html
new file mode 100644
index 0000000000..307f595ec2
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-getting.html
@@ -0,0 +1,54 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: bufferedAmount after send()ing</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t){
+ // bufferedAmount should increase sync in the send() method and decrease between
+ // events in the event loop (so never while script is running).
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.onopen = t.step_func(function(e) {
+ ws.send('x');
+ assert_equals(ws.bufferedAmount, 1, 'bufferedAmount after sent "x"');
+ ws.send('\u00E5');
+ assert_equals(ws.bufferedAmount, 1+2, 'bufferedAmount after sent "x", "\u00E5"');
+ ws.send('\u5336');
+ assert_equals(ws.bufferedAmount, 1+2+3, 'bufferedAmount after sent "x", "\u00E5", "\u5336"');
+ ws.send('\uD801\uDC7E');
+ assert_equals(ws.bufferedAmount, 1+2+3+4, 'bufferedAmount after sent "x", "\u00E5", "\u5336", "\uD801\uDC7E"');
+ })
+ var i = 0;
+ ws.onmessage = t.step_func(function(e) {
+ i++;
+ switch(i) {
+ case 1:
+ assert_equals(e.data, 'x');
+ assert_true(ws.bufferedAmount < 2+3+4 + 1, 'bufferedAmount after received "x"');
+ break;
+ case 2:
+ assert_equals(e.data, '\u00E5');
+ assert_true(ws.bufferedAmount < 3+4 + 1, 'bufferedAmount after received "x", "\u00E5"');
+ break;
+ case 3:
+ assert_equals(e.data, '\u5336');
+ assert_true(ws.bufferedAmount < 4 + 1, 'bufferedAmount after received "x", "\u00E5", "\u5336"');
+ break;
+ case 4:
+ assert_equals(e.data, '\uD801\uDC7E');
+ assert_equals(ws.bufferedAmount, 0, 'bufferedAmount after received "x", "\u00E5", "\u5336", "\uD801\uDC7E"');
+ t.done();
+ break;
+ default:
+ assert_unreached(i);
+ }
+ })
+ ws.onerror = ws.onclose = t.step_func(function() {assert_unreached()});
+});
+</script>
+
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-initial.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-initial.html
new file mode 100644
index 0000000000..7c66d20282
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-initial.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: getting bufferedAmount</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.bufferedAmount, 0);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large.html
new file mode 100644
index 0000000000..e599614103
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: bufferedAmount for 65K data</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ var data = "";
+ ws.onopen = t.step_func(function(e) {
+ for (var i = 0; i < 65000; i++) {
+ data = data + "x";
+ }
+ ws.send(data);
+ assert_equals(data.length, ws.bufferedAmount);
+ });
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, data);
+ t.done();
+ })
+ ws.onclose = t.unreached_func('close event should not fire');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-readonly.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-readonly.html
new file mode 100644
index 0000000000..951aaea57b
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-readonly.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: setting bufferedAmount</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.bufferedAmount = 5;
+ assert_equals(ws.bufferedAmount, 0);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-unicode.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-unicode.html
new file mode 100644
index 0000000000..ba25caeb22
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-unicode.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>WebSockets: bufferedAmount for unicode data</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ var data = "¥¥¥¥¥¥";
+ ws.onopen = t.step_func(function(e) {
+ ws.send(data);
+ assert_equals(data.length * 2, ws.bufferedAmount);
+ });
+ ws.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, data);
+ t.done();
+ });
+ ws.onclose = t.unreached_func('close event should not fire');
+});
+</script>
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>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/001.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/001.html
new file mode 100644
index 0000000000..9701047662
--- /dev/null
+++ b/testing/web-platform/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="">
+<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/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/002.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/002.html
new file mode 100644
index 0000000000..46ad3b1fb1
--- /dev/null
+++ b/testing/web-platform/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="">
+<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/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/003.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/003.html
new file mode 100644
index 0000000000..01127e0235
--- /dev/null
+++ b/testing/web-platform/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="">
+<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/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/004.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/004.html
new file mode 100644
index 0000000000..035e099b65
--- /dev/null
+++ b/testing/web-platform/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="">
+<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/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/005.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/005.html
new file mode 100644
index 0000000000..8e3de05a60
--- /dev/null
+++ b/testing/web-platform/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="">
+<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/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/006.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/006.html
new file mode 100644
index 0000000000..9dcd194159
--- /dev/null
+++ b/testing/web-platform/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="">
+<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>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/001.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/001.html
new file mode 100644
index 0000000000..2043f0dd84
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/001.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>WebSockets: getting on*</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+var events = ['open', 'message', 'error', 'close'];
+for (var i = 0; i < events.length; ++i) {
+ test(function(){
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_equals(ws['on'+events[i]], null, 'on'+events[i]);
+ });
+};
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/002.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/002.html
new file mode 100644
index 0000000000..df8e9f73d5
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/002.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>WebSockets: setting on*</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+var events = ['open', 'message', 'error', 'close'];
+for (var i = 0; i < events.length; ++i) {
+ test(function(){
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ var foo = function () {};
+ ws['on'+events[i]] = foo;
+ assert_equals(ws['on'+events[i]], foo);
+ });
+}
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/003.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/003.html
new file mode 100644
index 0000000000..f03ab49be6
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/003.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>WebSockets: listening for events with onopen</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 foo = t.step_func(function (e) {
+ if (e.detail == 5)
+ t.done();
+ })
+ ws.onopen = foo;
+ var ev = document.createEvent('UIEvents');
+ ev.initUIEvent('open', false, false, window, 5);
+ ws.dispatchEvent(ev);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/004.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/004.html
new file mode 100644
index 0000000000..f3698263ed
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/004.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>WebSockets: members of EventTarget</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(typeof ws.addEventListener, 'function');
+ assert_equals(typeof ws.removeEventListener, 'function');
+ assert_equals(typeof ws.dispatchEvent, 'function');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/006.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/006.html
new file mode 100644
index 0000000000..76930516c8
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/006.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>WebSockets: 'on*' in ws</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('onopen' in ws, true, 'onopen');
+ assert_equals('onmessage' in ws, true, 'onmessage');
+ assert_equals('onerror' in ws, true, 'onerror');
+ assert_equals('onclose' in ws, true, 'onclose');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/007.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/007.html
new file mode 100644
index 0000000000..c009f48a97
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/007.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>WebSockets: listening for events with onmessage</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ var foo = t.step_func(function (e) {
+ if (e.detail == 5)
+ t.done();
+ })
+ ws.onmessage = foo;
+ var ev = document.createEvent('UIEvents');
+ ev.initUIEvent('message', false, false, window, 5);
+ ws.dispatchEvent(ev);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/008.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/008.html
new file mode 100644
index 0000000000..eb46efbb1a
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/008.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<title>WebSockets: listening for events with onerror</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 run = false;
+ var foo = t.step_func(function (e) {
+ run = true;
+ assert_equals(e.detail, 5)
+ });
+ ws.onerror = foo;
+ var ev = document.createEvent('UIEvents');
+ ev.initUIEvent('error', false, false, window, 5);
+ ws.dispatchEvent(ev);
+ assert_true(run);
+ t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/009.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/009.html
new file mode 100644
index 0000000000..1194fb8b09
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/009.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>WebSockets: listening for events with onclose</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 foo = t.step_func(function (e) {
+ if (e.detail == 5)
+ t.done();
+ });
+ ws.onclose = foo;
+ var ev = document.createEvent('UIEvents');
+ ev.initUIEvent('close', false, false, window, 5);
+ ws.dispatchEvent(ev);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/010.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/010.html
new file mode 100644
index 0000000000..ccdbc4dbf9
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/010.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>WebSockets: setting event handlers to undefined</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 events = ['onclose', 'onopen', 'onerror', 'onmessage'];
+for (var i = 0; i < events.length; ++i) {
+ test(function(){
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
+ var foo = function() {}
+ ws[events[i]] = foo;
+ assert_equals(ws[events[i]], foo, events[i]);
+ ws[events[i]] = undefined;
+ assert_equals(ws[events[i]], null, events[i]);
+ });
+}
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/011.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/011.html
new file mode 100644
index 0000000000..4bb0ef391c
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/011.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>WebSockets: setting event handlers to 1</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 events = ['onclose', 'onopen', 'onerror', 'onmessage'];
+for (var i = 0; i < events.length; ++i) {
+ test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
+ ws[events[i]] = 1;
+ assert_equals(ws[events[i]], null);
+ }, events[i]);
+};
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/012.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/012.html
new file mode 100644
index 0000000000..d2f39194fd
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/012.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>WebSockets: setting event handlers to ";"</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 events = ['onclose', 'onopen', 'onerror', 'onmessage'];
+for (var i = 0; i < events.length; ++i) {
+ test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
+ ws[events[i]] = ";";
+ assert_equals(ws[events[i]], null);
+ }, events[i]);
+};
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/013.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/013.html
new file mode 100644
index 0000000000..121f6e6c30
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/013.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>WebSockets: setting event handlers to {handleEvent:function(){}}</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 events = ['onclose', 'onopen', 'onerror', 'onmessage'];
+for (var i = 0; i < events.length; ++i) {
+ test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
+ var obj = {handleEvent:this.unreached_func("handleEvent was called")};
+ ws[events[i]] = obj;
+ assert_equals(ws[events[i]], obj);
+ ws.dispatchEvent(new Event(events[i].substr(2)));
+ }, events[i]);
+};
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/014.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/014.html
new file mode 100644
index 0000000000..a427ce98c5
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/014.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>WebSockets: setting event handlers to null</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 events = ['onclose', 'onopen', 'onerror', 'onmessage'];
+for (var i = 0; i < events.length; ++i) {
+ test(function() {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
+ var foo = function() {}
+ ws[events[i]] = foo;
+ assert_equals(ws[events[i]], foo, events[i]);
+ ws[events[i]] = null;
+ assert_equals(ws[events[i]], null, events[i]);
+ }, "Setting event handlers to null " + events[i]);
+};
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/015.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/015.html
new file mode 100644
index 0000000000..663ccca80d
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/015.html
@@ -0,0 +1,36 @@
+<!doctype html>
+<title>WebSockets: instanceof on events</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
+ ws.onopen = t.step_func(function(e) {
+ assert_true(e instanceof Event);
+ // first a text frame, then a frame with reserved opcode 3
+ // which should fail the connection
+
+ // send '\\x81\\x04test\\x83\\x03LOL' in bytes
+ ws.send(new Uint8Array([129, 4, 116, 101, 115, 116, 131, 3, 76, 79, 76]));
+ });
+ ws.onmessage = t.step_func(function(e) {
+ assert_true(e instanceof Event);
+ assert_true(e instanceof MessageEvent);
+ assert_equals(ws.readyState, ws.OPEN);
+ })
+ ws.onerror = t.step_func(function(e) {
+ assert_true(e instanceof Event);
+ assert_equals(ws.readyState, ws.CLOSED);
+ })
+ ws.onclose = t.step_func(function(e) {
+ assert_true(e instanceof Event);
+ assert_true(e instanceof CloseEvent);
+ t.done();
+ })
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/016.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/016.html
new file mode 100644
index 0000000000..fcd14c854c
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/016.html
@@ -0,0 +1,39 @@
+<!doctype html>
+<title>WebSockets: addEventListener</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ var count = 0;
+ var checkCount = t.step_func(function (c, e) {
+ count++;
+ assert_equals(count, c);
+ });
+ // no spec requires this order for event listeners but the web does
+ ws.addEventListener('open', t.step_func(function(e) {
+ checkCount(1, e);
+ ws.send('Goodbye');
+ }), false);
+ ws.onopen = t.step_func(function(e) {checkCount(2, e) });
+ ws.addEventListener('open', t.step_func(function(e) {checkCount(3, e); }), false);
+
+ ws.addEventListener('message', t.step_func(function(e) {checkCount(4, e); }), false);
+ ws.onmessage = t.step_func(function(e) {checkCount(5, e) });
+ ws.addEventListener('message', t.step_func(function(e) {checkCount(6, e); }), false);
+
+ ws.addEventListener('close', t.step_func(function(e) {checkCount(7, e); }), false);
+ ws.onclose = t.step_func(function(e) {checkCount(8, e) });
+ ws.addEventListener('close', t.step_func(function(e) {
+ checkCount(9, e);
+ t.done();
+ }), false);
+
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/017.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/017.html
new file mode 100644
index 0000000000..9208261c12
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/017.html
@@ -0,0 +1,56 @@
+<!doctype html>
+<title>WebSockets: this, e.target, e.currentTarget, e.eventPhase</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
+ ws.addEventListener('open', function(e) {
+ var this_val = this;
+ t.step(function() {
+ // first a text frame, then a frame with reserved opcode 3
+ // which should fail the connection
+
+ // send '\\x81\\x04test\\x83\\x03LOL' in bytes
+ ws.send(new Uint8Array([129, 4, 116, 101, 115, 116, 131, 3, 76, 79, 76]));
+ assert_equals(this_val, ws);
+ assert_equals(e.target, ws);
+ assert_equals(e.currentTarget, ws);
+ assert_equals(e.eventPhase, 2);
+ });
+ }, false);
+ ws.addEventListener('message', function(e) {
+ var this_val = this;
+ t.step(function() {
+ assert_equals(this_val, ws);
+ assert_equals(e.target, ws);
+ assert_equals(e.currentTarget, ws);
+ assert_equals(e.eventPhase, 2);
+ });
+ }, false);
+ ws.addEventListener('error', function(e) {
+ var this_val = this;
+ t.step(function() {
+ assert_equals(this_val, ws);
+ assert_equals(e.target, ws);
+ assert_equals(e.currentTarget, ws);
+ assert_equals(e.eventPhase, 2);
+ });
+ }, false);
+ ws.addEventListener('close', function(e) {
+ var this_val = this;
+ t.step(function() {
+ assert_equals(this_val, ws);
+ assert_equals(e.target, ws);
+ assert_equals(e.currentTarget, ws);
+ assert_equals(e.eventPhase, 2);
+ t.done();
+ });
+ }, false);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/018.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/018.html
new file mode 100644
index 0000000000..3dc36d0c5f
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/018.html
@@ -0,0 +1,52 @@
+<!doctype html>
+<title>WebSockets: toString(), bubbles, cancelable</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">
+<meta name="variant" content="?wpt_flags=h2">
+<div id=log></div>
+<script>
+var ws = null;
+setup(function() {
+ ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
+});
+
+async_test(function(t) {
+ let openFired = false;
+ let messageFired = false;
+ let errorFired = false;
+ ws.addEventListener('open', t.step_func(function(e) {
+ openFired = true;
+ // first a text frame, then a frame with reserved opcode 3
+ // which should fail the connection
+
+ // send '\\x81\\x04test\\x83\\x03LOL' in bytes
+ ws.send(new Uint8Array([129, 4, 116, 101, 115, 116, 131, 3, 76, 79, 76]));
+ assert_equals(e.toString(), '[object Event]', "open e.toString()");
+ assert_equals(e.bubbles, false, 'open e.bubbles');
+ assert_equals(e.cancelable, false, 'open e.cancelable');
+ }), false);
+ ws.addEventListener('message', t.step_func(function(e) {
+ messageFired = true;
+ assert_equals(e.toString(), '[object MessageEvent]', "message e.toString()");
+ assert_equals(e.bubbles, false, 'message e.bubbles');
+ assert_equals(e.cancelable, false, 'message e.cancelable');
+ }), false);
+ ws.addEventListener('error', t.step_func(function(e) {
+ errorFired = true;
+ assert_equals(e.toString(), '[object Event]', "error e.toString()");
+ assert_equals(e.bubbles, false, 'error e.bubbles');
+ assert_equals(e.cancelable, false, 'error e.cancelable');
+ }), false);
+ ws.addEventListener('close', t.step_func_done(function(e) {
+ assert_true(openFired, 'open event should fire');
+ assert_true(messageFired, 'message event should fire');
+ assert_true(errorFired, 'error event should fire');
+ assert_equals(e.toString(), '[object CloseEvent]', "close e.toString()");
+ assert_equals(e.bubbles, false, 'close e.bubbles');
+ assert_equals(e.cancelable, false, 'close e.cancelable');
+ }), false);
+}, "open, message, error and close events");
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/019.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/019.html
new file mode 100644
index 0000000000..cbc271d9e6
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/019.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<title>WebSockets: removeEventListener</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 events = ['open', 'message', 'error', 'close'];
+for (var i = 0; i < events.length; ++i) {
+ test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
+ ws.close();
+ var got = [];
+ var event;
+ function addThis(e) {
+ got.push(e.type);
+ }
+ ws.addEventListener(events[i], addThis, false);
+ ws.removeEventListener(events[i], addThis, false);
+ event = document.createEvent('Event');
+ event.initEvent(events[i], false, false);
+ ws.dispatchEvent(event);
+ assert_equals(got.length, 0);
+ if (got.length) {
+ debug('Got: '+got);
+ }
+ })
+};
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/events/020.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/020.html
new file mode 100644
index 0000000000..34c1f35312
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/events/020.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>WebSockets: error events</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('ws://example.invalid/');
+ ws.onerror = t.step_func(function(e) {
+ assert_true(e instanceof Event);
+ t.done();
+ })
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/extensions/001.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/extensions/001.html
new file mode 100644
index 0000000000..4f86da57b8
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/extensions/001.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>WebSockets: getting extensions in connecting</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(t) {
+ // The extensions attribute must initially return the empty string
+ assert_equals((new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message')).extensions, '');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/protocol/protocol-initial.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/protocol/protocol-initial.html
new file mode 100644
index 0000000000..33c123abac
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/protocol/protocol-initial.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>WebSockets: getting protocol in connecting</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(t) {
+ // The protocol attribute must initially return the empty string
+ assert_equals((new WebSocket(SCHEME_DOMAIN_PORT + '/empty-message')).protocol, '');
+});
+</script>
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 0000000000..b8f96740ca
--- /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.sub.js></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 0000000000..b86e128059
--- /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.sub.js></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 0000000000..0143480721
--- /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.sub.js></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 0000000000..7864f0e853
--- /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.sub.js></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 0000000000..c42939316a
--- /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.sub.js></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 0000000000..993655abd9
--- /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.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+'/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 0000000000..f9ab27a405
--- /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.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+'/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 0000000000..5dcd362ce9
--- /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.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+'/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>
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 0000000000..e99ce7722f
--- /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.sub.js></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_js(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 0000000000..8a384df32d
--- /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.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.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 0000000000..d5aa6c5766
--- /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.sub.js></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_dom("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 0000000000..63fd83a7e9
--- /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.sub.js></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_dom("INVALID_STATE_ERR", function(){ws.send('a\uDC00x')});
+}, "lone low surrogate");
+
+test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_throws_dom("INVALID_STATE_ERR", function(){ws.send('a\uD800x')});
+}, "lone high surrogate");
+
+test(function(t) {
+ var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
+ assert_throws_dom("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 0000000000..ddba5bf4a3
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/005.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>WebSockets: send() return value</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+'/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 0000000000..a7c00b154f
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/006.html
@@ -0,0 +1,28 @@
+<!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.sub.js></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<meta name="variant" content="?wpt_flags=h2">
+<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.unreached_func();
+ t.step_timeout(() => t.done(), 50);
+ });
+ ws.close();
+ })
+ // This will be overridden if the message event fires.
+ ws.onclose = t.unreached_func('close event should not fire before message event');
+ });
+</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 0000000000..e2a8999e2f
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/007.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<title>WebSockets: close() followed by send()</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">
+<meta name="variant" content="?wpt_flags=h2">
+<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.unreached_func();
+ t.step_timeout(() => t.done(), 50);
+ });
+ ws.onerror = ws.onmessage = t.unreached_func();
+});
+</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 0000000000..7b6125b8c8
--- /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.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+'/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.unreached_func();
+ t.step_timeout(() => t.done(), 50);
+ })
+ ws.onerror = t.unreached_func();
+});
+</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 0000000000..65d9270ecb
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/009.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<title>WebSockets: send('')</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">
+<meta name="variant" content="?wpt_flags=h2">
+<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.unreached_func();
+ t.step_timeout(() => t.done(), 50);
+ });
+ ws.onerror = t.unreached_func();
+});
+</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 0000000000..4e4f5c57b8
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/010.html
@@ -0,0 +1,42 @@
+<!doctype html>
+<title>WebSockets: sending non-strings</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(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 0000000000..bcf0422a31
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/011.html
@@ -0,0 +1,28 @@
+<!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.sub.js></script>
+<meta name="variant" content="">
+<meta name="variant" content="?wss">
+<meta name="variant" content="?wpt_flags=h2">
+<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.unreached_func();
+ t.step_timeout(() => t.done(), 50);
+ })
+ ws.close();
+ })
+ ws.onclose = ws.onerror = t.unreached_func();
+});
+</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 0000000000..058ab9f621
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/send/012.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<title>WebSockets: sending null</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">
+<meta name="variant" content="?wpt_flags=h2">
+<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.unreached_func();
+ t.step_timeout(() => t.done(), 50);
+ })
+ ws.close();
+ });
+ ws.onclose = ws.onerror = t.unreached_func();
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/url/001.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/001.html
new file mode 100644
index 0000000000..76f68b9093
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/001.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>WebSockets: getting url</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() {
+ assert_equals((new WebSocket(SCHEME_DOMAIN_PORT)).url, SCHEME_DOMAIN_PORT+'/');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/url/002.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/002.html
new file mode 100644
index 0000000000..b7e74eecea
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/002.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>WebSockets: setting url</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.url = SCHEME_DOMAIN_PORT+'/test';
+ assert_equals(ws.url, SCHEME_DOMAIN_PORT+'/');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/url/003.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/003.html
new file mode 100644
index 0000000000..5a98b50f55
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/003.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>WebSockets: deleting url</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+'/');
+ delete ws.url;
+ assert_equals(ws.url, SCHEME_DOMAIN_PORT+'/', 'delete ws.url');
+ delete WebSocket.prototype.url;
+ assert_equals(ws.url, undefined, 'delete WebSocket.prototype.url');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/url/004.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/004.html
new file mode 100644
index 0000000000..a3c90c73d9
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/004.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>WebSockets: 'URL'</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.URL, undefined);
+ assert_equals('URL' in ws, false);
+ assert_equals(WebSocket.prototype.URL, undefined);
+ assert_equals('URL' in WebSocket.prototype, false);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/url/005.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/005.html
new file mode 100644
index 0000000000..f897b88de0
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/005.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>WebSockets: defineProperty getter for url</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() {
+ Object.defineProperty(WebSocket.prototype, 'url', {
+ get: function() { return 'foo'; }
+ });
+ var ws = new WebSocket('ws://example.invalid/');
+ assert_equals(ws.url, 'foo');
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/url/006.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/006.html
new file mode 100644
index 0000000000..8c4e29aa83
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/006.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>WebSockets: defineProperty setter for url</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() {
+ window.setter_ran = false;
+ Object.defineProperty(WebSocket.prototype, 'url', {
+ set: function(v) { window[v] = true; }
+ });
+ var ws = new WebSocket('ws://example.invalid/');
+ ws.url = 'setter_ran';
+ assert_true(setter_ran);
+});
+</script>
diff --git a/testing/web-platform/tests/websockets/interfaces/WebSocket/url/resolve.html b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/resolve.html
new file mode 100644
index 0000000000..0526872d56
--- /dev/null
+++ b/testing/web-platform/tests/websockets/interfaces/WebSocket/url/resolve.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>WebSocket#url: resolving</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 + '/echo?foo%20bar baz');
+ assert_equals(ws.url, SCHEME_DOMAIN_PORT + '/echo?foo%20bar%20baz');
+});
+</script>