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