From f5b7f3014466319ff47dfa7c563cc8264e92e638 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 4 Dec 2019 16:41:46 -0800 Subject: [PATCH] feat: use xvfb for WK on linux --- browser_patches/webkit/pw_run.sh | 13 ++++++++++++- src/webkit/Launcher.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/browser_patches/webkit/pw_run.sh b/browser_patches/webkit/pw_run.sh index 95c3debba1..313121c9cf 100755 --- a/browser_patches/webkit/pw_run.sh +++ b/browser_patches/webkit/pw_run.sh @@ -31,7 +31,18 @@ function runLinux() { echo "Cannot find a MiniBrowser.app in neither location" 1>&2 exit 1 fi - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LD_PATH $MINIBROWSER "$@" + + newargs="" + for arg in "$@"; do + if [[ "$arg" == "--headless" ]]; then + if which xvfb-run > /dev/null; then + MINIBROWSER="xvfb-run $MINIBROWSER" + fi + else + newargs="$newarg$arg" + fi + done + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LD_PATH $MINIBROWSER "$newargs" } SCRIPT_PATH="$(cd "$(dirname "$0")" ; pwd -P)" diff --git a/src/webkit/Launcher.ts b/src/webkit/Launcher.ts index 265b637181..13430291d5 100644 --- a/src/webkit/Launcher.ts +++ b/src/webkit/Launcher.ts @@ -78,7 +78,7 @@ export class Launcher { stdio = ['ignore', 'ignore', 'ignore', 'pipe', 'pipe']; webkitArguments.push('--inspector-pipe'); // Headless options is only implemented on Mac at the moment. - if (process.platform === 'darwin' && options.headless !== false) + if (options.headless !== false) webkitArguments.push('--headless'); const webkitProcess = childProcess.spawn( webkitExecutable,