Auto merge of #6358 - Ms2ger:ws-tests, r=jgraham

Second try.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6358)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-06-15 11:42:16 -06:00
commit f8e3f92813
22 changed files with 546 additions and 41 deletions

View file

@ -1,3 +1,485 @@
[004.html]
type: testharness
expected: CRASH
[WebSockets: new WebSocket(url, invalid protocol)]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 1]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 2]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 3]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 4]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 5]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 6]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 7]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 8]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 9]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 10]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 11]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 12]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 13]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 14]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 15]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 16]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 17]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 18]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 19]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 20]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 21]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 22]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 23]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 24]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 25]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 26]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 27]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 28]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 29]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 30]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 31]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 32]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 33]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 34]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 35]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 36]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 37]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 38]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 39]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 40]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 41]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 42]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 43]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 44]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 45]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 46]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 47]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 48]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 49]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 50]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 51]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 52]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 53]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 54]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 55]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 56]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 57]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 58]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 59]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 60]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 61]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 62]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 63]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 64]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 65]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 66]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 67]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 68]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 69]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 70]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 71]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 72]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 73]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 74]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 75]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 76]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 77]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 78]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 79]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 80]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 81]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 82]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 83]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 84]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 85]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 86]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 87]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 88]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 89]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 90]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 91]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 92]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 93]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 94]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 95]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 96]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 97]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 98]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 99]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 100]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 101]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 102]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 103]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 104]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 105]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 106]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 107]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 108]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 109]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 110]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 111]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 112]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 113]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 114]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 115]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 116]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 117]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 118]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 119]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 120]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 121]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 122]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 123]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 124]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 125]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 126]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 127]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 128]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 129]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 130]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 131]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 132]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 133]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 134]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 135]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 136]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 137]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 138]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 139]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 140]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 141]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 142]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 143]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 144]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 145]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 146]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 147]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 148]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 149]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 150]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 151]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 152]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 153]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 154]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 155]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 156]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 157]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 158]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 159]
expected: FAIL
[WebSockets: new WebSocket(url, invalid protocol) 160]
expected: FAIL

View file

@ -1,3 +0,0 @@
[005.html]
type: testharness
expected: CRASH

View file

@ -1,3 +1,5 @@
[007.html]
type: testharness
expected: CRASH
[WebSockets: new WebSocket(url, null char)]
expected: FAIL

View file

@ -1,3 +1,5 @@
[010.html]
type: testharness
expected: CRASH
[WebSockets: setting event handlers to undefined 3]
expected: FAIL

View file

@ -1,3 +1,5 @@
[011.html]
type: testharness
expected: CRASH
[onmessage]
expected: FAIL

View file

@ -1,3 +1,5 @@
[012.html]
type: testharness
expected: CRASH
[onmessage]
expected: FAIL

View file

@ -1,3 +1,11 @@
[013.html]
type: testharness
expected: CRASH
[onclose]
expected: FAIL
[onopen]
expected: FAIL
[onerror]
expected: FAIL

View file

@ -1,3 +0,0 @@
[014.html]
type: testharness
expected: CRASH

View file

@ -1,3 +1,5 @@
[001.html]
type: testharness
expected: CRASH
[WebSockets: getting extensions in connecting]
expected: FAIL

View file

@ -1,3 +1,5 @@
[protocol-initial.html]
type: testharness
expected: CRASH
[WebSockets: getting protocol in connecting]
expected: FAIL

View file

@ -1,18 +1,12 @@
//This file requires server-side substitutions and must be included as constants.js?pipe=config
var DOMAIN_FOR_WS_TESTS = "{{host}}";
var DOMAIN_FOR_WSS_TESTS = "{{host}}";
//This file requires server-side substitutions and must be included as constants.js?pipe=sub
var PORT = "{{ports[ws][0]}}";
//FIXME: Add support for wss
var PORT_SSL = "{{ports[ws][0]}}";
// logic for using wss URLs instead of ws
var SCHEME_AND_DOMAIN;
var SCHEME_DOMAIN_PORT;
if (location.search == '?wss') {
SCHEME_AND_DOMAIN = 'wss://'+DOMAIN_FOR_WSS_TESTS;
SCHEME_DOMAIN_PORT = SCHEME_AND_DOMAIN + ":" + PORT_SSL;
SCHEME_DOMAIN_PORT = 'wss://{{host}}:' + PORT_SSL;
} else {
SCHEME_AND_DOMAIN = 'ws://'+DOMAIN_FOR_WS_TESTS;
SCHEME_DOMAIN_PORT = SCHEME_AND_DOMAIN + ":" + PORT;
SCHEME_DOMAIN_PORT = 'ws://{{host}}:' + PORT;
}

