The Firefox OS Simulator is still at an early stage of development, and isn't yet as reliable and complete as we'd like it to be.
The Firefox OS Simulator add-on is a tool that enables you to test and debug your Firefox OS app on the desktop. The code-test-debug cycle is much faster with the simulator than with a real device, and of course, you don't need a real device in order to use it.
Essentially, the Simulator add-on consists of:
- the Simulator: this includes the Firefox OS desktop client, which is a version of the higher layers of Firefox OS that runs on your desktop. The Simulator also includes some additional emulation features that aren't in the standard Firefox OS desktop builds.
- the Dashboard: a tool hosted by the Firefox browser that enables you to start and stop the Simulator and to install, uninstall, and debug apps running in it. The Dashboard also helps you push apps to a real device, and checks app manifests for common problems.
The screenshot below shows a debugging session using the Simulator.
The Dashboard is on the top-right, running inside a Firefox tab. We've added one app, a packaged app called "Where am I?". At the top-left the app is running in the Simulator. We've also connected the debugging tools, which are in the window at the bottom. You can see that we've just hit a breakpoint in the app.
This guide covers the following topics:
- how to install the Simulator add-on
- how to add, remove, and update apps
- manifest validation
- how to run the Simulator
- how to connect developer tools such as the JS debugger to apps running in the Simulator
- the limitations of the Simulator compared with a real Firefox OS device
For a practical walkthrough that shows how to use the Simulator to debug a real web app, see the Simulator Walkthrough page.
The Simulator is packaged and distributed as a Firefox add-on. To install it:
- Using Firefox, go to the Simulator's page on addons.mozilla.org.
- Click "Add to Firefox".
- Once the add-on has downloaded you will be prompted to install it: click "Install Now".
Because of the size of the add-on, Firefox may freeze for several seconds while installing it, and a dialog titled "Warning: Unresponsive script" may appear. It it does, click "Continue" to wait for installation to finish. This issue is being tracked as bug 814505.
Once you have installed the Simulator add-on, Firefox will periodically check for newer versions and keep it up to date for you.
The Dashboard opens automatically when you install the Simulator, and you can reopen it at any time by going to the "Firefox" menu (or the "Tools" menu on OS X and Linux), then "Web Developer", then "Firefox OS Simulator":
The Dashboard is the tool you use to add your app to the Simulator and run it. Here's what it looks like:
To add a packaged app to the Simulator, open the Dashboard, click "Add Directory" and select the manifest file for your app.
To add a hosted app, enter a URL in the textbox where it says "URL for page or manifest.webapp", then click "Add URL". If the URL points to a manifest, then that manifest will be used. If it doesn't, the Dashboard will generate a manifest for the URL: so you can add any website as an app just by entering its URL.
When you add an app, the Dashboard will run a series of tests on your manifest file, checking for common problems. See the section on Manifest Validation for details on what tests are run.
Unless manifest validation reveals that your app has errors, the Dashboard will then automatically run your app in the Simulator.
Once you have added an app, it will appear in the Manager's list of installed apps:
Each entry gives us the following information about the app:
- its name, taken from the manifest
- its type, which will be one of "Packaged", "Hosted", or "Generated"
- a link to its manifest file
- the result of manifest validation
It also gives us three commands:
- "Remove": remove the app from the Simulator or the Dashboard. You can undo this action as long as the Dashboard tab is open.
- "Update": use this to update the app in the Simulator after you have made changes to it. This also makes the Dashboard validate the manifest again. If you make changes to your app they will not be reflected automatically in the installed app: you will need to click "Update", and restart the Simulator if it is running.
- "Run": run the app in the Simulator
If you've connected a Firefox OS device to your computer, you'll see a fourth command labeled "Push to device".
When you supply a manifest, the Manager will run some validation tests on it. It reports three categories of problems:
- manifest errors: problems that will prevent your app from running
- manifest warnings: problems that may prevent your app from working properly
- simulator-specific warnings: features your app is using that the Simulator doesn't yet support
It summarises the problems encountered in the entry for the app: clicking on the summary provides more details.
The Dashboard will report the following conditions as errors, meaning that you won't be able to run your app in the Simulator without fixing them:
- the manifest does not include the mandatory "name" field
- the manifest is not valid JSON
- the app is a hosted app, but the type field in its manifest is "privileged" or "certified", which are only available to packaged apps
Here's the result of trying to add a manifest file with a missing "name":
The Dashboard will report the following manifest issues as warnings:
- missing icons
- the icon is less than 128 pixels: all apps submitted to the Marketplace must have at least one icon that is at least 128 pixels square
- the type field is unrecognized
- the manifest requests a permission that is unrecognized
- the manifest requests a permission which will be denied
- the manifest requests a permission for which access could not be determined
Finally, the Manager will emit warnings for apps that use features of Firefox OS not yet fully supported by the Simulator:
- the type field is "certified", but the Simulator does not yet fully supprt certified apps
- the manifest requests a permission to use an API that is not yet supported by the Simulator
There are two different ways the Simulator may be started:
- if you add, update, or remove an app, or click the "Run" button next to your app's entry, the Dashboard will automatically run your app in the Simulator
- if you click the button labeled "Stopped" on the left-hand side of the Dashboard, the Simulator will boot to the Home screen and you'll need to navigate to your app
Either way, once the Simulator is running, the button labeled "Stopped" turns green and the label changes to "Running". To stop the Simulator, click this button again.
The Simulator appears as a separate window, sized so the simulated screen area is 320x480 pixels, with a toolbar at the bottom that contains some extra features.
To simulate touch events you can click the mouse button and drag while holding the button down. So by clicking and dragging right-to-left from the Home Screen, you'll see the built-in apps, as well as any apps you have added:
You'll see three buttons on the toolbar at the bottom of the Simulator window:
From left to right, these are the Home button, the Rotation Simulation button, and the Geolocation Simulation button.
- the Home button takes you to the Home screen
- the Rotation Simulation button switches the device between portrait and landscape orientation. This will generate the deviceorientation event.
- the Geolocation Simulation button triggers a dialog asking you to share your geographic location, either using your current coordinates or supplying custom coordinates: this will be made available to your app via the Geolocation API.
Enabling console logging
If you check the "Console" box underneath the "Stopped/Running" switch, then the Error Console will be opened when you run the Simulator. Your app will be able to log to this console using the global console object.
While the Simulator is running another button appears underneath the "Console" checkbox. It is labeled "Connect...":
Click it, and you'll be taken to a page that looks like this:
Click "Connect" here and you'll see another page, this time like this:
To use the Web Console with your app, select "Main Process" in the "Connect to remote device" window.
At the moment, unfortunately, there's no single debugging target that will work with both the Web Console and the JS Debugger - but you can run two simultaneous instances of the debugging tools, one targeting "shell.xul" and the other targeting "Main Process".
If you have a Firefox OS device you can connect it to the Simulator, and can then push apps from the Dashboard to the device.
Connecting a device
To connect a device to the Simulator, you need the Android Debug Bridge (adb) to be installed, but the Simulator add-on bundles adb for you. You do, though, need to configure both the Firefox OS device and your desktop OS.
- On your Firefox OS device: open the Settings app, then
Developer. In the developer menu, check "Remote debugging".
- Set up your OS to detect the device. Instructions for this are OS-specific, and are detailed in point 3 of "Setting up a Device for Development" on the Android developer site. The vendor ID to use for Firefox OS Geeksphone devices is
Pushing apps to the device
Once you've set up the device and desktop, and connected the device to your desktop via USB, you'll see the note "Device connected." appear on the left of the Dashboard, and a new command appear in the entry for each app labeled "Push":
Click "Push", and the app will be installed on the Firefox OS device.
Troubleshooting on Linux
If you are unable to connect your device after creating udev rules, please see this bug.
Note that the Firefox OS Simulator isn't a perfect simulation.
Apart from screen size, the Simulator does not simulate the hardware limitations of a Firefox OS device such as available memory or CPU speed.
The following codecs depend on hardware-accelerated decoding and are therefore not yet supported:
- H.264 (MP4)
This means it isn't possible to use the Simulator to test video playback in apps and on websites like Youtube that rely on these codecs.
Certain APIs that work on the device won't work on the Simulator, generally because the supporting hardware is not available on the desktop. We've implemented simulations for some APIs such as geolocation, and expect to add more in future releases. However, at the moment the following APIs are not supported. Using them might throw errors or just return incorrect results:
- Ambient Light
- Network Information
- navigator.onLine and offline events