Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,23 @@
<!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.js?pipe=sub></script>
<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();
})
});
</script>

View file

@ -0,0 +1,24 @@
<!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.js?pipe=sub></script>
<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();
});
});
</script>

View file

@ -0,0 +1,16 @@
<!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.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,18 @@
<!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.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,21 @@
<!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.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,51 @@
<!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.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,13 @@
<!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.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(){
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
assert_equals(ws.bufferedAmount, 0);
});
</script>

View file

@ -0,0 +1,25 @@
<!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.js?pipe=sub></script>
<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();
})
}, null, {timeout:20000});
</script>

View file

@ -0,0 +1,14 @@
<!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.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(){
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
ws.bufferedAmount = 5;
assert_equals(ws.bufferedAmount, 0);
});
</script>

View file

@ -0,0 +1,21 @@
<!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.js?pipe=sub></script>
<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();
});
});
</script>

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>WebSockets: close()</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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');
t.done();
});
ws.close();
assert_equals(ws.readyState, ws.CLOSING);
}, undefined, {timeout:9900});
</script>

View file

@ -0,0 +1,23 @@
<!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.js?pipe=sub></script>
<div id=log></div>
<script>
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/sleep_10_v13');
setTimeout(t.step_func(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.step_func(assert_unreached);
}, undefined, {timeout:12000});
</script>

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>WebSockets: close() several times</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
var i = 0;
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
ws.onclose = function(e) {
i++;
}
ws.close();
ws.close();
ws.close();
setTimeout(t.step_func(function() {
assert_equals(i, 1);
t.done()
}), 50);
});
</script>

View file

@ -0,0 +1,26 @@
<!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.js?pipe=sub></script>
<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);
}
setTimeout(t.step_func(function() {
assert_equals(i, 1);
t.done();
}), 50);
});
ws.close();
assert_equals(ws.readyState, ws.CLOSING);
}, undefined, {timeout:9900});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: replacing close</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function() {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
ws.close = 5;
assert_equals(ws.close, 5);
});
</script>

View file

@ -0,0 +1,12 @@
<!doctype html>
<title>WebSockets: close() return value</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function() {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
assert_equals(ws.close(), undefined);
});
</script>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: getting constants on constructor</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>WebSockets: setting constants</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,20 @@
<!doctype html>
<title>WebSockets: deleting constants</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,19 @@
<!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.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,18 @@
<!doctype html>
<title>WebSockets: defineProperty getter for constants</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
for (var i = 0; i < constants.length; ++i) {
test(function() {
assert_throws(new TypeError(), function() {
Object.defineProperty(WebSocket.prototype, constants[i], {
get: function() { return 'foo'; }
});
});
}, "defineProperty getter " + constants[i]);
};
</script>

View file

@ -0,0 +1,18 @@
<!doctype html>
<title>WebSockets: defineProperty setter for constants</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
for (var i = 0; i < constants.length; ++i) {
test(function() {
assert_throws(new TypeError(), function(){
Object.defineProperty(WebSocket.prototype, constants[i], {
set: function() { return 'foo'; }
});
});
}, "defineProperty setter " + constants[i])
};
</script>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: getting on*</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,17 @@
<!doctype html>
<title>WebSockets: setting on*</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,19 @@
<!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.js?pipe=sub></script>
<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);
}, null, {timeout:2000});
</script>

View file

@ -0,0 +1,14 @@
<!doctype html>
<title>WebSockets: members of EventTarget</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: 'on*' in ws</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,19 @@
<!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.js?pipe=sub></script>
<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);
}, null, {timeout:2000});
</script>

View file

@ -0,0 +1,22 @@
<!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.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,19 @@
<!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.js?pipe=sub></script>
<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);
}, null, {timeout:2000});
</script>

View file

@ -0,0 +1,19 @@
<!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.js?pipe=sub></script>
<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_AND_DOMAIN+'/');
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>

View file

@ -0,0 +1,16 @@
<!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.js?pipe=sub></script>
<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_AND_DOMAIN+'/');
ws[events[i]] = 1;
assert_equals(ws[events[i]], null);
}, events[i]);
};
</script>

View file

@ -0,0 +1,16 @@
<!doctype html>
<title>WebSockets: setting event handlers to ";"</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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_AND_DOMAIN+'/');
ws[events[i]] = ";";
assert_equals(ws[events[i]], null);
}, events[i]);
};
</script>

View file

@ -0,0 +1,16 @@
<!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.js?pipe=sub></script>
<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_AND_DOMAIN+'/');
ws[events[i]] = {handleEvent:function(){}};
assert_equals(ws[events[i]], null);
}, events[i]);
};
</script>

View file

@ -0,0 +1,19 @@
<!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.js?pipe=sub></script>
<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_AND_DOMAIN+'/');
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>

View file

@ -0,0 +1,31 @@
<!doctype html>
<title>WebSockets: instanceof on events</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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
ws.send('\\x81\\x04test\\x83\\x03LOL');
});
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>

View file

@ -0,0 +1,35 @@
<!doctype html>
<title>WebSockets: addEventListener</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,51 @@
<!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.js?pipe=sub></script>
<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
ws.send('\\x81\\x04test\\x83\\x03LOL');
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>

View file

@ -0,0 +1,35 @@
<!doctype html>
<title>WebSockets: toString(), bubbles, cancelable</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
ws.addEventListener('open', t.step_func(function(e) {
// first a text frame, then a frame with reserved opcode 3
// which should fail the connection
ws.send('\\x81\\x04test\\x83\\x03LOL');
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) {
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) {
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(function(e) {
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');
t.done();
}), false);
});
</script>

