-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
report: add full-page-screenshot to experimental config (#10716)
Co-authored-by: Matt Zeunert <[email protected]>
- Loading branch information
1 parent
44d0551
commit 3efbf94
Showing
39 changed files
with
1,485 additions
and
25 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
* Copyright 2020 The Lighthouse Authors. 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. | ||
--> | ||
|
||
<style> | ||
body { | ||
background: lightblue url('screenshot.gif') no-repeat fixed center; | ||
} | ||
p { | ||
background-color: white; | ||
} | ||
</style> | ||
|
||
<body> | ||
<script> | ||
const params = new URLSearchParams(document.location.search); | ||
if (params.has('width')) document.body.style.width = params.get('width'); | ||
if (params.has('height')) document.body.style.height = params.get('height'); | ||
</script> | ||
|
||
<p>Screenshot tester.</p> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
lighthouse-cli/test/smokehouse/test-definitions/screenshot/expectations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @license Copyright 2020 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'; | ||
|
||
/** | ||
* @type {Array<Smokehouse.ExpectedRunnerResult>} | ||
*/ | ||
const expectations = [ | ||
{ | ||
artifacts: { | ||
FullPageScreenshot: { | ||
width: '>1000', | ||
height: '>1000', | ||
data: /data:image\/jpeg;base64,.{10000,}$/, | ||
}, | ||
}, | ||
lhr: { | ||
requestedUrl: 'http://localhost:10200/screenshot.html?width=1000px&height=1000px', | ||
finalUrl: 'http://localhost:10200/screenshot.html?width=1000px&height=1000px', | ||
audits: {}, | ||
}, | ||
}, | ||
{ | ||
artifacts: { | ||
FullPageScreenshot: null, | ||
}, | ||
lhr: { | ||
requestedUrl: 'http://localhost:10200/screenshot.html?width=5000px&height=5000px', | ||
finalUrl: 'http://localhost:10200/screenshot.html?width=5000px&height=5000px', | ||
runWarnings: [/Full page screenshot is too big/], | ||
audits: {}, | ||
}, | ||
}, | ||
]; | ||
|
||
module.exports = expectations; |
17 changes: 17 additions & 0 deletions
17
lighthouse-cli/test/smokehouse/test-definitions/screenshot/screenshot-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @license Copyright 2020 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'; | ||
|
||
const experimentalConfig = require('../../../../../lighthouse-core/config/experimental-config.js'); | ||
|
||
/** @type {LH.Config.Json} */ | ||
module.exports = { | ||
...experimentalConfig, | ||
settings: { | ||
onlyAudits: ['full-page-screenshot'], | ||
emulatedFormFactor: 'desktop', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @license Copyright 2020 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'; | ||
|
||
const Audit = require('./audit.js'); | ||
|
||
class FullPageScreenshot extends Audit { | ||
/** | ||
* @return {LH.Audit.Meta} | ||
*/ | ||
static get meta() { | ||
return { | ||
id: 'full-page-screenshot', | ||
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE, | ||
title: 'Full-page screenshot', | ||
description: 'A full-height screenshot of the final rendered page', | ||
requiredArtifacts: ['FullPageScreenshot'], | ||
}; | ||
} | ||
|
||
/** | ||
* @param {LH.Artifacts} artifacts | ||
* @return {Promise<LH.Audit.Product>} | ||
*/ | ||
static async audit(artifacts) { | ||
if (!artifacts.FullPageScreenshot) { | ||
return {score: 0, notApplicable: true}; | ||
} | ||
|
||
return { | ||
score: 1, | ||
details: { | ||
type: 'full-page-screenshot', | ||
...artifacts.FullPageScreenshot, | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
module.exports = FullPageScreenshot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.