-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Perf-X server Rerun lighthouse on POST request. #1393
Changes from 9 commits
42b6378
f209126
70c3634
eef6acb
33cb613
c7d93c8
d65748b
189177b
415cdf7
b6765f9
d25a85f
571724c
2b76c26
7891430
54167f7
ba6572e
e8d85d9
0b65e48
896d40d
4dd5b6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,10 +202,21 @@ class ReportGenerator { | |
|
||
/** | ||
* Gets the script for the report UI | ||
* @return {string} | ||
* @param {string} reportContext | ||
* @return {Array<string>} | ||
*/ | ||
getReportJS() { | ||
return fs.readFileSync(path.join(__dirname, './scripts/lighthouse-report.js'), 'utf8'); | ||
getReportJS(reportContext) { | ||
const scriptList = []; | ||
|
||
if (reportContext === 'perf-x') { | ||
scriptList.push(fs.readFileSync(path.join(__dirname, './scripts/perf-x-api.js'))); | ||
} | ||
|
||
if (reportContext !== 'devtools') { | ||
scriptList.push(fs.readFileSync(path.join(__dirname, './scripts/lighthouse-report.js'))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was the 'utf8' removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry. I didn't add this when I rewrite this method because I thought 'utf8' is default anyway : ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think null is the default. https://nodejs.org/api/fs.html#fs_fs_readfilesync_file_options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad. Fixed in the next update! Thanks for pointing out! |
||
} | ||
|
||
return scriptList; | ||
} | ||
|
||
/** | ||
|
@@ -303,7 +314,7 @@ class ReportGenerator { | |
lhresults: this._escapeScriptTags(JSON.stringify(results, null, 2)), | ||
css: this.getReportCSS(), | ||
reportContext: reportContext, | ||
script: reportContext === 'devtools' ? '' : this.getReportJS(), | ||
scripts: this.getReportJS(reportContext), | ||
aggregations: results.aggregations, | ||
auditsByCategory: this._createPWAAuditsByCategory(results.aggregations) | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allow us to use |
||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"globalReturn": false, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Google Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
/** | ||
* @fileoverview Report script for Project Performance Experiment. | ||
* | ||
* Include functions for supporting interation between report page and Perf-X server. | ||
* Currently not exposed to users. Only for testing Perf-X server. | ||
*/ | ||
|
||
/** | ||
* Send request to rerun lighthouse with additional cli-flags. | ||
* Some cli-flags will be ignored. | ||
- Flags which are not applicable to rerun lighthouse (e.g. --list-all-audits, --help) | ||
- config related flags (e.g. --config-path). Always use perf-olny config for rerunning. | ||
* @param {!Object} additionalFlags | ||
*/ | ||
|
||
/* exported rerunLighthouse */ | ||
function rerunLighthouse(additionalFlags={}) { | ||
fetch('/rerun', {method: 'POST', body: JSON.stringify(additionalFlags)}) | ||
.then(response => response.json()) | ||
.then(console.log.bind(console)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we rerun tests with configurations (e.g. URL blocking patterns), we only care about performance. So use
perfOnlyConfig
here to get faster result.