Skip to content
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

examples audit #178

Closed
7 of 8 tasks
paulirish opened this issue Aug 1, 2017 · 3 comments
Closed
7 of 8 tasks

examples audit #178

paulirish opened this issue Aug 1, 2017 · 3 comments
Assignees

Comments

@paulirish
Copy link
Collaborator

paulirish commented Aug 1, 2017

  • add example for saving a PDF
  • add example: navigate to google, enter search query, click the submit button
    • maybe do something with results?
    • add pavel's
  • screenshot
    • save screenshot to disk. done.
    • get and save fullpage screenshot
    • get and save emulated iphone screenshot
  • loadurlwithoutcss
    • update so that it works.
  • unrandomize
    • what is this example actually doing? delete?
  • pagecallback
    • needs comments to explain what the example is actually doing.
  • detectsniff
    • at least the setTimeout should be done via an await.
    • would be nice to use a proxy instead of defineGetter, but that's lower priority
    • i'd recommend a function declaration for passing into evaluateOnNewDocument. we use that convention in lighthouse to make it more clear that its' a pageFunction. (colorWheel does this already :)
  • waitFor example
@ebidel
Copy link
Contributor

ebidel commented Aug 1, 2017

For examples, we should start running them through the linter and clean up the code a bit so they're consistent and using es6. e.g. use const/let and a top-level async func to remove the mix of .then() and async/await. I think that's less common to see.

For example, this:

var browser = new Browser({headless: false});
browser.newPage().then(async page => {
    page.setRequestInterceptor(request => {
        if (request.url.endsWith('.css'))
            request.abort();
        else
            request.continue();
    });
    var success = await page.navigate(address);
    if (!success)
        console.log('Unable to load the address!');
    browser.close();

to maybe to something like this:

(async () => {

const browser = new Browser({headless: false});
const page = await browser.newPage();
page.setRequestInterceptor(request => {
  request.url.endsWith('.css') ?  request.abort() : request.continue();
});

const success = await page.navigate(address);
if (!success) {
  console.log('Unable to load the address!');
}
browser.close();

})();

aslushnikov pushed a commit that referenced this issue Aug 2, 2017
This patch enables lint in `examples/` folder.
@JoelEinbinder JoelEinbinder self-assigned this Aug 2, 2017
JoelEinbinder added a commit that referenced this issue Aug 2, 2017
JoelEinbinder added a commit that referenced this issue Aug 2, 2017
aslushnikov pushed a commit that referenced this issue Aug 2, 2017
This was referenced Aug 8, 2017
@JoelEinbinder
Copy link
Collaborator

Do we want to keep the phantom examples? They feel out of place.

aslushnikov added a commit that referenced this issue Aug 8, 2017
This patch:
- removes old phantom-js examples
- adds an example to load page without images

References #178
@ebidel ebidel mentioned this issue Aug 9, 2017
6 tasks
@aslushnikov aslushnikov added this to the v0.1 milestone Aug 9, 2017
aslushnikov pushed a commit that referenced this issue Aug 11, 2017
Add google search example.

References #178
@aslushnikov
Copy link
Contributor

I can't come up with a simple yet illustrative example for page.addBinding (former inPage callback).

However, documentation has a few examples which might be good enough.
Closing this for now.

P.S. Feel free to PR an example with page.addBinding / share an idea for it if any!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants