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,11 @@
<!doctype html>
<title>WebSockets: new WebSocket() 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() {
assert_throws(new TypeError(), function(){new WebSocket()});
});
</script>

View file

@ -0,0 +1,18 @@
<!doctype html>
<title>WebSockets: new WebSocket(invalid 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_throws("SyntaxError", function(){new WebSocket("/test")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("ws://foo bar.com/")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("wss://foo bar.com/")})});
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("?test")})});
test(function() {assert_throws("SyntaxError", function(){new WebSocket("#test")})});
</script>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>WebSockets: new WebSocket(url, invalid protocol)</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>
// empty string
test(function() {assert_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/", "")})});
// 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);
})
}
// 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);
})
}
</script>

View file

@ -0,0 +1,11 @@
<!doctype html>
<title>WebSockets: 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() {
assert_true(new WebSocket("ws://"+location.host+"/") instanceof WebSocket);
});
</script>

View file

@ -0,0 +1,26 @@
<!doctype html>
<title>WebSockets: converting first arguments</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 a = document.createElement('a');
a.href = SCHEME_DOMAIN_PORT+'/echo';
var ws = new WebSocket(a); // should stringify arguments; <a> stringifies to its .href
assert_equals(ws.url, a.href);
ws.onopen = t.step_func(function(e) {
ws.send('test');
});
ws.onmessage = t.step_func(function(e) {
assert_equals(e.data, 'test');
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(t.step_func(function() {t.done()}), 50);
});
ws.close();
});
ws.onerror = ws.onclose = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,9 @@
<!doctype html>
<title>WebSockets: new WebSocket(url, null char)</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_throws("SyntaxError", function(){new WebSocket("ws://"+location.host+"/", 'a'+String.fromCharCode(0)+'b')})});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: new WebSocket(url with not blocked port)</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>
//Pass condition is to not throw
test(function(){new WebSocket('ws://example.invalid:80/')});
test(function(){new WebSocket('ws://example.invalid:443/')});
test(function(){new WebSocket('wss://example.invalid:80/')});
test(function(){new WebSocket('wss://example.invalid:443/')});
</script>

View file

@ -0,0 +1,21 @@
<!doctype html>
<title>WebSockets: protocol</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+'/protocol', 'foobar');
ws.onmessage = t.step_func(function(e) {
assert_equals(ws.protocol, 'foobar');
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(t.step_func(function() {t.done()}), 50);
})
ws.close();
})
ws.onerror = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,20 @@
<!doctype html>
<title>WebSockets: protocol in response but no requested protocol</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+'/handshake_protocol');
ws.onerror = ws.onmessage = ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
ws.onopen = t.step_func(function(e) {
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
setTimeout(t.step_func(function() {t.done();}), 50);
})
ws.close();
})
});
</script>

View file

@ -0,0 +1,25 @@
<!doctype html>
<title>WebSockets: protocol mismatch</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+'/handshake_protocol', 'FOOBAR');
var gotOpen = false;
var gotError = false;
ws.onopen = t.step_func(function(e) {
gotOpen = true;
})
ws.onerror = t.step_func(function(e) {
gotError = true;
})
ws.onclose = t.step_func(function(e) {
assert_true(gotOpen, 'got open');
assert_true(gotError, 'got error');
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(t.step_func(function() {t.done();}), 50);
})
});
</script>

View file

@ -0,0 +1,17 @@
<!doctype html>
<title>WebSockets: no protocol in response</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+'/handshake_no_protocol', 'foobar');
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(t.step_func(function() {t.done();}), 50)
})
ws.onmessage = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,39 @@
<!doctype html>
<title>WebSockets: multiple WebSocket objects</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) {
// test that the events are fired as they should when opening 25 websockets and
// sending a message on each and then closing when getting the message back
var ws = [];
var events = 0;
for (var i = 0; i < 25; ++i) {
ws[i] = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
ws[i].id = i;
ws[i].onopen = t.step_func(function(e) {
events++;
this.send(this.id);
this.onopen = t.step_func(function() {assert_unreached()});
}, ws[i]);
ws[i].onmessage = t.step_func(function(e) {
events++;
assert_equals(e.data, ''+this.id);
this.close();
this.onmessage = t.step_func(function() {assert_unreached()});
}, ws[i]);
ws[i].onclose = t.step_func(function(e) {
events++;
if (events == 75) {
t.done();
}
this.onclose = t.step_func(function() {assert_unreached()});
}, ws[i]);
ws[i].onerror = t.step_func(function() {assert_unreached()});
}
}, null, {timeout:25000});
</script>

