1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25

content / test / data / back_forward_cache / worker_with_webtransport.js [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let transport;

onmessage = async (msg) => {
  const tokens = msg.data.split(',');
  switch (tokens[0]) {
  case 'open':
    const port = tokens[1];
    transport = new WebTransport('https://localhost:' + port + '/echo');
    await transport.ready;
    postMessage('opened');
    break;
  case 'close':
    transport.close();
    await transport.closed;
    postMessage('closed');
    break;
  default:
    console.error(msg);
    break;
  }
};