Commit 7a14ada9 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

[QuicTransport] Add wpt for constructor

Verify that the QuicTransport constructor rejects incorrect URLs.

Also verify that attempting to connect to port 0 fails.

BUG=1011392

Change-Id: I57d209569633c351dd408cdced1d7e44f92f1065
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217680Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773048}
parent 696c82aa
// META: global=window,worker
// META: script=/common/get-host-info.sub.js
const HOST = get_host_info().ORIGINAL_HOST;
const BAD_URLS = [
null,
'',
'no-scheme',
'https://example.com/' /* scheme is wrong */,
'quic-transport:///' /* no host specified */,
'quic-transport://example.com/#failing' /* has fragment */,
`quic-transport://${HOST}:999999/` /* invalid port */,
];
for (const url of BAD_URLS) {
test(() => {
assert_throws_dom('SyntaxError', () => new QuicTransport(url),
'constructor should throw');
}, `QuicTransport constructor should reject URL '${url}'`);
}
// TODO(ricea): Test CSP.
promise_test(t => {
const qt = new QuicTransport(`quic-transport://${HOST}:0/`);
return Promise.all([
promise_rejects_js(t, TypeError, qt.ready, 'ready promise rejects'),
promise_rejects_js(t, TypeError, qt.closed, 'closed promise rejects'),
]);
}, 'connection to port 0 should fail');
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment