Skip to content

Commit

Permalink
clients(devtools): audits2->audits and defer reading resources (#9344)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Jul 11, 2019
1 parent a36d263 commit 3fb2c6d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
20 changes: 16 additions & 4 deletions clients/devtools-report-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@
// @ts-ignore: Runtime exists in Devtools.
const cachedResources = Runtime.cachedResources;

// Getters are necessary because the DevTools bundling processes
// resources after this module is resolved. These properties are not
// read from immediately, so we can defer reading with getters and everything
// is going to be OK.
module.exports = {
REPORT_CSS: cachedResources['audits/lighthouse/report.css'],
REPORT_JAVASCRIPT: cachedResources['audits/lighthouse/report.js'],
REPORT_TEMPLATE: cachedResources['audits/lighthouse/template.html'],
REPORT_TEMPLATES: cachedResources['audits/lighthouse/templates.html'],
get REPORT_CSS() {
return cachedResources['audits/lighthouse/report.css'];
},
get REPORT_JAVASCRIPT() {
return cachedResources['audits/lighthouse/report.js'];
},
get REPORT_TEMPLATE() {
return cachedResources['audits/lighthouse/template.html'];
},
get REPORT_TEMPLATES() {
return cachedResources['audits/lighthouse/templates.html'];
},
};
8 changes: 5 additions & 3 deletions lighthouse-core/scripts/roll-to-devtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ else
frontend_dir="$chromium_dir/third_party/blink/renderer/devtools/front_end"
fi

tests_dir="$frontend_dir/../../../web_tests/http/tests/devtools/audits2"
tests_dir="$frontend_dir/../../../web_tests/http/tests/devtools/audits"

if [[ ! -d "$frontend_dir" || ! -a "$frontend_dir/Runtime.js" ]]; then
echo -e "\033[31m✖ Error!\033[39m"
Expand All @@ -43,10 +43,12 @@ cp -pPR "$lh_bg_js" "$lh_worker_dir/lighthouse-dt-bundle.js"
echo -e "\033[96m ✓\033[39m (Potentially stale) lighthouse-dt-bundle copied."

# copy report generator + cached resources into $fe_lh_dir
cp -r dist/dt-report-resources/ $fe_lh_dir
# use dir/* format to copy over all files in dt-report-resources directly to $fe_lh_dir
# dir/ format behavior changes based on if their exists a folder named dir, which can get weird
cp -r dist/dt-report-resources/* $fe_lh_dir

# update expected version string in tests
VERSION=$(node -e "console.log(require('./package.json').version)")
sed -i '' -e "s/Version:.*/Version: $VERSION/g" "$tests_dir"/*-expected.txt

echo "Done. To rebase the test expectations, run: yarn --cwd ~/chromium/src/third_party/blink/renderer/devtools test 'http/tests/devtools/audits2/*' --reset-results"
echo "Done. To rebase the test expectations, run: yarn --cwd ~/chromium/src/third_party/blink/renderer/devtools test 'http/tests/devtools/audits/*' --reset-results"

0 comments on commit 3fb2c6d

Please sign in to comment.