Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct Sockets: stub implementations for openTCPSocket openUDPSocket #25199

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions raw-sockets/META.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spec: https://github.com/WICG/raw-sockets/blob/master/docs/explainer.md
suggested_reviewers:
- ewilligers
- mgiuca
- phoglenix
2 changes: 2 additions & 0 deletions raw-sockets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
These tests are for the TCP and UDP sockets API proposed in
https://github.com/WICG/raw-sockets/blob/master/docs/explainer.md
21 changes: 21 additions & 0 deletions raw-sockets/open-securecontext.http.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sockets test: Open from non-secure context</title>
<link rel="help" href="https://github.com/WICG/raw-sockets/blob/master/docs/explainer.md#security-considerations">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(() => {
assert_false('openTCPSocket' in navigator, 'navigator has attribute \'openTCPSocket\'.');
}, 'navigator.openTCPSocket must be undefined in non-secure context');

test(() => {
assert_false('openUDPSocket' in navigator, 'navigator has attribute \'openUDPSocket\'.');
}, 'navigator.openUDPSocket must be undefined in non-secure context');
</script>
</body>
</html>
34 changes: 34 additions & 0 deletions raw-sockets/remotePort-required.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sockets test: open without remotePort</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
'use strict';

const options = {
localAddress: "127.0.0.1",
localPort: 0,
remoteAddress: "127.0.0.1",
};

test(() => {
assert_throws_js(TypeError, () => { navigator.openTCPSocket() });
assert_throws_js(TypeError, () => { navigator.openTCPSocket(null) });
assert_throws_js(TypeError, () => { navigator.openTCPSocket(undefined) });
assert_throws_js(TypeError, () => { navigator.openTCPSocket(options) });
}, 'openTCPSocket requires remotePort');

test(() => {
assert_throws_js(TypeError, () => { navigator.openUDPSocket() });
assert_throws_js(TypeError, () => { navigator.openUDPSocket(null) });
assert_throws_js(TypeError, () => { navigator.openUDPSocket(undefined) });
assert_throws_js(TypeError, () => { navigator.openTCPSocket(options) });
}, 'openUDPSocket requires remotePort');
</script>
</body>
</html>