Skip to content

Commit

Permalink
Direct Sockets: stub implementations for openTCPSocket openUDPSocket
Browse files Browse the repository at this point in the history
The rename is tentative, blocked on naming decision
WICG/direct-sockets#10

Explainer: https://github.com/WICG/raw-sockets/blob/master/docs/explainer.md

Intent to Prototype:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ARtkaw4e9T4/m/npjeMssPCAAJ

Design doc:
https://docs.google.com/document/d/1Xa5nFkIWxkL3hZHvDYWPhT8sZvNeFpCUKNuqIwZHxnE/edit?usp=sharing

We introduce IDL methods for opening TCP and UDP sockets.

We introduce a mojom service that will perform permission checks
before forwarding socket opening requests to the Network Service.

Not yet implemented:
Permissions checks, calls to Network Service

Bug: 909927
Change-Id: Ifec9860d4e0b8211af7b142b856efc29cd6f9b35
  • Loading branch information
ericwilligers authored and chromium-wpt-export-bot committed Aug 25, 2020
1 parent f32f380 commit c801420
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
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>

0 comments on commit c801420

Please sign in to comment.