Is a browser's console an interface to the web API? - google-chrome

From my research, the browser gives us some features that the JavaScript engine itself doesn’t provide: a Web API. This includes the DOM API, setTimeout, HTTP requests, and so on.
So because browsers run functions that are not supported in the JavaScript engine, like setTimeout for example, is it correct to say that the browser's terminal is an interface to the web and Web API.
Does that make sense, is that a constructive way to think about it?

I think that the WebAPI and the Console are two separate Things that both plug into the js-engine of your browser. The Console is not able to directly access the DOM for example, it can only execute javascript lines, that access the DOM internal and return a specific result (again returned via javascript)

Related

How can I use a Chrome browser extension to monitor and parse the output in the devtools console?

I am building a chrome extension that is supposed to aid in the debugging of software that runs on top of a website. This software can have a debug mode enabled that will cause a lot of output to the console using console.log.
I want to use my chrome extension to parse the console messages and show the important events in the UI for quicker debugging. However, I am not seeing a way to simply do this with the API. Is there something I am missing? Should I override the console.log function? How would I go about doing that?
There are two methods.
Override console.log, console.warn, and so on, in page context (this is important!). There are lots of examples (here's a random one). In your case it'll be even simpler as you'll just call the original method and transfer the arguments via CustomEvent to your content script (example), which will accumulate them.
Use chrome.debugger API with Console.messageAdded or Runtime.consoleAPICalled events. This will show a message bar in the entire browser about debugger being active unless you hide it globally by running chrome with --silent-debugger-extension-api command line, but that's somewhat dangerous if you accidentally install a malicious extension that uses chrome.debugger API.

does selenium knows to analyse the browser activity log or network activity?

I want to verify an ajax call was triggered
and also I want to detect a call to external custom protocol was triggered.
I think I will be able to read that data in this way only.
No, Selenium is not meant for such use case. Selenium WebDriver is just meant for simulating user interactions with web app. If you want intercept network requests, add custom headers etc during your selenium tests, you can use a proxy. BrowserMob proxy is popular for such use cases with selenium tests. It has a REST API too.

Tail like logging window for my web app?

I am developing an app using Phalcon and would like to create a popup logging window that displays any logging type information when I am logged in (such as DB calls and exceptions).
Alot of my app is driven by Ajax calls. Is it going to be possible to have a window that I can popup on my main app that uses a tail like method of displaying this information?
How would I go about this? I'm not entirely sure that what I want is possible with the Ajax calls as they are done in a different request. I can't find anything on the internet as to how I would go about this so any help would be great.
Well, you didn't said that explicitly, but I imagine that you want this just for development purposes. If so, you can log useful info to a method that checks if it should send that log to the browser based on some criteria (e.g. logged in user is you, the app is in a dev enviroment, etc) and then use Phalcon's FirePHP log adapter to send to log the information to the browser.
You'll just need to have some FirePHP extension in your Firefox or Chrome to be able to see the information under your JavaScript console. And yes, it works well with Ajax calls too.
Let me know if you need further explanations on this...
I think you are looking for a debug toolkit.. There are lot of toolkit available on packagist.org and phalconist.com. I personally like this phalcon-debug-widget toolkit that you may try.

Is it possible to do OAuth on WP8 without embeded browser?

This is for doing OAuth with the Pocket API, it specifically states that using an embedded webview is a violation of the terms of use, all OAuth examples I can find on WP8 seem to rely on the embedded webbrowser to do the authentication.
Is it not possible to use the default browser in WP8 to do the authentication and then redirect back into the App? I have done this in Android before. Thanks.
Well, if you read their documentation, it says that you need to provide a redirect URL. I am not sure if it will work, but you could try adding URI association to your application and specify callback URL that will return back to your app.
Then, when your application is reactivated from the default browser, you should know that the user has authorized it.
Thus you could use WebBrowserTask for that, but I am unaware if you can call local app-URI from browser.

How to view request response for non Ajax Calls

I am working on a Web based application where the user interface is made using Jquery and the backend was developed using Java / Java EE.
On the user interface once I click on the submit button, the request goes and
the response comes from the back end. (This is not an AJAX call)
Is it possible to see what data went as request and how the response came back from the back end? Are there any such tools to view the request / response if it's not an AJax Call?
By the way I am using Chrome and Apple browsers.
Use the Network tab of Web Inspector (Chrome/WebKit) or Web Console (Firefox) or the Net tab (Firefox with Firebug)
Another option than using a browsers native network inspector (which btw DOES work for non-Ajax requests), is to use an intercepting proxy.
Burp Proxy is particular nice. It allows you to see, hold and if needed modify both the request and the response between the browser and the server. You do need to setup your browser to use a proxy. It has a somewhat steeper learning curve than the browser's native network inspectors, but once you get the hang of it it's quite an invaluable tool.