summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/node_execute/test_node_execute_loop.js
blob: 44871c65c2e5ac0336d3bd549cea3b8aee5a9a96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// This test checks that the interaction between NodeServer.execute defined in
// httpd.js and the node server that we're interacting with defined in
// moz-http2.js is working properly.
// This test spawns a node server that loops on while true and makes sure
// the the process group is killed by runxpcshelltests.py at exit.
// See bug 1855174

"use strict";

const { NodeServer } = ChromeUtils.importESModule(
  "resource://testing-common/httpd.sys.mjs"
);

add_task(async function killOnEnd() {
  let id = await NodeServer.fork();
  await NodeServer.execute(id, `console.log("hello");`);
  await NodeServer.execute(id, `console.error("hello");`);
  // Make the forked subprocess hang forever.
  NodeServer.execute(id, "while (true) {}").catch(() => {});
  await new Promise(resolve => do_timeout(10, resolve));
  // Should get killed at the end of the test by the harness.
});