View file

@ -0,0 +1,29 @@
<!doctype html>
<title>WebSockets: removeEventListener</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: error events</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,12 @@
<!doctype html>
<title>WebSockets: getting extensions in connecting</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(t) {
// The extensions attribute must initially return the empty string
assert_equals((new WebSocket(SCHEME_AND_DOMAIN+'/')).extensions, '');
});
</script>

View file

@ -0,0 +1,12 @@
<!doctype html>
<title>WebSockets: getting protocol in connecting</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(t) {
// The protocol attribute must initially return the empty string
assert_equals((new WebSocket(SCHEME_AND_DOMAIN+'/')).protocol, '');
});
</script>

View file

@ -0,0 +1,11 @@
<!doctype html>
<title>WebSockets: getting readyState in connecting</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(t) {
assert_equals((new WebSocket(SCHEME_DOMAIN_PORT+'/')).readyState, WebSocket.CONNECTING);
});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: setting readyState</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: delete readyState</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(t) {
delete WebSocket.prototype.readyState;
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
ws.close();
delete ws.readyState;
assert_equals(ws.readyState, ws.CLOSING);
});
</script>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: defineProperty getter for readyState</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,17 @@
<!doctype html>
<title>WebSockets: defineProperty setter for readyState</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,17 @@
<!doctype html>
<title>WebSockets: getting readyState in open</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,17 @@
<!doctype html>
<title>WebSockets: getting readyState in closing</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,19 @@
<!doctype html>
<title>WebSockets: getting readyState in closed</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: send() with no args</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
assert_throws(new TypeError(), function(){ws.send()});
});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: replacing send</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function() {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
ws.send = 5;
assert_equals(ws.send, 5);
});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: send() when readyState is CONNECTING</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
assert_throws("INVALID_STATE_ERR", function(){ws.send('a')});
});
</script>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>WebSockets: send() with unpaired surrogate when readyState is CONNECTING</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
assert_throws("INVALID_STATE_ERR", function(){ws.send('a\uDC00x')});
}, "lone low surrogate");
test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
assert_throws("INVALID_STATE_ERR", function(){ws.send('a\uD800x')});
}, "lone high surrogate");
test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
assert_throws("INVALID_STATE_ERR", function(){ws.send('a\uDC00\uD800x')});
}, "surrogates in wrong order");
</script>

View file

@ -0,0 +1,16 @@
<!doctype html>
<title>WebSockets: send() return value</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>WebSockets: send() with unpaired surrogate when readyState is OPEN</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id="log"></div>
<script>
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
ws.onopen = t.step_func(function(e) {
// lone low surrogate, lone high surrogate + surrogates in wrong order.
ws.send('a\uDC00xb\uD800xc\uDC00\uD800x');
})
ws.onmessage = t.step_func(function(e) {
assert_equals(e.data, 'a\uFFFDxb\uFFFDxc\uFFFD\uFFFDx');
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(function() {t.done();}, 50);
});
ws.close();
})
});
</script>

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>WebSockets: close() followed by send()</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
ws.onopen = t.step_func(function(e) {
// test that nothing strange happens if we send something after close()
ws.close();
var sent = ws.send('test');
assert_equals(sent, undefined);
});
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(function() {t.done()}, 50);
});
ws.onerror = ws.onmessage = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>WebSockets: send() in onclose</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
ws.onopen = t.step_func(function(e) {
ws.send('Goodbye');
})
ws.onclose = t.step_func(function(e) {
// test that nothing strange happens when send()ing in closed state
var sent = ws.send('test');
assert_equals(sent, undefined);
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(function() {t.done()}, 50);
})
ws.onerror = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>WebSockets: send('')</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
async_test(function(t){
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
ws.onopen = t.step_func(function(e) {
ws.send('');
})
ws.onmessage = t.step_func(function(e) {
assert_equals(e.data, 'pass');
ws.close();
});
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(function() {t.done()}, 50);
});
ws.onerror = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,39 @@
<!doctype html>
<title>WebSockets: sending non-strings</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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 = function(e) {
sendNext();
}
}, "Constructor succeeds");
</script>

View file

@ -0,0 +1,25 @@
<!doctype html>
<title>WebSockets: sending non-ascii, combining chars and non-BMP</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
ws.onopen = t.step_func(function(e) {
ws.send('\u00E5 a\u030A \uD801\uDC7E');
});
ws.onmessage = t.step_func(function(e) {
assert_equals(e.data, '\u00E5 a\u030A \uD801\uDC7E');
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(function() {t.done()}, 50);
})
ws.close();
})
ws.onclose = ws.onerror = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,25 @@
<!doctype html>
<title>WebSockets: sending null</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
async_test(function(t){
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
ws.onopen = t.step_func(function(e) {
ws.send(null);
});
ws.onmessage = t.step_func(function(e) {
assert_equals(e.data, 'null');
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(function() {t.done()}, 50);
})
ws.close();
});
ws.onclose = ws.onerror = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,11 @@
<!doctype html>
<title>WebSockets: getting url</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function() {
assert_equals((new WebSocket(SCHEME_DOMAIN_PORT)).url, SCHEME_DOMAIN_PORT+'/');
});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: setting url</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: deleting url</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function() {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
delete ws.url;
assert_equals(ws.url, SCHEME_DOMAIN_PORT+'/');
});
</script>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: 'URL'</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>WebSockets: defineProperty getter for url</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>

View file

@ -0,0 +1,17 @@
<!doctype html>
<title>WebSockets: defineProperty setter for url</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.js?pipe=sub></script>
<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>