assaf / zombie

Insanely fast, full-stack, headless browser testing using node.js
http://zombie.js.org/
MIT License
5.65k stars 518 forks source link

XMLHttpRequest hard to trace; Are contributions welcome? #1194

Open unblu-kschiess opened 5 years ago

unblu-kschiess commented 5 years ago

With the current API, it is very hard to know what is going on with XHR requests inside the page. You can hook 'xhr' event on the browser/window, but that only gives you eventName (loadstart, load, error, ...) and the url that was accessed. People (like me) who need precise timing information can hook the resource pipeline - only then it is really hard to figure out something is a XHR request.

Ideally, I would like to receive events on a target that is accessible to me, containing more information but at the very least:

You could for example make this look as follows:

const browser = new Browser()
browser.on('xhrDebug', (event, url, xhr) => {
  // Do something with the event here: xhr uniquely identifies this request
})

I realise that this would be the first such API that is only targeted at zombie users (non-web API). Are you interested in such a contribution at all?