11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst { MessageChannel } = require('worker_threads'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// Make sure that closing a message port while receiving messages on it does 71cb0ef41Sopenharmony_ci// not stop messages that are already in the queue from being emitted. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst { port1, port2 } = new MessageChannel(); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciport1.on('message', common.mustCall(() => { 121cb0ef41Sopenharmony_ci port1.close(); 131cb0ef41Sopenharmony_ci}, 2)); 141cb0ef41Sopenharmony_ciport2.postMessage('foo'); 151cb0ef41Sopenharmony_ciport2.postMessage('bar'); 16