Bug 1806694: Support WebTransport constructor options r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D165182
This commit is contained in:
Randell Jesup 2022-12-22 15:51:32 +00:00
Родитель 1e39264465
Коммит 0896d559e1
8 изменённых файлов: 147 добавлений и 14 удалений

Просмотреть файл

@ -113,11 +113,23 @@ bool WebTransport::Init(const GlobalObject& aGlobal, const nsAString& aURL,
aError.ThrowSyntaxError("Invalid WebTransport URL");
return false;
}
// XXX and other steps in the constructor requirement (TypeError). Order is
// important.
bool dedicated =
!aOptions.mAllowPooling; // spec language, optimizer will eliminate this
bool requireUnreliable = aOptions.mRequireUnreliable;
WebTransportCongestionControl congestionControl = aOptions.mCongestionControl;
if (aOptions.mServerCertificateHashes.WasPassed()) {
// XXX bug 1806693
aError.ThrowNotSupportedError("No support for serverCertificateHashes yet");
// XXX if dedicated is false and serverCertificateHashes is non-null, then
// throw a TypeError. Also should enforce in parent
return false;
}
// https://w3c.github.io/webtransport/#webtransport-constructor Spec 5.2
backgroundChild
->SendCreateWebTransportParent(aURL /*, aOptions*/,
->SendCreateWebTransportParent(aURL, dedicated, requireUnreliable,
(uint32_t)congestionControl,
// XXX serverCertHashes,
std::move(parentEndpoint))
->Then(
GetCurrentSerialEventTarget(), __func__,

Просмотреть файл

@ -7,6 +7,7 @@
#include "WebTransportParent.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/dom/WebTransportBinding.h"
#include "mozilla/dom/WebTransportLog.h"
#include "mozilla/ipc/BackgroundParent.h"
@ -19,12 +20,22 @@ WebTransportParent::~WebTransportParent() {
}
bool WebTransportParent::Init(
const nsAString& aURL,
// WebTransportOptions aOptions,
const nsAString& aURL, const bool& aDedicated,
const bool& aRequireUnreliable, const uint32_t& aCongestionControl,
// Sequence<WebTransportHash>* aServerCertHashes,
Endpoint<PWebTransportParent>&& aParentEndpoint,
std::function<void(const nsresult&)>&& aResolver) {
LOG(("Created WebTransportParent %p %s", this,
NS_ConvertUTF16toUTF8(aURL).get()));
LOG(("Created WebTransportParent %p %s %s %s congestion=%s", this,
NS_ConvertUTF16toUTF8(aURL).get(),
aDedicated ? "Dedicated" : "AllowPooling",
aRequireUnreliable ? "RequireUnreliable" : "",
aCongestionControl ==
(uint32_t)dom::WebTransportCongestionControl::Throughput
? "ThroughPut"
: (aCongestionControl ==
(uint32_t)dom::WebTransportCongestionControl::Low_latency
? "Low-Latency"
: "Default")));
if (!StaticPrefs::network_webtransport_enabled()) {
aResolver(NS_ERROR_DOM_NOT_ALLOWED_ERR);

Просмотреть файл

@ -22,7 +22,9 @@ class WebTransportParent : public PWebTransportParent {
// XXX Threadsafe??
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebTransportParent, override)
bool Init(const nsAString& aURL, // WebTransportOptions aOptions,
bool Init(const nsAString& aURL, const bool& aDedicated,
const bool& aRequireUnreliable, const uint32_t& aCongestionControl,
// Sequence<WebTransportHash>* aServerCertHashes,
Endpoint<PWebTransportParent>&& aParentEndpoint,
std::function<void(const nsresult&)>&& aResolver);

Просмотреть файл

@ -504,8 +504,9 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateFileSystemManagerParent(
}
mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateWebTransportParent(
const nsAString& aURL,
// WebTransportOptions aOptions,
const nsAString& aURL, const bool& aDedicated,
const bool& aRequireUnreliable, const uint32_t& aCongestionControl,
// Sequence<WebTransportHash>* aServerCertHashes,
Endpoint<PWebTransportParent>&& aParentEndpoint,
CreateWebTransportParentResolver&& aResolver) {
AssertIsInMainProcess();
@ -513,7 +514,8 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateWebTransportParent(
RefPtr<mozilla::dom::WebTransportParent> webt =
new mozilla::dom::WebTransportParent();
if (!webt->Init(aURL, /*aOptions, */ std::move(aParentEndpoint),
if (!webt->Init(aURL, aDedicated, aRequireUnreliable, aCongestionControl,
/*aServerCertHashes, */ std::move(aParentEndpoint),
std::move(aResolver))) {
webt->Close();
}

Просмотреть файл

@ -138,8 +138,9 @@ class BackgroundParentImpl : public PBackgroundParent {
CreateFileSystemManagerParentResolver&& aResolver) override;
mozilla::ipc::IPCResult RecvCreateWebTransportParent(
const nsAString& aURL,
// WebTransportOptions aOptions,
const nsAString& aURL, const bool& aDedicated,
const bool& aRequireUnreliable, const uint32_t& aCongestionControl,
// Sequence<WebTransportHash>* aServerCertHashes,
Endpoint<PWebTransportParent>&& aParentEndpoint,
CreateWebTransportParentResolver&& aResolver) override;

Просмотреть файл

@ -203,7 +203,10 @@ parent:
*/
async CreateWebTransportParent(
nsString aURL,
/* WebTransportOptions aOptions, */
bool aDedicated,
bool aRequireUnreliable,
uint32_t aCongestionControl,
/* Sequence<WebTransportHash>* aServerCertHashes, */
Endpoint<PWebTransportParent> aParentEndpoint)
returns(nsresult rv);

Просмотреть файл

@ -28,6 +28,26 @@
[Connection to port 0 should fail]
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "requireUnreliable": "true"} ']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "default" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "throughput" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "low-latency" }']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true", "congestionControl": "low-latency" }']
expected: FAIL
[constructor.https.any.html]
expected:
@ -59,6 +79,27 @@
[Connection to port 0 should fail]
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "requireUnreliable": "true"} ']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "default" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "throughput" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "low-latency" }']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true", "congestionControl": "low-latency" }']
expected: FAIL
[constructor.https.any.sharedworker.html]
expected:
@ -90,6 +131,27 @@
[Connection to port 0 should fail]
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "requireUnreliable": "true"} ']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "default" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "throughput" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "low-latency" }']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true", "congestionControl": "low-latency" }']
expected: FAIL
[constructor.https.any.worker.html]
expected:
@ -120,3 +182,24 @@
[Connection to port 0 should fail]
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "requireUnreliable": "true"} ']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "default" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "throughput" }']
expected: FAIL
[WebTransport constructor should allow options '{ "congestionControl": "low-latency" }']
expected: FAIL
[WebTransport constructor should allow options '{ "allowPooling": "true", "requireUnreliable": "true", "congestionControl": "low-latency" }']
expected: FAIL

Просмотреть файл

@ -20,6 +20,25 @@ for (const url of BAD_URLS) {
}, `WebTransport constructor should reject URL '${url}'`);
}
const OPTIONS = [
{ allowPooling: true },
{ requireUnreliable: true },
{ allowPooling: true, requireUnreliable: true },
{ congestionControl: "default" },
{ congestionControl: "throughput" },
{ congestionControl: "low-latency" },
{ allowPooling: true, requireUnreliable: true, congestionControl: "low-latency" },
// XXX Need to test serverCertificateHashes
];
for (const options of OPTIONS) {
promise_test(async t => {
const wt = new WebTransport(`https://${HOST}:0/`, options );
await wt.ready;
wt.close();
}, "WebTransport constructor should allow options " + JSON.stringify(options));
}
promise_test(async t => {
const wt = new WebTransport(`https://${HOST}:0/`);