Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

This branch is 1 commit behind senchalabs:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
src
README.md

README.md

RemoteJS

What it is

RemoteJS is an application that works as a remote JavaScript console. Think of Web Inspector running on your workstation, debugging code running on your mobile phone or tablet device. There are two versions of the application. One has a GUI and is meant to be run on a desktop, the other is a Python application that runs on a shell. The latter is useful for quick debugging on a text environment, but is particularly designed for scripting and test automation.

Supported platforms

The applications run on Windows, Mac OS X, and Linux, and should run on any platform that is simultaneously supported by the Android Debug Bridge (adb) and Python (in the non-GUI version). Currently, it is able to debug code on any devices running Android (2.1 or 2.2). The Android emulator is also supported, allowing you to debug your code without a physical device.

Requirements

The Android SDK is necessary to run the application. In particular, the adb tool is required to be in your $PATH. To run the shell version, a Python environment is required.

Features

When you launch RemoteJS (GUI version), it will try to detect all attached devices. If there is none, it will wait for the first to be connected and make it the target device. If there' more than one device attached, you'll be asked to select one.

After your target device is finally set, you can simply unplug it and the application will automatically detect the disconnection. Again, if there's only one device left, that will be chosen for you. If there are at least two, then you'll need to select one again, otherwise the console will wait for one to be attached indefinitely.

After all is set up, most of the times you want to debug a specific web page. In order to load an URL, enter it:

www.sencha.com

The page will start being loaded on the device and the message Opening www.sencha.com will be shown on the console. Expressions starting with www., http://, https:// or ftp:// are automatically identified as URL's.

You can print values with the console.log function:

> for (var x in document) console.log(x)
bgColor
alinkColor
width
...

Multiple instructions are also supported:

> var a = [1,2,3]; console.log(a)
1,2,3

Sometimes you might get an error:

> console.log(documant.title)
ReferenceError: Can't find variable: documant

To recover previously entered expressions, press Arrow/Page Up and you will be able to browse the history. Arrow/Page Down works in the usual opposite way, giving you the expressions entered after the current one. The history is stored when you quit the application, which means it will still be available when you start a new session.

The non-GUI version works in a very similar way. You can type python remotejs.py -h to check the usage.

How it works

When the application is started, it automatically installs an Android package (apk called RemoteJS on your selected device. If a package already exists, it is uninstalled first. This ensures total compatibility with the remote console.

This proxy activity will be the one receiving intents requesting the execution of the JavaScript code. The evaluation results are then logged in Android. Meanwhile, our console is already listening and filtering that very same log through adb and logcat. The processed output is finally presented on the screen.

Implementation details

RemoteJS is a native application, but in reality there's only a very thin layer of native code. It is only necessary to deal with adb at a system level. This component of the program is written in C++ and Qt. In particular, the QtWebKit module is crucial, since the rest of the application is written with HTML, JavaScript and CSS.

The thin system-level functionality is exported from the Qt space to the web view through a very simple API. All the logic is then implemented on the JS side, including the entire console window, turning the native nature of the application into hybrid.

Something went wrong with that request. Please try again.