--- title: Simulador Firefox OS 1.1 slug: Tools/Firefox_OS_1.1_Simulator tags: - Ferramentas - Firefox OS - Guia(2) - Guía translation_of: Tools/Firefox_OS_1.1_Simulator original_slug: Tools/Simulador_Firefox_OS_1.1 ---
{{ToolsSidebar}}

Esta página descreve o "velho" Firefox OS Simulator. Você deve apenas usar se você desenvolve apps para Firefox 1.1, e que só pode ser instalado no Firefox 24 ou Firefox 25.

Se você desenvolve apps para Firefox OS 1.2 ou superior, invés disso você precisa usar o App Manager.

Se você precisar de ajuda, tente perguntar na lista ou em dev-developer-tools mailing list ou em #devtools on irc.mozilla.org.

Resumo

O complemento Firefox OS Simulator é uma ferramenta que permite você testar e depurar seu aplicativo Firefox OS no seu desktop. O ciclo de codificar-testar-depurar é muito mais rápido com o simulador do que com um dispositivo real, e claro, você não precisa de um dispositivo real para usar.

Essencialmente, o complemento Simulador consiste em:

O screenshot abaixo mostra uma sessão de depuração usando o Simulador.

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 panel at the bottom. You can see that the Console pane displays messages about the app.

This guide covers the following topics:

For a practical walkthrough that shows how to use the Simulator to debug a real web app, see the Simulator Walkthrough page.

Installing the Simulator add-on

The Simulator is packaged and distributed as a Firefox add-on. To install it:

  1. Using Firefox, go to the Simulator's page on addons.mozilla.org.
  2. Click "Add to Firefox".
  3. 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. If it does, click "Continue" to wait for installation to finish. This should not occur from Firefox 27 onwards.

Firefox will periodically check for newer versions of the Simulator add-on once it's installed, updating it automatically.

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:

Adding, removing and refreshing apps

Adding apps

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.

The Dashboard will then automatically run your app in the Simulator unless the Manifest Validation Process discovers an error in your app.

Managing apps

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:

It also gives us four commands:

Refresh App from the Simulator window: you can update and reload an app directly from the Simulator window using the menubar action or its associated shortcut while the app is running.

Manifest validation

When you supply a manifest, the Manager will run some validation tests on it. It reports three categories of problems:

It summarizes the problems encountered in the entry for the app; clicking on the summary provides more details.

Manifest errors

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:

Here's the result of trying to add a manifest file with a missing "name":

Manifest warnings

The Dashboard will report the following manifest issues as warnings:

Simulator-specific warnings

Finally, the Manager will emit warnings for apps that use features of Firefox OS not yet fully supported by the Simulator:

Running the Simulator

There are two different ways the Simulator may be started:

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 and a menubar at the top 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:

Simulator toolbar

In the bottom toolbar, from left to right, there are the Home button, the Screen Rotation button, and the Geolocation button.

Simulator menubar

In the top menubar, you can access some useful commands to make development more efficient:

The keyboard shortcut for the "App Refresh" command makes it possible to iteratively develop an app much like a web page:

"Refresh App and Clear Data" hidden shortcut: sometimes it's useful to clear data that the Simulator has stored for an app, so the Simulator contains a hidden shortcut, Shift - Ctrl/Cmd - R, that will refresh the running app while clearing the following data:

  • localStorage / sessionStorage

  • cookies

  • indexedDB

  • appCache

Attaching developer tools

You can attach developer tools to the Simulator to help debug your app. At the moment you can only attach the JavaScript Debugger, the Web Console, the Style Editor, the Profiler, and the Network Monitor, but we're working on adding support for more developer tools.

Some of these tools are only available in Beta, Aurora, or Nightly builds of Firefox.

To attach developer tools to the Simulator, click the "Connect" button for an app:

The Dashboard will then open a developer toolbox pane at the bottom of the Dashboard tab and connect it to the app:

Web Console

The app can log to this console using the global console object, and it displays various other messages generated by the app: network requests, CSS and JS warnings/errors, and security errors. (Learn more about the Web Console.)

Debugger

Using the Debugger, you can step through JavaScript code that is running in the connected app, manage breakpoints, and watch expressions to track down errors and problems faster. (Learn more about the Debugger.)

Style Editor

You can view and edit CSS files referenced in the app using the connected Style Editor. Your changes will be applied to the app in real time, without needing to refresh the app. (Learn more about the Style Editor.)

Profiler

Using the Profiler tool connected to the app, you can find out where your JavaScript code is spending too much time. The Profiler periodically samples the current JavaScript call stack and compiles statistics about the samples. (Learn more about the Profiler.)

Network Monitor

Thanks to the new Network Monitor, you can analyze the status, headers, content, and timing of all the network requests initiated by the app through a friendly interface. (Learn more about the Network Monitor.)

Receipts

If you are developing a paid app, you should test your receipt validation code (e.g., the code that verifies that a user has already purchased the app or has been issued a refund and then informs the user and locks or unlocks app features accordingly) on a valid (cryptographically signed) receipt.

Thanks to the "Receipts" menu in each app entry on the Simulator Dashboard, you can install an app with a "Valid", "Invalid", or "Refunded" test receipt. Simply select the type of receipt you wish to test, and the Dashboard will retrieve a test receipt of that type from the Marketplace receipt service and reinstall the app with that receipt in the Simulator:

Push to device

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 the device, follow the instructions in the guide to connecting a Firefox OS device to the desktop. Note that you don't have to install ADB, as the Simulator add-on includes it already.

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.

Manual Steps:

  • Once you’ve pushed the app to the device, you need to manually close and restart it again to get updated content.

  • If you update anything in the manifest (e.g., app name, orientation, type, permissions), you need to reboot the operating system for those changes to have effect.

Firefox OS Device Connection Confirmation

On every device reboot, the first "Push" request needs to be confirmed on the device:

Troubleshooting on Linux

If you are unable to connect your device after creating udev rules, please see this bug.

Limitations of the Simulator

Note that the Firefox OS Simulator isn't a perfect simulation.

Hardware limitations

Apart from screen size, the Simulator does not simulate the hardware limitations of a Firefox OS device such as available memory or CPU speed.

Audio/video codecs

The following codecs depend on hardware-accelerated decoding and are therefore not yet supported:

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.

Unsupported APIs

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:

Getting help

If you have a question, try asking us on the dev-developer-tools mailing list or on #devtools on irc.mozilla.org.

How to enable verbose logging

Use about:config to create the preference extensions.r2d2b2g@mozilla.org.sdk.console.logLevel, set it to the integer value 0, and disable/reenable the add-on. Additional messages about the Simulator's operation will appear in the Error Console (or Browser Console in newer versions of Firefox).