-
Notifications
You must be signed in to change notification settings - Fork 9.6k
core(iframe-elements): Include new IFrameElements gatherer #8979
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
Merged
paulirish
merged 23 commits into
GoogleChrome:master
from
jburger424:iframe-elements-gatherer
Sep 18, 2019
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
89d81ef
Bring over IFrameElements gatherer and add types.
jburger424 499c599
Move page functions to `.../lib/page-functions.js`
jburger424 4abd4dc
Update default config to include IFrameElements gatherer in defaultPass.
jburger424 3ee62ee
Resolve no-undef lint errors.
jburger424 ce2e280
Address comments.
jburger424 2642fa9
Update `index-test.js.snap` snapshot.
jburger424 76e3e1d
Address numerous comments.
jburger424 e07610e
Merge branch 'master' into iframe-elements-gatherer
jburger424 aa8e553
Merge branch 'master' into iframe-elements-gatherer
jburger424 861e3ed
Address comments and update snapshot.
jburger424 0c8ba7f
Recurse frameTree.
jburger424 c9887c6
Fix lint errors.
jburger424 0ca3b25
Declare type for framesByDomId map.
jburger424 d2223fd
Address comments.
jburger424 371bcc9
Merge branch 'master' into iframe-elements-gatherer
jburger424 a1a6f21
Resolve comments.
jburger424 a4bacac
Address comments.
jburger424 54f9793
Update oopif to ensure functionality of IFrameElements gatherer.
jburger424 13e6f66
Address comments.
jburger424 e674bc9
Remove `frame` object from IFrameElement.
jburger424 4121d17
Merge branch 'master' into iframe-elements-gatherer
jburger424 8d9354e
Remove recursive iframe gathering functionality from _findAllElements…
jburger424 82ddb3b
Remove unused `inner-iframe` from online-only fixture.
jburger424 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Where is my iframe?</title> | ||
| </head> | ||
| <body> | ||
| <h1>Hello frames</h1> | ||
| <iframe name="oopif" src="https://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/" style="width: 100vw; height: 100vh;"></iframe> | ||
| <iframe id="oopif" name="oopif" src="https://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/" style="width: 100vw; height: 110vh;"></iframe> | ||
| <iframe id="outer-iframe" src="http://localhost:10200/online-only.html" style="position: fixed"></iframe> | ||
| </body> | ||
| </html> |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -10,9 +10,4 @@ | |
| */ | ||
| module.exports = { | ||
| extends: 'lighthouse:default', | ||
| settings: { | ||
| onlyAudits: [ | ||
| 'network-requests', | ||
| ], | ||
| }, | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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,55 @@ | ||
| /** | ||
| * @license Copyright 2019 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 Gatherer = require('./gatherer.js'); | ||
| const pageFunctions = require('../../lib/page-functions.js'); | ||
|
|
||
| /* eslint-env browser, node */ | ||
|
|
||
| /** | ||
| * @return {LH.Artifacts['IFrameElements']} | ||
| */ | ||
jburger424 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* istanbul ignore next */ | ||
| function collectIFrameElements() { | ||
| // @ts-ignore - put into scope via stringification | ||
| const iFrameElements = getElementsInDocument('iframe'); // eslint-disable-line no-undef | ||
| return iFrameElements.map(/** @param {HTMLIFrameElement} node */ (node) => { | ||
| const clientRect = node.getBoundingClientRect(); | ||
| const {top, bottom, left, right, width, height} = clientRect; | ||
| return { | ||
| id: node.id, | ||
| src: node.src, | ||
| clientRect: {top, bottom, left, right, width, height}, | ||
jburger424 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // @ts-ignore - put into scope via stringification | ||
| isPositionFixed: isPositionFixed(node), // eslint-disable-line no-undef | ||
| }; | ||
| }); | ||
| } | ||
|
|
||
| class IFrameElements extends Gatherer { | ||
| /** | ||
| * @param {LH.Gatherer.PassContext} passContext | ||
| * @return {Promise<LH.Artifacts['IFrameElements']>} | ||
| * @override | ||
| */ | ||
| async afterPass(passContext) { | ||
| const driver = passContext.driver; | ||
|
|
||
| const expression = `(() => { | ||
| ${pageFunctions.getOuterHTMLSnippetString}; | ||
| ${pageFunctions.getElementsInDocumentString}; | ||
| ${pageFunctions.isPositionFixedString}; | ||
| return (${collectIFrameElements})(); | ||
| })()`; | ||
|
|
||
| /** @type {LH.Artifacts['IFrameElements']} */ | ||
| const iframeElements = await driver.evaluateAsync(expression, {useIsolation: true}); | ||
| return iframeElements; | ||
| } | ||
| } | ||
|
|
||
| module.exports = IFrameElements; | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.