1#! /bin/sh 2 3# Copyright 2018 Google Inc. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7if [ "$(uname)" = Linux ]; then 8 EXAMPLE='/opt/google/chrome/chrome' 9elif [ "$(uname)" = Darwin ]; then 10 EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"' 11else 12 EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"' 13fi 14 15if [ $# -lt 3 ] || ! [ -x "$1" ]; then 16 cat >&2 << EOF 17usage: 18 $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_PATH 19 $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_PATH OPTIONAL_WAIT_TIME # 5 second sleep before capture 20e.g: 21 $0 $EXAMPLE https://www.google.com/ /tmp/foo.mskp 22 $0 $EXAMPLE https://www.google.com/ /tmp/foo.mskp 5 23EOF 24 exit 1 25fi 26 27EXE="$1" 28URL="$2" 29DST="$3" 30SLP=${4:-0} # sleep in seconds before capture. 4th param iff provided, else 0. 31 32CRASH=~/tmp/headless_crash_dumps 33mkdir -p "$CRASH" 34 35(sleep $SLP; printf 'chrome.gpuBenchmarking.printPagesToSkPictures("%s");\nquit\n' "$DST") | \ 36 "$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \ 37 --no-sandbox --enable-gpu-benchmarking "$URL" 38