summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webtransport/server-certificate-hashes.https.any.js
blob: 01efab1191b70398884e4cc5ac6ef0fc45e597b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// META: global=window,worker
// META: script=/common/get-host-info.sub.js
// META: script=resources/webtransport-test-helpers.sub.js

promise_test(async t => {
  const hashValue = new Uint8Array(32);
  // The connection fails because the fingerprint does not match.
  const wt = new WebTransport(webtransport_url('echo.py'), {
    serverCertificateHashes: [
      {
        algorithm: "sha-256",
        value: hashValue,
      }
    ]
  });

  const e = await wt.ready.catch(e => e);
  await promise_rejects_exactly(t, e, wt.ready, 'ready should be rejected');
  await promise_rejects_exactly(t, e, wt.closed, 'closed should be rejected');
  assert_true(e instanceof WebTransportError);
}, 'Connection fails due to certificate hash mismatch');