[TS] Manually GC on chromium and skip leak checks otherwise
[ldk-java] / ts / test / browser.mjs
1 import { chromium, firefox, webkit } from 'playwright';
2 import { strict as assert } from 'assert';
3
4 for (const browserType of [chromium, firefox]) { // We'd like to test webkit, but playwright doesn't support it on Debian (?!)
5         var browser;
6         if (browserType == chromium)
7                 browser = await browserType.launch(["--js-flags=\"--expose-gc\""]);
8         else
9                 browser = await browserType.launch();
10         const context = await browser.newContext();
11         const page = await context.newPage();
12         page.on('console', async msg => {
13                 const values = [];
14                 for (const arg of msg.args())
15                         values.push(await arg.jsonValue());
16                 console.log(...values);
17         });
18         await page.goto('http://localhost:8000/test/index.html');
19         var ret;
20         // On chromium we expose the GC and can run it manually, otherwise we really can't leak-check
21         if (browserType == chromium) {
22                 ret = await page.evaluate(() => { return test_runner('../liblightningjs.wasm', true); });
23         } else {
24                 ret = await page.evaluate(() => { return test_runner('../liblightningjs.wasm', false); });
25         }
26         assert(ret);
27
28         await browser.close();
29 }