View file

@ -11,8 +11,8 @@ test(function() {assert_throws("SyntaxError", function(){new WebSocket("wss://fo
test(function() {assert_throws("SyntaxError", function(){new WebSocket("http://"+location.host+"/")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("mailto:example@example.org")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("about:blank")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/#")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/#test")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket(SCHEME_DOMAIN_PORT+"/#")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket(SCHEME_DOMAIN_PORT+"/#test")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("?test")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("#test")})});
</script>

View file

@ -6,18 +6,28 @@
<div id=log></div>
<script>
// empty string
test(function() {assert_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/", "")})});
test(function() {
assert_throws("SyntaxError", function() {
new WebSocket(SCHEME_DOMAIN_PORT + '/empty-message', "")
})
});
// chars below U+0020 except U+0000; U+0000 is tested in a separate test
for (var i = 1; i < 0x20; ++i) {
test(function() {
assert_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/", "a"+String.fromCharCode(i)+"b")}, 'char code '+i);
})
test(function() {
assert_throws("SyntaxError", function() {
new WebSocket(SCHEME_DOMAIN_PORT + '/empty-message',
"a"+String.fromCharCode(i)+"b")
}, 'char code '+i);
})
}
// some chars above U+007E
for (var i = 0x7F; i < 0x100; ++i) {
test(function() {
assert_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/", "a"+String.fromCharCode(i)+"b")}, 'char code '+i);
})
test(function() {
assert_throws("SyntaxError", function() {
new WebSocket(SCHEME_DOMAIN_PORT + '/empty-message',
"a"+String.fromCharCode(i)+"b")
}, 'char code '+i);
})
}
</script>

View file

@ -6,6 +6,6 @@
<div id=log></div>
<script>
test(function() {
assert_true(new WebSocket("ws://"+location.host+"/") instanceof WebSocket);
assert_true(new WebSocket(SCHEME_DOMAIN_PORT + '/empty-message') instanceof WebSocket);
});
</script>

View file

@ -5,5 +5,10 @@
<script src=../constants.js?pipe=sub></script>
<div id=log></div>
<script>
test(function() {assert_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/", 'a'+String.fromCharCode(0)+'b')})});
test(function() {
assert_throws("SyntaxError", function() {
new WebSocket(SCHEME_DOMAIN_PORT + '/empty-message',
'a' + String.fromCharCode(0) + 'b')
})
});
</script>

View file

@ -8,7 +8,7 @@
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
for (var i = 0; i < events.length; ++i) {
test(function(){
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
var foo = function() {}
ws[events[i]] = foo;
assert_equals(ws[events[i]], foo, events[i]);

View file

@ -8,7 +8,7 @@
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
for (var i = 0; i < events.length; ++i) {
test(function(t) {
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
ws[events[i]] = 1;
assert_equals(ws[events[i]], null);
}, events[i]);

View file

@ -8,7 +8,7 @@
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
for (var i = 0; i < events.length; ++i) {
test(function(t) {
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
ws[events[i]] = ";";
assert_equals(ws[events[i]], null);
}, events[i]);

View file

@ -8,7 +8,7 @@
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
for (var i = 0; i < events.length; ++i) {
test(function(t) {
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
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);

View file

@ -8,7 +8,7 @@
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
for (var i = 0; i < events.length; ++i) {
test(function() {
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message');
var foo = function() {}
ws[events[i]] = foo;
assert_equals(ws[events[i]], foo, events[i]);

View file

@ -7,6 +7,6 @@
<script>
test(function(t) {
// The extensions attribute must initially return the empty string
assert_equals((new WebSocket(SCHEME_AND_DOMAIN+'/')).extensions, '');
assert_equals((new WebSocket(SCHEME_DOMAIN_PORT+'/empty-message')).extensions, '');
});
</script>

View file

@ -7,6 +7,6 @@
<script>
test(function(t) {
// The protocol attribute must initially return the empty string
assert_equals((new WebSocket(SCHEME_AND_DOMAIN+'/')).protocol, '');
assert_equals((new WebSocket(SCHEME_DOMAIN_PORT + '/empty-message')).protocol, '');
});
</script>