1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14

content / test / data / service_worker / message_port_close_event.js [blame]

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

onmessage = async (e) => {
  if (e.data == 'init') {
    self.port = e.ports[0];
    self.port.start();
  } else if (e.data == 'wait for close event') {
    self.port.onclose = () => {
      e.source.postMessage('close event is fired');
    }
  }
}