View file

@ -0,0 +1,35 @@
<!doctype html>
<title>WebSockets: serialize establish a connection</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 = [];
var events = 0;
var prevDate;
var date;
for (var i = 0; i < 4; ++i) {
ws[i] = new WebSocket(SCHEME_DOMAIN_PORT+'/handshake_sleep_1');
ws[i].id = i;
ws[i].onopen = t.step_func(function(e) {
events++;
date = new Date();
if (prevDate)
assert_greater_than(date-prevDate, 998);
prevDate = date;
this.onopen = t.step_func(function() {assert_unreached()});
})
ws[i].onclose = t.step_func(function(e) {
events++;
if (events == 8) {
t.done();
}
this.onclose = t.step_func(function() {assert_unreached()});
});
ws[i].onerror = ws[i].onmessage = t.step_func(function() {assert_unreached()});
}
}, null, {timeout:10000});
</script>

View file

@ -0,0 +1,17 @@
<!doctype html>
<meta charset=windows-1252>
<title>WebSockets: non-ascii URL in query, document encoding windows-1252</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-query_v13?åäö');
ws.onclose = t.step_func(function() {assert_unreached()});
ws.onmessage = t.step_func(function(e) {
assert_equals(e.data, '%C3%A5%C3%A4%C3%B6');
t.done();
});
});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>WebSockets: too few slashes after ws: and wss:</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 tests = ['ws:', 'ws:/', 'wss:', 'wss:/'];
//Pass condition is to not throw
for (var i = 0; i < tests.length; ++i) {
test(function(){new WebSocket(tests[i]+location.host+'/echo')}, tests[i]);
}
</script>

View file

@ -0,0 +1,17 @@
<!doctype html>
<title>WebSockets: NULL char in 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>
async_test(function(t) {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo-query?x\u0000');
ws.onmessage = t.step_func(function(e) {
assert_equals(e.data, 'x%00');
ws.close();
t.done();
})
ws.onclose = ws.onerror = t.step_func(function(e) {assert_unreached(e.type)});
});
</script>

View file

@ -0,0 +1,18 @@
<!doctype html>
<title>WebSockets: uppercase '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>
async_test(function(t) {
var scheme = SCHEME_DOMAIN_PORT.split('://')[0];
var domain = SCHEME_DOMAIN_PORT.split('://')[1];
var ws = new WebSocket(scheme.toUpperCase()+'://'+domain+'/echo');
ws.onopen = t.step_func(function(e) {
ws.close();
t.done();
})
ws.onclose = ws.onerror = ws.onmessage = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,18 @@
<!doctype html>
<title>WebSockets: uppercase host</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 scheme = SCHEME_DOMAIN_PORT.split('://')[0];
var domain = SCHEME_DOMAIN_PORT.split('://')[1];
var ws = new WebSocket(scheme+'://'+domain.toUpperCase()+'/echo');
ws.onopen = t.step_func(function(e) {
ws.close();
t.done();
});
ws.onclose = ws.onerror = ws.onmessage = t.step_func(function() {assert_unreached()});
});
</script>

View file

@ -0,0 +1,9 @@
<!doctype html>
<title>WebSockets: Same sub protocol twice</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_throws("SyntaxError", function(){new WebSocket("ws://certo2.oslo.osa/protocol_array",["foobar, foobar"])})});
</script>

View file

@ -0,0 +1,20 @@
<!doctype html>
<title>WebSockets: protocol array</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+'/protocol_array',['foobar','foobar2']);
ws.onmessage = t.step_func(function(e) {
assert_equals(ws.protocol, 'foobar');
ws.onclose = t.step_func(function(e) {
ws.onclose = t.step_func(function() {assert_unreached()});
setTimeout(t.step_func(function() {t.done();}), 50)
});
ws.close();
});
ws.onerror = t.step_func(function() {assert_unreached()});
});
</script>