Firefox OS Simulator

  • Revision slug: Tools/Firefox_OS_Simulator
  • Revision title: Firefox OS Simulator
  • Revision id: 439687
  • Created:
  • Creator: Mykmelez1
  • Is current revision? No
  • Comment

Revision Content

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.

If you find any bugs, please file them on GitHub, and if you have any questions, try asking on the dev-developer-tools mailing list or on #devtools on irc.mozilla.org.

Read how to enable verbose logging and get the latest preview build in the Getting help section.

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 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. 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:

 

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.

Unless manifest validation reveals that your app has errors, the Dashboard will then automatically run your app in the Simulator.

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:

  • 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 four commands:

  • "Refresh": use this to update and reload 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 refresh the app to apply the changes.
  • "Connect": use this to connect developer tools to the selected app. The Dashboard will start the Simulator and app if they aren't already running.
  • "Remove" ("X"): use this to remove the app from the Simulator and the Dashboard. You can undo this action as long as the Dashboard tab is open.
  • "Receipt": use this to test receipt verification for paid apps. After you select a type of receipt to test, the app will be reinstalled with a test receipt of the given type.

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:

  • manifest errors: problems that will prevent your app from installing or 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.

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:

  • 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
  • common appCache errors (packaged apps can't use appCache, requests to the manifest URL return an HTTP redirect or an HTTP error status)

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:

  • 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

Simulator-specific warnings

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 support certified apps
  • the manifest requests a permission to use an API that is not yet supported by the Simulator

Running the Simulator

There are two different ways the Simulator may be started:

  • if you add an app or click the "Refresh" or "Connect" 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 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, these are the Home button, the Screen Rotation button, and the Geolocation button.

  • the Home button takes you to the Home screen (or to the task list if you keep it pressed for a couple of seconds)
  • the Screen Rotation button switches the device between portrait and landscape orientation. This will generate the orientationchange event.
  • the Geolocation 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.

Simulator menubar

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

  • File -> Quit (Ctrl/Cmd - Q): shut down the Simulator
  • App -> Refresh (Ctrl/Cmd - R): refresh the running app

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

  • make a change to the code (and rerun your build tool if needed, e.g. volo / yeoman / grunt)
  • type the keyboard shortcut to refresh the app running in the Simulator

"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 to 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:

  • MP3
  • AAC
  • H.264 (MP4)
  • WebM

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

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.

If you find any bugs, please file them on GitHub. 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 addon. Additional messages about the Simulator's operation will appear in the Error Console (or Browser Console in newer versions of Firefox).

How to get the latest preview build

The latest preview build can be downloaded from the following URLs:

Preview builds are less stable and complete than release builds, so use them with caution.

 

Revision Source

<div class="note">
  <p>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.</p>
  <p>If you find any bugs, please <a href="https://github.com/mozilla/r2d2b2g/issues?state=open">file them on GitHub</a>, and if you have any questions, try asking on the <a href="https://lists.mozilla.org/listinfo/dev-developer-tools">dev-developer-tools mailing list</a> or on <a href="irc://irc.mozilla.org/#devtools">#devtools on irc.mozilla.org</a>.</p>
  <p>Read <a href="#Simulator-verbose-logging" title="#Simulator-verbose-logging">how to enable verbose logging</a> and <a href="#Simulator-latest-preview-build" title="#Simulator-latest-preview-build">get the latest preview build</a> in the <a href="#Unsupported-APIs" title="#Unsupported-APIs">Getting help</a> section.</p>
</div>
<p>The Firefox OS Simulator add-on is a tool that enables you to test and debug your <a href="/en-US/docs/Apps" title="/en-US/docs/Apps">Firefox OS app</a> 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.</p>
<p>Essentially, the Simulator add-on consists of:</p>
<ul>
  <li><strong>the Simulator</strong>: this includes the <a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client" title="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client">Firefox OS desktop client</a>, which is a version of the higher layers of <a href="/en-US/docs/Mozilla/Firefox_OS" title="/en-US/docs/Mozilla/Firefox_OS">Firefox OS</a> that runs on your desktop. The Simulator also includes some <a href="#Simulator-toolbar" title="#Simulator-toolbar">additional emulation features</a> that aren't in the standard Firefox OS desktop builds.</li>
  <li><strong>the Dashboard</strong>: 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.</li>
</ul>
<p>The screenshot below shows a debugging session using the Simulator.</p>
<p>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.</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5513/Simulator-overview-4.0.png" style="width: 900px; height: 632px;" /></p>
<p>This guide covers the following topics:</p>
<ul>
  <li><a href="#Installing" title="#Installing">how to install the Simulator add-on</a></li>
  <li><a href="#Adding-updating-removing" title="#Adding-updating-removing">how to add, remove, and refresh apps</a></li>
  <li><a href="#Manifest-validation" title="#Manifest-validation">manifest validation</a></li>
  <li><a href="#Running-the-Simulator" title="#Running-the-Simulator">how to run the Simulator</a></li>
  <li><a href="#Attaching-developer-tools" title="#Attaching-developer-tools">how to connect developer tools such as the JS debugger to apps running in the Simulator</a></li>
  <li><a href="#Simulator-receipts" title="#Simulator-receipts">how to get test receipts for a paid app</a></li>
  <li><a href="#Push-to-device" title="#Push-to-device">how to push apps to a connected device</a></li>
  <li><a href="#Limitations" title="#Limitations">the limitations of the Simulator compared with a real Firefox OS device</a></li>
</ul>
<div class="geckoVersionNote">
  <p>For a practical walkthrough that shows how to use the Simulator to debug a real web app, see the <a href="/en-US/docs/Tools/Firefox_OS_Simulator/Simulator_Walkthrough" title="/en-US/docs/Tools/Firefox_OS_Simulator/Simulator_Walkthrough">Simulator Walkthrough</a> page.</p>
</div>
<h2 id="Installing_the_Simulator_add-on"><a name="Installing">Installing the Simulator add-on</a></h2>
<p>The Simulator is packaged and distributed as a Firefox add-on. To install it:</p>
<ol>
  <li>Using Firefox, go to <a href="https://addons.mozilla.org/en-US/firefox/addon/firefox-os-simulator/" title="https://addons.mozilla.org/en-US/firefox/addon/firefox-os-simulator/">the Simulator's page on addons.mozilla.org</a>.</li>
  <li>Click "Add to Firefox".</li>
  <li>Once the add-on has downloaded you will be prompted to install it: click "Install Now".</li>
</ol>
<p>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 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=814505" title="https://bugzilla.mozilla.org/show_bug.cgi?id=814505">bug 814505</a>.<br />
  <br />
  Once you have installed the Simulator add-on, Firefox will periodically check for newer versions and keep it up to date for you.</p>
<p>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":</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5141/simulator-open-on-windows-7.png" style="width: 453px; height: 533px; display: block; margin-left: auto; margin-right: auto;" /><br />
  The Dashboard is the tool you use to add your app to the Simulator and run it. Here's what it looks like: <img alt="" src="https://mdn.mozillademos.org/files/5491/dashboard-4.0.png" style="width: 1044px; height: 650px;" /></p>
<p>&nbsp;</p>
<h2 id="Adding.2C_removing.2C_and_refreshing_apps"><a name="Adding-updating-removing">Adding, removing, and refreshing apps</a></h2>
<h3 id="Adding_apps">Adding apps</h3>
<p>To add a <a href="/en-US/docs/Apps/Packaged_apps" title="/en-US/docs/Apps/Packaged_apps">packaged app</a> to the Simulator, open the Dashboard, click "Add Directory" and select the <a href="/en-US/docs/Apps/Manifest" title="/en-US/docs/Apps/Manifest">manifest file</a> for your app.<br />
  <br />
  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.<br />
  <br />
  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 <a href="#Manifest-validation" title="#Manifest-validation">Manifest Validation</a> for details on what tests are run.</p>
<p>Unless manifest validation reveals that your app has errors, the Dashboard will then automatically run your app in the Simulator.</p>
<h3 id="Managing_apps">Managing apps</h3>
<p>Once you have added an app, it will appear in the Manager's list of installed apps:<br />
  <img alt="" src="https://mdn.mozillademos.org/files/5493/dashboard-list-apps-4.0.png" style="width: 1044px; height: 650px;" /><br />
  Each entry gives us the following information about the app:</p>
<ul>
  <li>its name, taken from the manifest</li>
  <li>its type, which will be one of "Packaged", "Hosted", or "Generated"</li>
  <li>a link to its manifest file</li>
  <li>the result of manifest validation</li>
</ul>
<p>It also gives us four commands:</p>
<ul>
  <li><strong>"Refresh":</strong> use this to update and reload 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 refresh the app to apply the changes.</li>
  <li><strong>"Connect": </strong>use this to connect developer tools to the selected app. The Dashboard will start the Simulator and app if they aren't already running.</li>
  <li><strong>"Remove" ("X"):</strong> use this to remove the app from the Simulator and the Dashboard. You can undo this action as long as the Dashboard tab is open.</li>
  <li><strong>"Receipt":</strong> use this to test receipt verification for paid apps. After you select a type of receipt to test, the app will be reinstalled with a test receipt of the given type.</li>
</ul>
<div class="note">
  <p><strong>Refresh App from the Simulator window</strong>: you can update and reload an app directly from the Simulator window <a href="#Simulator-menubar" title="#Simulator-menubar">using the menubar action or its associated shortcut</a> while the app is running.</p>
</div>
<h3 id="Manifest_validation"><a name="Manifest-validation">Manifest validation</a></h3>
<p>When you supply a manifest, the Manager will run some validation tests on it. It reports three categories of problems:</p>
<ul>
  <li>manifest errors: problems that will prevent your app from installing or running</li>
  <li>manifest warnings: problems that may prevent your app from working properly</li>
  <li>simulator-specific warnings: features your app is using that the Simulator doesn't yet support</li>
</ul>
<p>It summarises the problems encountered in the entry for the app: clicking on the summary provides more details.</p>
<h4 id="Manifest_errors">Manifest errors</h4>
<p>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:</p>
<ul>
  <li>the manifest does not include the mandatory "name" field</li>
  <li>the manifest is not valid JSON</li>
  <li>the app is a hosted app, but the <a href="/en-US/docs/Apps/Manifest#type" title="/en-US/docs/Apps/Manifest#type">type</a> field in its manifest is <a href="/en-US/docs/Apps/Packaged_apps#Types_of_packaged_apps" title="/en-US/docs/Apps/Packaged_apps#Types_of_packaged_apps">"privileged" or "certified"</a>, which are only available to packaged apps</li>
  <li>common appCache errors (packaged apps can't use appCache, requests to the manifest URL return an HTTP redirect or an HTTP error status)</li>
</ul>
<p>Here's the result of trying to add a manifest file with a missing "name":<br />
  <img alt="" src="https://mdn.mozillademos.org/files/5495/dashboard-missing-name-4.0.png" style="width: 1044px; height: 650px;" /></p>
<h4 id="Manifest_warnings">Manifest warnings</h4>
<p>The Dashboard will report the following manifest issues as warnings:</p>
<ul>
  <li>missing icons</li>
  <li>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</li>
  <li>the <a href="/en-US/docs/Apps/Manifest#type" title="/en-US/docs/Apps/Manifest#type">type</a> field is unrecognized</li>
  <li>the manifest requests a <a href="/en-US/docs/Apps/Manifest#permissions" title="/en-US/docs/Apps/Manifest#permissions">permission</a> that is unrecognized</li>
  <li>the manifest requests a <a href="/en-US/docs/Apps/Manifest#permissions" title="/en-US/docs/Apps/Manifest#permissions">permission</a> which will be denied</li>
  <li>the manifest requests a <a href="/en-US/docs/Apps/Manifest#permissions" title="/en-US/docs/Apps/Manifest#permissions">permission</a> for which access could not be determined</li>
</ul>
<h4 id="Simulator-specific_warnings">Simulator-specific warnings</h4>
<p>Finally, the Manager will emit warnings for apps that use features of Firefox OS not yet fully supported by the Simulator:</p>
<ul>
  <li>the <a href="/en-US/docs/Apps/Manifest#type" title="/en-US/docs/Apps/Manifest#type">type</a> field is "certified", but the Simulator does not yet fully support certified apps</li>
  <li>the manifest requests a <a href="/en-US/docs/Apps/Manifest#permissions" title="/en-US/docs/Apps/Manifest#permissions">permission</a> to use an API that is <a href="#Unsupported-APIs" title="#Unsupported-APIs">not yet supported</a> by the Simulator</li>
</ul>
<h2 id="Running_the_Simulator"><a name="Running-the-Simulator">Running the Simulator</a></h2>
<p>There are two different ways the Simulator may be started:</p>
<ul>
  <li>if you add an app or click the "Refresh" or "Connect" button next to your app's entry, the Dashboard will automatically run your app in the Simulator</li>
  <li>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</li>
</ul>
<p>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.<br />
  <br />
  The Simulator appears as a separate window, sized so the simulated screen area is 320x480 pixels, with a <a href="#Simulator-toolbar" title="#Simulator-toolbar">toolbar at the bottom</a> and a <a href="#Simulator-menubar" title="#Simulator-menubar">menubar at the top</a> that contains some extra features:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5505/simulator-bars.png" style="width: 1044px; height: 240px; margin-left: auto; margin-right: auto; display: block;" /></p>
<p>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:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5517/simulator-homescreen.png" style="width: 1044px; height: 666px;" /></p>
<h3 id="Simulator_toolbar"><a name="Simulator-toolbar">Simulator toolbar</a></h3>
<p>In the bottom toolbar, from left to right, these are the <strong>Home button</strong>, the <strong>Screen Rotation button</strong>, and the <strong>Geolocation button</strong>.</p>
<ul>
  <li>the <strong>Home button</strong> takes you to the Home screen (or to the task list if you keep it pressed for a couple of seconds)</li>
  <li>the <strong>Screen Rotation button</strong> switches the device between portrait and landscape orientation. This will generate the <a href="https://developer.mozilla.org/en-US/docs/WebAPI/Managing_screen_orientation#Listening_orientation_change" title="/en-US/docs/WebAPI/Detecting_device_orientation">orientationchange</a> event.</li>
  <li>the <strong>Geolocation button</strong> 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 <a href="/en-US/docs/WebAPI/Using_geolocation" title="/en-US/docs/WebAPI/Using_geolocation">Geolocation API</a>.</li>
</ul>
<p><a href="https://mdn.mozillademos.org/files/5511/simulator-geolocation.png" target="_blank"><img alt="" src="https://mdn.mozillademos.org/files/5511/simulator-geolocation.png" style="width: 520px; height: 309px;" /></a><a href="https://mdn.mozillademos.org/files/5519/simulator-screen-orientation.png" target="_blank"><img alt="" src="https://mdn.mozillademos.org/files/5519/simulator-screen-orientation.png" style="width: 500px; height: 297px;" /></a></p>
<h3 id="Simulator_menubar"><a name="Simulator-menubar"></a>Simulator menubar</h3>
<p>In the top menubar, you can access some useful commands to make development more efficient:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5525/simulator-menubar.png" style="width: 1044px; height: 280px;" /></p>
<ul>
  <li><strong>File -&gt; Quit</strong> (<em>Ctrl/Cmd - Q</em>): shut down the Simulator</li>
  <li><strong>App -&gt; Refresh</strong> (<em>Ctrl/Cmd - R</em>): refresh the running app</li>
</ul>
<p>The keyboard shortcut for the <strong>"App Refresh"</strong> command makes it possible to iteratively develop an app much like a web page:</p>
<ul>
  <li>make a change to the code (and rerun your build tool if needed, e.g. volo / yeoman / grunt)</li>
  <li>type the keyboard shortcut to refresh the app running in the Simulator</li>
</ul>
<div class="note">
  <p><strong>"Refresh App and Clear Data" hidden shortcut:</strong> sometimes it's useful to clear data that the Simulator has stored for an app, so the Simulator contains a hidden shortcut, <em>Shift - Ctrl/Cmd - R</em>, that will refresh the running app while clearing the following data:</p>
  <ul>
    <li>
      <p>localStorage / sessionStorage</p>
    </li>
    <li>
      <p>cookies</p>
    </li>
    <li>
      <p>indexedDB</p>
    </li>
    <li>
      <p>appCache</p>
    </li>
  </ul>
</div>
<h2 id="Attaching_developer_tools"><a name="Attaching-developer-tools">Attaching developer tools</a></h2>
<p>You can attach developer tools to the Simulator, to help debug your app. At the moment you can only attach the <a href="/en-US/docs/Tools/Debugger" title="/en-US/docs/Tools/Debugger">JavaScript Debugger</a>, the <a href="/en-US/docs/Tools/Web_Console" title="/en-US/docs/Tools/Web_Console">Web Console</a>, the <a href="/en-US/docs/Tools/Style_Editor" title="/en-US/docs/Tools/Style_Editor">Style Editor</a>, the <a href="/en-US/docs/Tools/Profiler" title="/en-US/docs/Tools/Profiler">Profiler</a> and the <a href="/en-US/docs/Tools/Network_Monitor" title="/en-US/docs/Tools/Network_Monitor">Network Monitor</a>, but we're working on adding support for more <a href="https://developer.mozilla.org/en-US/docs/Tools/DevTools_Window" title="https://developer.mozilla.org/en-US/docs/Tools/DevTools_Window">developer tools</a>.</p>
<div class="note">
  <p>Some of these tools are only available in Beta, Aurora, or Nightly builds of Firefox.</p>
</div>
<p>To attach developer tools to the Simulator, click the <strong>"Connect"</strong> button for an app:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5497/connect-to-app-button.png" style="width: 1044px; height: 650px; margin-left: auto; margin-right: auto; display: block;" /></p>
<p>The Dashboard will then open a developer toolbox pane at the bottom of the Dashboard tab and connect it to the app:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5501/simulator-devtools-connected.png" style="width: 1044px; height: 750px; margin-left: auto; margin-right: auto; display: block;" /></p>
<h3 id="Web_Console">Web Console</h3>
<p>The app can log to this console using the global <a href="/en-US/docs/DOM/console" title="/en-US/docs/DOM/console">console</a> object, and it displays various other messages generated by the app: network requests, CSS and JS warnings/errors, and security errors. (<a href="/en-US/docs/Tools/Web_Console" title="/en-US/docs/Tools/Web_Console">Learn more about the Web Console.</a>)</p>
<h3 id="Debugger">Debugger</h3>
<p>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. (<a href="/en-US/docs/Tools/Debugger" title="/en-US/docs/Tools/Web_Console">Learn more about the Debugger.</a>)</p>
<h3 id="Style_Editor">Style Editor</h3>
<p>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. (<a href="/en-US/docs/Tools/Style_Editor" title="/en-US/docs/Tools/Web_Console">Learn more about the Style Editor.</a>)</p>
<h3 id="Profiler">Profiler</h3>
<p>Using the Profiler tool connected to the app, you can to 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. (<a href="/en-US/docs/Tools/Profiler" title="/en-US/docs/Tools/Web_Console">Learn more about the Profiler.</a>)</p>
<h3 id="Network_Monitor">Network Monitor</h3>
<p>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. (<a href="https://hacks.mozilla.org/2013/06/network-monitor-now-in-firefox-beta/" title="https://hacks.mozilla.org/2013/06/network-monitor-now-in-firefox-beta/">Learn more about the Network Monitor.</a>)</p>
<h2 id="Receipts"><a name="Simulator-receipts"></a>Receipts</h2>
<p>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.</p>
<p>Thanks to the <strong>"Receipts"</strong> menu in each app entry on the Simulator Dashboard, you can install an app with a <strong>"Valid"</strong>, <strong>"Invalid"</strong>, or <strong>"Refunded"</strong> 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:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5523/simulator-receipts-selector-4.0.png" style="width: 1044px; height: 620px;" /></p>
<h2 id="Push_to_device"><a name="Push-to-device">Push to device</a></h2>
<p>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.</p>
<h3 id="Connecting_a_device">Connecting a device</h3>
<p>To connect the device, follow the instructions in the guide to <a href="/en-US/docs/Mozilla/Firefox_OS/Debugging/Connecting_a_Firefox_OS_device_to_the_desktop" title="/en-US/docs/Mozilla/Firefox_OS/Debugging/Connecting_a_Firefox_OS_device_to_the_desktop">connecting a Firefox OS device to the desktop</a>. Note that you don't have to install ADB, as the Simulator add-on includes it already.</p>
<h3 id="Pushing_apps_to_the_device">Pushing apps to the device</h3>
<p>Once you've set up the device and desktop, and connected the device to your desktop via USB, you'll see the note <strong>"Device connected"</strong> appear on the left of the Dashboard, and a new command appear in the entry for each app labeled <strong>"Push"</strong>:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5521/simulator-push2device.png" style="width: 1044px; height: 620px;" /></p>
<p>Click <strong>"Push"</strong>, and the app will be installed on the Firefox OS device.</p>
<div class="note">
  <p><strong>Manual Steps:</strong></p>
  <ul>
    <li>
      <p>Once you’ve pushed the app to the device, you need to manually close and restart it again, to get updated content</p>
    </li>
    <li>
      <p>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&nbsp;</p>
    </li>
  </ul>
</div>
<h3 id="Firefox_OS_Device_Connection_Confirmation">Firefox OS Device Connection Confirmation</h3>
<p>On every device reboot, the first <strong>"Push"</strong> request needs to be confirmed on the device:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5527/device-push-confirmation.png" style="width: 320px; height: 480px;" /></p>
<h3 id="Troubleshooting_on_Linux">Troubleshooting on Linux</h3>
<p>If you are unable to connect your device after creating udev rules, please see this <a href="https://github.com/mozilla/r2d2b2g/issues/515" title="https://github.com/mozilla/r2d2b2g/issues/515">bug</a>.</p>
<h2 id="Limitations_of_the_Simulator"><a name="Limitations">Limitations of the Simulator</a></h2>
<p>Note that the Firefox OS Simulator isn't a perfect simulation.</p>
<h3 id="Hardware_limitations">Hardware limitations</h3>
<p>Apart from screen size, the Simulator does not simulate the hardware limitations of a Firefox OS device such as available memory or CPU speed.</p>
<h3 id="Audio.2Fvideo_codecs">Audio/video codecs</h3>
<p>The following codecs depend on hardware-accelerated decoding and are therefore not yet supported:</p>
<ul>
  <li>MP3</li>
  <li>AAC</li>
  <li>H.264 (MP4)</li>
  <li>WebM</li>
</ul>
<p>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.</p>
<h3 id="Unsupported_APIs"><a name="Unsupported-APIs">Unsupported APIs</a></h3>
<p>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:</p>
<ul>
  <li><a href="/en-US/WebAPI/WebTelephony" title="/en-US/WebAPI/WebTelephony">Telephony</a></li>
  <li><a href="/en-US/docs/WebAPI/WebSMS" title="/en-US/docs/WebAPI/WebSMS">WebSMS</a></li>
  <li><a href="/en-US/docs/WebAPI/WebBluetooth" title="/en-US/docs/WebAPI/WebBluetooth">WebBluetooth</a></li>
  <li><a href="/en-US/docs/WebAPI/Using_Light_Events" title="/en-US/docs/WebAPI/Using_Light_Events">Ambient Light</a></li>
  <li><a href="/en-US/docs/WebAPI/Proximity" title="/en-US/docs/WebAPI/Proximity">Proximity</a></li>
  <li><a href="/en-US/docs/WebAPI/Network_Information" title="/en-US/docs/WebAPI/Network_Information">Network Information</a></li>
  <li><a href="/en-US/docs/Online_and_offline_events" title="/en-US/docs/Online_and_offline_events">navigator.onLine and offline events</a></li>
  <li><a href="/en-US/docs/WebAPI/Vibration" title="/en-US/docs/WebAPI/Vibration">Vibration</a></li>
</ul>
<h2 id="Getting_help"><a name="Simulator-help"></a>Getting help</h2>
<p>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.</p>
<p>If you find any bugs, please <a href="https://github.com/mozilla/r2d2b2g/issues?state=open">file them on GitHub</a>. If you have a question, try asking us on the <a href="https://lists.mozilla.org/listinfo/dev-developer-tools">dev-developer-tools mailing list</a> or on <a href="irc://irc.mozilla.org/#devtools">#devtools on irc.mozilla.org</a>.</p>
<h3 id="How_to_enable_verbose_logging"><a name="Simulator-verbose-logging"></a>How to enable verbose logging</h3>
<p>Use about:config to create the preference <a href="mailto:extensions.r2d2b2g@mozilla.org.sdk.console.logLevel">extensions.r2d2b2g@mozilla.org.sdk.console.logLevel</a>, set it to the integer value 0, and disable/reenable the addon. Additional messages about the Simulator's operation will appear in the Error Console (or Browser Console in newer versions of Firefox).</p>
<h3 id="How_to_get_the_latest_preview_build"><a name="Simulator-latest-preview-build"></a>How to get the latest preview build</h3>
<p>The latest preview build can be downloaded from the following URLs:</p>
<ul>
  <li>Windows: <a href="https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/r2d2b2g-windows.xpi">https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/r2d2b2g-windows.xpi</a></li>
  <li>Mac: <a href="https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/r2d2b2g-mac.xpi">https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/r2d2b2g-mac.xpi</a></li>
  <li>Linux: <a href="https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/r2d2b2g-linux.xpi">https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/r2d2b2g-linux.xpi</a></li>
</ul>
<div class="warning">
  <p>Preview builds are less stable and complete than release builds, so use them with caution.</p>
</div>
<p>&nbsp;</p>
Revert to this revision