Using Weinre

Weinre (pronounced like “winery”) is a lovely tool to provide JavaScript console and DOM tree inspection for remote devices that don’t ship with a remote debugger. I’ve been using it for quite a while especially when I got issues with Android’s legacy WebView. (I say legacy, because the new WebView on Android 4.4 KitKat is now implemented with Chromium and has built-in remote debugger, but the older one doesn’t.) I’d like to discuss some things to watch out for when using Weinre as well as some tips.

Fundamentals

This post assumes you already know the basics of getting Weinre to run. I won’t cover anything related to installation of start up. But before you start there’s a few very important things you need to remember. I’ve been using version 2.0.0 at time of this writing.

Issues

Remote target

Tips

Aside from the tips I have already mentioned above and some common Chrome tricks like $0, I want to note that even though Weinre does not provide a JavaScript debugger, it at least provides a functional JavaScript console that runs in the same environment as your device. That means you can use it to inspect APIs, DOMs and your JavaScript objects. Oftentimes your JavaScript variables and objects are not available to the global scope, but you could try to expose the ones you need in your code to global score by assigning them to a global variable without using the var keyword eg. g = this;. Then you can inspect them in the console.

Tags