test_node_execute_loop.js (887B)
1 // This test checks that the interaction between NodeServer.execute defined in 2 // httpd.js and the node server that we're interacting with defined in 3 // moz-http2.js is working properly. 4 // This test spawns a node server that loops on while true and makes sure 5 // the the process group is killed by runxpcshelltests.py at exit. 6 // See bug 1855174 7 8 "use strict"; 9 10 const { NodeServer } = ChromeUtils.importESModule( 11 "resource://testing-common/NodeServer.sys.mjs" 12 ); 13 14 add_task(async function killOnEnd() { 15 let id = await NodeServer.fork(); 16 await NodeServer.execute(id, `console.log("hello");`); 17 await NodeServer.execute(id, `console.error("hello");`); 18 // Make the forked subprocess hang forever. 19 NodeServer.execute(id, "while (true) {}").catch(() => {}); 20 await new Promise(resolve => do_timeout(10, resolve)); 21 // Should get killed at the end of the test by the harness. 22 });