Git Product home page Git Product logo

Comments (14)

paulirish avatar paulirish commented on April 28, 2024 6

and expose all of what's in https://github.com/GoogleChrome/puppeteer/blob/master/lib/Connection.js ?

i was thinking maybe..

const connection = page.connection();

// send()
const ltree = await connection.send('LayerTree.getLayerTree');

// listen to events
await connection.send('LayerTree.enable');
connection.on('LayerTree.layerTreeChanged', data => { ... });

from puppeteer.

Everettss avatar Everettss commented on April 28, 2024 3

How will it be solved a problem with enabling some services? Currently, there are some services enabled in source code: https://github.com/GoogleChrome/puppeteer/blob/16320b7ac2943aa04420c67e9df367e7801409ea/lib/Page.js#L47-L50

So currently using page._client.send() technique it's hard to know when to use page._client.send('XYZ.enable'). For example:

 // this will work without sending enable
await page._client.send('Network.clearBrowserCache');

// this one require sending enable
await page._client.send('ServiceWorker.enable'); 
await page._client.send('ServiceWorker.unregister', {
    scopeURL: 'http://localhost:8080/',
});

Is page.connection() will cover this problem? Or it will be in documentation when to send enable?

from puppeteer.

stilliard avatar stilliard commented on April 28, 2024 2

Currently accessing the raw protocol via page._client like so:

await page._client.send('Log.enable');
page._client.on('Log.entryAdded', console.log);

But the proposed page.connection() sounds like a better solution :)

from puppeteer.

aslushnikov avatar aslushnikov commented on April 28, 2024 2

@ebidel we're working on it!

from puppeteer.

aslushnikov avatar aslushnikov commented on April 28, 2024

So having just:

var connection = page.connection()

should satisfy the usecase.

from puppeteer.

paulirish avatar paulirish commented on April 28, 2024

Here's a good usecase of why we need to punch through to raw protocol: gr2m/headless-chrome-test#1 Dev wants to toggle offline mode but is currently using simple-headless-chrome

from puppeteer.

aslushnikov avatar aslushnikov commented on April 28, 2024

@paulirish It seems to be a good idea to have offline mode in puppeteer to ease service worker testing, filed #63

from puppeteer.

paambaati avatar paambaati commented on April 28, 2024

Another use case is using the 'Network.setBlockedURLs` API. I run a crawler with an adblock list that blocks all ads; it would be much simpler to use that instead of using the intercept API and building a regex check for each of my adblock patterns.

from puppeteer.

ebidel avatar ebidel commented on April 28, 2024

Anyone working on this? Getting some requests that folks want to go off road. I'd love to recommend a paved path rather than a dirt road :)

from puppeteer.

ebidel avatar ebidel commented on April 28, 2024

Ping again :)

from puppeteer.

karanjthakkar avatar karanjthakkar commented on April 28, 2024

Can I help here?

from puppeteer.

JulianKlug avatar JulianKlug commented on April 28, 2024

Would be good to have for speed testing as well.
Accessing the time every element was loaded would be very useful.

from puppeteer.

trentmwillis avatar trentmwillis commented on April 28, 2024

Since I could also use this feature, I've opened a PR to implement this: #1445.

from puppeteer.

GregRos avatar GregRos commented on April 28, 2024

@Everettss Does enabling something twice do anything bad? It could be just best practice to enable something in your application if you want to use it.


I kind of see the problem here. Basically, puppeteer is high-level enough that it needs to keep an internal state, and sending messages via the raw protocol can break that state.

On the other hand, in JavaScript things breaking is just part of life. Raw protocol access should be something that is outlined as dangerous so people will be wary of it and that it can break internal state, but people should still be able to use it because puppeteer will never be able to implement all the functionality of the raw protocol. And if they break something, well, that's what debugging is for.

(From my perspective, using underscored members is not so much dangerous as not a feature of the library so don't use it).

Otherwise, programmers will have to use another library to send raw protocol messages, which will make the likelihood of breaking even higher.

from puppeteer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.