Skip to content

Commit ffe1583

Browse files
committed
[js/webgpu] use Headless for webgpu test by default (#19702)
### Description use Chromium Headless for webgpu test by default. Still use normal Chromium with window when debug=true or perfMode=true. Use the [`--headless=new`](https://developer.chrome.com/docs/chromium/new-headless) mode. ### Motivation and Context try to use a more stable way to launch npm tests to avoid a "chrome not found" issue in pipeline, which may potentially caused by windowed application.
1 parent d61ef6f commit ffe1583

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

js/web/karma.conf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ module.exports = function(config) {
8686
hostname,
8787
listenAddress,
8888
customLaunchers: {
89-
// the following flags are used to make sure Edge on CI agents to initialize WebGPU correctly.
89+
// Chromium-based browsers
9090
EdgeTest: {base: 'Edge', flags: chromiumFlags},
9191
ChromeTest: {base: 'Chrome', flags: chromiumFlags},
92-
ChromeTestHeadless: {base: 'ChromeHeadless', flags: chromiumFlags},
9392
ChromeCanaryTest: {base: 'ChromeCanary', flags: chromiumFlags},
93+
9494
//
9595
// ==== BrowserStack browsers ====
9696
//

js/web/script/test-runner-cli.ts

+7-22
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,13 @@ async function main() {
495495
npmlog.info('TestRunnerCli.Run', '(4/4) Running karma to start test runner...');
496496
const webgpu = args.backends.indexOf('webgpu') > -1;
497497
const webnn = args.backends.indexOf('webnn') > -1;
498-
const browser = getBrowserNameFromEnv(
499-
args.env,
500-
args.bundleMode === 'perf' ? 'perf' :
501-
args.debug ? 'debug' :
502-
'test',
503-
webgpu);
498+
const browser = getBrowserNameFromEnv(args.env);
504499
const karmaArgs = ['karma', 'start', `--browsers ${browser}`];
505500
const chromiumFlags = ['--enable-features=SharedArrayBuffer', ...args.chromiumFlags];
501+
if (args.bundleMode === 'dev' && !args.debug) {
502+
// use headless for 'test' mode (when 'perf' and 'debug' are OFF)
503+
chromiumFlags.push('--headless=new');
504+
}
506505
if (args.debug) {
507506
karmaArgs.push('--log-level info --timeout-mocha 9999999');
508507
chromiumFlags.push('--remote-debugging-port=9333');
@@ -615,10 +614,10 @@ async function main() {
615614
fs.writeJSONSync(path.join(TEST_ROOT, './testdata-config.json'), config);
616615
}
617616

618-
function getBrowserNameFromEnv(env: TestRunnerCliArgs['env'], mode: 'debug'|'perf'|'test', webgpu: boolean) {
617+
function getBrowserNameFromEnv(env: TestRunnerCliArgs['env']) {
619618
switch (env) {
620619
case 'chrome':
621-
return selectChromeBrowser(mode, webgpu);
620+
return 'ChromeTest';
622621
case 'edge':
623622
return 'EdgeTest';
624623
case 'firefox':
@@ -633,20 +632,6 @@ async function main() {
633632
throw new Error(`env "${env}" not supported.`);
634633
}
635634
}
636-
637-
function selectChromeBrowser(mode: 'debug'|'perf'|'test', webgpu: boolean) {
638-
if (webgpu) {
639-
return 'ChromeTest';
640-
} else {
641-
switch (mode) {
642-
case 'debug':
643-
case 'perf':
644-
return 'ChromeTest';
645-
default:
646-
return 'ChromeTestHeadless';
647-
}
648-
}
649-
}
650635
}
651636

652637
void main();

0 commit comments

Comments
 (0)