Skip to content

Commit

Permalink
Don't try to connect to "ws://"+location.host+"/" in WebSocket tests.
Browse files Browse the repository at this point in the history
This will connect on port 80, which is not typically under the control of the
wpt server.
  • Loading branch information
Ms2ger committed Jun 23, 2015
1 parent 3ecdc9d commit 2e4553c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions websockets/constructor/002.html
Expand Up @@ -11,8 +11,8 @@
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>
24 changes: 17 additions & 7 deletions websockets/constructor/004.html
Expand Up @@ -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>
2 changes: 1 addition & 1 deletion websockets/constructor/005.html
Expand Up @@ -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>
7 changes: 6 additions & 1 deletion websockets/constructor/007.html
Expand Up @@ -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>

0 comments on commit 2e4553c

Please sign in to comment.