How to get response time of a request using chrome api's? - javascript

I am trying to get all of the response times of the requests on a chrome tab using just the chrome api. I see that the chrome.webRequest has an "onCompleted" event handler that has a timeStamp associated when the event fires. Would this accomplish what I want? Is there another api that is better suited? I want the response times that you would see in the network tab of dev tools, but using an api so I can store that data.

Related

Chrome devtools network tab - websocket message source/initiator

I have a websocket that sends some messages to my server and I would like to find out what code is causing the messages to be send.
I can see the websocket and its messages by opening the chrome devtools, going to the network tab, looking for the request of type websocket, clicking on it and going to the tab messages. When looking at the requests in the network tab itself, they have a column Initiator, which links to the code having initialized the request, the same sadly isn't true for the messages overview.
How can I get the same information for each individual message?
Not possible now in Network panel now. I've created a feature request for the Chrome DevTools team in https://crbug.com/1348694. Please leave additional comment on your use case there.
However, one thing you can try is to use debug(function) in the Console, to break on everytime when message is sent. In your case, it could be debug(ws.send).
https://developer.chrome.com/docs/devtools/console/utilities/#debug-function

Can we access responses of Ajax calls from Network tab of chrome driver by javascript?

Can we access the responses tab of Network in Chrome Dev Tools. I am trying to access the response of Ajax calls using selenium-python using Chrome Webdriver.
I have tried using the performance.getEntries() which returns only the requests made not their responses. Is there a way to access responses of ajax calls?

Stop Logging of Outgoing Browser Requests

I have an html page that is meant to be used in an iframe, this page makes an ajax request based on a received message (using postMessage from the parent). I can see this request using the Firefox's Network Monitor even though it is happening in the iframe. I assume all browsers have similar capabilities.
The request contains sensitive information that shouldn't be logged/saved. Is there any way to prevent this request from ever being seen (by the browser or through any other method)?

How can I see webrequests Facebook sends me

I am wondering how I can see exactly what webrequests I am receiving from Facebook?
Lets say that we are on Facebook event and I want to invite all my 1000 friends.
I start clicking all my friends one by one and at some point Facebook sets a limit of 498 and then I continue to do all the clicks until I reach 498 and then it says you cant invite anyone else.
Facebook to do this at some point sends back an ajax.php page as a packet and sets this limit. This ajax php page i'm trying to find somehow.
I've tried some ajax jQuery capture Chrome extensions but I dont quite understand them much.
Do you have any idea of how I can track any ajax php request from Facebook to my browser to set this limit?
I am using Chrome Extension Live HTTP Headers
and this shows me anything that Facebook webrequest is "POST" in my browser.
But i dont think its actually all of them.
Because its only loading the photos of the chat
and some thread updates.
Here is a video of what limitation is showing in my frame of friends invite in facebook.
Youtube Video Here.
Press F12 and find the network requests section of your browser's dev tools.
http://www.devtoolsecrets.com/secret/general-finding-the-development-tools.html
I think you are misunderstanding the process. Web servers don't send requests to web browsers. They only respond to requests sent from the web browser.
When you click to invite friends you are sending an ajax request to Facebooks server. That ajax request passes the information about the event, you and your friend to a method on the server. Part of that method is to check and see if the limit on invitations has been exceeded. If not it sends your invitation and sends a response to your ajax request showing this person was invited. However if the limit has been reached the invitation is not sent and the response comes back from your ajax request stating that the limit has been exceeded.
If you know what your doing, you use Chrome or Firefox developers tools to debug javascript and follow the ajax request to the server and the response from the server. But this is difficult with the minified javascript. There are tools to deminify the javascript making it easier.
However, if you're looking for a way around the invitation limit. It's not going to happen. This all occurs on the Facebook servers to which you do not have access.
Try to use Fiddler (http://www.telerik.com/fiddler). With Fiddler you can see all requests (also HTTPS requests with an intermediate certificate), modify those or simply replay requests. It's worth a try and a must have for each web developer

Tracking http requests sent by the browser using javascript/jquery

Using javascript or jquery, is there a way to track the http requests(including headers, parameters, etc.), sent by a webpage? What I want to achieve is something similar to the functionality of the 'network' tab of Google Chrome's developer console. All the solutions I found was either tracking Ajax requests or requests made using javascript(using XMLHttpRequest Object). This functionality should also be cross browser compatible.
You have three choices.
Make sure you know all the places where a request can get fired, and attach an event to it, say RequestFired. And bind the onRequestFired event in your JavaScript / jQuery code.
Go through the Network Developers document or each browser and based on the browser, execute it. This feature may not be available in older browsers like Internet Explorer 7 and 8.
Google Developers Doc
Firefox Network Information API
NetworkInformation.connection
If it is for a particular server, read the Server Log using a server side script and access it using an endpoint. You can use long polling method and fetch the contents of the log, may be this way:
// jQuery
$(document).ready(function () {
setInterval (function () {
$("#log").load("/path/to/endpoint.log");
}, 5000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<h3>Logs</h3>
<div id="log"></div>
You can't track everything.
For example some of the calls in Xmlhttprequest are transparent (301 HTTP codes) and can't be handle by javascript client side.
see the XMLHTTrequest specs: http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send-method
This among a few other reasons. if you want to track the requests of a "webpage" it's better to use the development tools of that browser or packet capturing.
On the userExperience side you can only do very limited things.
It can be done, if you are implementing a single page web-application with a framework like AngularJS. There you can do that using HTTP interceptors.
Other than that, you can only track Ajax requests, but not JavaScript requests.

Categories