Skip to content

Commit

Permalink
Convert WebSocket tests to .any.js format
Browse files Browse the repository at this point in the history
Fixes #2557.
  • Loading branch information
annevk committed Mar 15, 2017
1 parent e48dd15 commit e3f3b63
Show file tree
Hide file tree
Showing 92 changed files with 191 additions and 1,196 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Close WebSocket - Code is 1000 and reason</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - Connection should be opened");
var testClose = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(1000, reason) - readyState should be in CLOSED state and wasClean is TRUE - Connection should be closed");
Expand All @@ -28,8 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be TRUE");
testClose.done();
}), true);

</script>

</body>
</html>
17 changes: 1 addition & 16 deletions websockets/Close-1000.htm → websockets/Close-1000.any.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Close WebSocket - Code is 1000</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create WebSocket - Connection should be opened");
var testClose = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(1000) - readyState should be in CLOSED state and wasClean is TRUE - Connection should be closed");
Expand All @@ -28,8 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be TRUE");
testClose.done();
}), true);

</script>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Close WebSocket - Reason is more than 123 bytes long</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var test = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(code, 'reason more than 123 bytes') - SYNTAX_ERR is thrown");

Expand All @@ -21,7 +11,3 @@
assert_throws("SYNTAX_ERR", function () { wsocket.close(1000, reason) });
test.done();
}), true);
</script>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Close WebSocket - Reason with unpaired surrogates</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(reason with unpaired surrogates) - connection should get opened");
var testClose = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(reason with unpaired surrogates) - connection should get closed");
Expand All @@ -29,8 +19,3 @@
assert_equals(evt.reason, replacementChar, "reason replaced with replacement character");
testClose.done();
}), true);

</script>

</body>
</html>
11 changes: 11 additions & 0 deletions websockets/Close-undefined.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// META: script=websocket.sub.js

var test = async_test();

var wsocket = CreateWebSocket(false, false, false);
var isOpenCalled = false;

wsocket.addEventListener('open', test.step_func(function (evt) {
wsocket.close(undefined);
test.done();
}), true);
25 changes: 0 additions & 25 deletions websockets/Close-undefined.htm

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Create Secure WebSocket - blocked port</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script>
// META: script=websocket.sub.js

test(function () {
// list of bad ports according to
// https://fetch.spec.whatwg.org/#port-blocking
Expand Down Expand Up @@ -83,6 +74,3 @@
assert_throws("SECURITY_ERR", function () { CreateWebSocketWithBlockedPort(blockedPort) });
}
}, "W3C WebSocket API - Create Secure WebSocket - Pass a URL with a blocked port - SECURITY_ERR should be thrown")
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Create Secure WebSocket</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create Secure WebSocket - wsocket.extensions should be set to '' after connection is established - Connection should be opened");
var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - wsocket.extensions should be set to '' after connection is established - Connection should be closed");
Expand All @@ -28,6 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be true");
testClose.done();
}), true);
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions websockets/Create-Secure-url-with-space.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// META: script=websocket.sub.js

test(function () {
var wsocket;
var spaceUrl = "web platform.test";
assert_throws("SYNTAX_ERR", function () { wsocket = CreateWebSocketWithSpaceInUrl(spaceUrl) });
}, "W3C WebSocket API - Create Secure WebSocket - Pass a URL with a space - SYNTAX_ERR should be thrown")
19 changes: 0 additions & 19 deletions websockets/Create-Secure-url-with-space.htm

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Create Secure WebSocket with valid url and array of protocols</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create Secure WebSocket - Pass a valid URL and array of protocol strings - Connection should be opened");
var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - Pass a valid URL and array of protocol strings - Connection should be closed");
Expand All @@ -28,7 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be true");
testClose.done();
}), true);

</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Create Secure WebSocket - binaryType set correctly</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create Secure WebSocket - wsocket.binaryType should be set to 'blob' after connection is established - Connection should be opened");
var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - wsocket.binaryType should be set to 'blob' after connection is established - Connection should be closed");
Expand All @@ -28,7 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be true");
testClose.done();
}), true);

</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Create Secure WebSocket and verify if protocol is set correctly after connection</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create Secure WebSocket - Pass a valid URL and protocol string - protocol should be set correctly - Connection should be opened");
var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - Pass a valid URL and protocol string - Connection should be closed");
Expand All @@ -28,6 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be true");
testClose.done();
}), true);
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Create Secure WebSocket with valid url and protocol string</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create Secure WebSocket - Check readyState is 1");
var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - Pass a valid URL and protocol string - Connection should be closed");
Expand All @@ -28,7 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be true");
testClose.done();
}), true);

</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Create Secure WebSocket with valid url</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.sub.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
// META: script=websocket.sub.js

var testOpen = async_test("W3C WebSocket API - Create Secure WebSocket - Pass a valid URL - Connection should be opened");
var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - Pass a valid URL - Connection should be closed");
Expand All @@ -28,7 +18,3 @@
assert_equals(evt.wasClean, true, "wasClean should be true");
testClose.done();
}), true);

</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// META: script=websocket.sub.js

test(function () {
var urlNonDefaultPort = "wss://" + __SERVER__NAME + ":" + __NEW__SECURE__PORT + "/" + __PATH;
var wsocket = new WebSocket(urlNonDefaultPort);
assert_equals(wsocket.url, urlNonDefaultPort, "wsocket.url is set correctly");
}, "W3C WebSocket API - Create Secure WebSocket - wsocket.url should be set correctly")
19 changes: 0 additions & 19 deletions websockets/Create-Secure-verify-url-set-non-default-port.htm

This file was deleted.

9 changes: 9 additions & 0 deletions websockets/Create-asciiSep-protocol-string.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// META: script=websocket.sub.js

if(window.WebSocket) {
test(function () {
var asciiWithSep = "/echo";
var wsocket;
assert_throws("SYNTAX_ERR", function () { wsocket = CreateWebSocketWithAsciiSep(asciiWithSep) });
}, "W3C WebSocket API - Create WebSocket - Pass a valid URL and a protocol string with an ascii separator character - SYNTAX_ERR is thrown")
}
21 changes: 0 additions & 21 deletions websockets/Create-asciiSep-protocol-string.htm

This file was deleted.

Loading

0 comments on commit e3f3b63

Please sign in to comment.