-
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
README: Reorganization and new "Using programmatically" section #1721
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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,59 @@ | ||
# Architecture | ||
|
||
_Some incomplete notes_ | ||
|
||
## Components | ||
|
||
* **Driver** - Interfaces with [Chrome Debugging Protocol](https://developer.chrome.com/devtools/docs/debugger-protocol) ([API viewer](https://chromedevtools.github.io/debugger-protocol-viewer/)) | ||
* **Gatherers** - Requesting data from the browser (and maybe post-processing) | ||
* **Artifacts** - The output of gatherers | ||
* **Audits** - Non-performance evaluations of capabilities and issues. Includes a raw value and score of that value. | ||
* **Metrics** - Performance metrics summarizing the UX | ||
* **Aggregations** - Pulling audit results, grouping into user-facing components (eg. `install_to_homescreen`) and applying weighting and overall scoring. | ||
|
||
### Internal module graph | ||
|
||
![graph of lighthouse-core module dependencies](https://cloud.githubusercontent.com/assets/39191/19367685/04d4336a-9151-11e6-9ebb-3b87bdb09a4c.png) | ||
|
||
`npm install -g js-vd; vd --exclude "node_modules|third_party|fs|path|url|log" lighthouse-core/ > graph.html` | ||
|
||
## Protocol | ||
|
||
* _Interacting with Chrome:_ The Chrome protocol connection maintained via [WebSocket](https://github.com/websockets/ws) for the CLI [`chrome.debuggger` API](https://developer.chrome.com/extensions/debugger) when in the Chrome extension. | ||
* _Event binding & domains_: Some domains must be `enable()`d so they issue events. Once enabled, they flush any events that represent state. As such, network events will only issue after the domain is enabled. All the protocol agents resolve their `Domain.enable()` callback _after_ they have flushed any pending events. See example: | ||
|
||
```js | ||
// will NOT work | ||
driver.sendCommand('Security.enable').then(_ => { | ||
driver.on('Security.securityStateChanged', state => { /* ... */ }); | ||
}) | ||
|
||
// WILL work! happy happy. :) | ||
driver.on('Security.securityStateChanged', state => { /* ... */ }); // event binding is synchronous | ||
driver.sendCommand('Security.enable'); | ||
``` | ||
|
||
* _Debugging the protocol_: Read [Better debugging of the Protocol](https://github.com/GoogleChrome/lighthouse/issues/184). | ||
|
||
## Gatherers | ||
|
||
* _Reading the DOM:_ We prefer reading the DOM right from the browser (See #77). The driver exposes a `querySelector` method that can be used along with a `getAttribute` method to read values. | ||
|
||
## Audits | ||
|
||
The return value of each audit takes this shape: | ||
|
||
```js | ||
Promise.resolve({ | ||
name: 'audit-name', | ||
description: 'whatnot', | ||
// value: The score. Typically a boolean, but can be number 0-100 | ||
value: 0, | ||
// rawValue: Could be anything, as long as it can easily be stringified and displayed, | ||
// e.g. 'your score is bad because you wrote ${rawValue}' | ||
rawValue: {}, | ||
// debugString: Some *specific* error string for helping the user figure out why they failed here. | ||
// The reporter can handle *general* feedback on how to fix, e.g. links to the docs | ||
debugString: 'Your manifest 404ed', | ||
}); | ||
``` |
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.
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.
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.
IMO this file can get merged with API-and-internals.md
and since readme and contributing are in root, i kinda prefer keeping this md file there rather than docs/. wdyt?
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.
Up to you. I figured we'd have more in the future and wanted to declutter.
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.
There's also https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch, which we could leverage someday.
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.
Moved and renamed that file to "headless-chrome.md". It didn't contain anything but headless Chrome stuff :)
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.
sg