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
docs(auth): add setCookie example #11473
Conversation
|
||
See [a working demo at /docs/recipes/auth](./recipes/auth). | ||
|
||
View our full documentation for using [Lighthouse along with Puppeteer](https://github.com/GoogleChrome/lighthouse/blob/master/docs/puppeteer.md). | ||
|
||
You may want to use Puppeteer's [`page.setCookie`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetcookiecookies). |
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.
we don't really want to encourage anyone do to this
@@ -32,7 +30,7 @@ const result = await lighthouse('http://www.example.com', { | |||
}); | |||
``` | |||
|
|||
You could also set the `Cookie` header, but beware: it will [override any other Cookies you expect to be there](https://github.com/GoogleChrome/lighthouse/pull/9170). | |||
You could also set the `Cookie` header, but beware: it will [override any other Cookies you expect to be there](https://github.com/GoogleChrome/lighthouse/pull/9170). For a more flexible cookie-based approach, use [puppeteer (Option 1)](./recipes/auth/README.md) instead. |
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.
nudge them toward option 1 so they don't end up asking for #9170 all over again :)
@@ -1,5 +1,13 @@ | |||
# Using Puppeteer with Lighthouse | |||
|
|||
## Recipes | |||
|
|||
### [Using Puppeteer for authenticated pages](./recipes/auth/README.md) |
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.
this seemed much more important to place at the top than injecting stylesheets
if (page && page.url() === url) { | ||
// Note: can't use page.addStyleTag due to github.com/GoogleChrome/puppeteer/issues/1955. |
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.
wasn't true anymore
@@ -19,32 +27,16 @@ const browser = await puppeteer.launch({ | |||
defaultViewport: null, | |||
}); | |||
|
|||
// Wait for Lighthouse to open url, then customize network conditions. |
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.
comments were describing something that wasn't happening...
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.
LGTM!
@@ -1,5 +1,13 @@ | |||
# Using Puppeteer with Lighthouse | |||
|
|||
## Recipes | |||
|
|||
### [Using Puppeteer for authenticated pages](./recipes/auth/README.md) |
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.
would these be better as bullet points or something? IMO they look kind of weird as linked headings with no content, but the formatting is also not terribly important.
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.
I have no strong preference, I was just matching the style used for the custom gatherer one, and I see the value of bumping their visual prominence a bit over regular text-sized bullets.
Do they look weird enough to you to change? :) I'll accept whatever suggestion you put up
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.
I see the value of bumping their visual prominence a bit over regular text-sized bullets.
Do they look weird enough to you to change? :) I'll accept whatever suggestion you put up
No suggestion, sorry, and I figured that was the reasoning. It is a little awkward looking but it's also functional and clear in what that function is, so that's why I said not terribly important :)
Summary
Promised followup to #9170, adds a setCookie example and updates some of our pptr docs. @paulirish's prior PR #10277 did some of this already, so just a few more minor tweaks.
Related Issues/PRs
closes #11470