mozilla

Revision 374881 of Setting up to debug Firefox OS using Firefox Developer Tools

  • Revision slug: Mozilla/Firefox_OS/Debugging/Setting_up
  • Revision title: Setting up to debug on Firefox OS using Firefox developer tools
  • Revision id: 374881
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Added developer settings page link

Revision Content

Firefox OS supports the same remote debugging protocol that Firefox mobile supports on Android. This means you can use the Firefox development tools to debug Gaia applications running on a Firefox OS device or emulator. In order to debug Firefox OS running on your device or on the Firefox OS Simulator, you need to use Firefox 18 or later; in addition, there are settings that need to be changed both in your desktop browser's configuration and on your Firefox OS device or simulator.

Firefox desktop

You need to be sure you have a build of Firefox 18 or later in order to have remote debugging support. If you don't already have a recent copy of Firefox, download the latest stable release of Firefox, or get a more recent Beta, Aurora or Nightly build. Uncompress it, install it in your favorite place for applications, quit any already-running copies of Firefox, then start up Nightly.

Once you're running an appropriate version of Firefox on your computer, type about:config in the URL bar and change the value of devtools.debugger.remote-enabled to true. Then you'll need to restart Firefox to get remote debugging enabled. After restarting Firefox, you'll see new Remote Debugger and Remote Web Console options in the Web Developer menu. (On recentl Nightly builds this menu option is called "Connect..." instead.)

Enabling debugging on the Firefox OS Simulator

When using the Firefox OS Simulator (or B2G Desktop), setting up for debugging is pretty easy. You don't need to do any port forwarding like you do when debugging on a physical device. Simply open the Settings app, then Device Information > More Information > Developer. In that menu, enable Remote Debugging.

Now you're ready to use the debugger!

Enabling debugging on a Firefox OS device

Note: As of January 10, 2013, device builds of Firefox OS have debugging disabled. There will eventually be a way to build your own build with it re-enabled, but this doesn't exist yet. This document will be updated once that happens. In addition, the preference for turning off out-of-process support has been removed. For now, you'll need to do your debugging in the Firefox OS Simulator.

On your Firefox OS device, open the Settings app, then Device Information > More Information > Developer. In the developer menu:

  • Turn on Remote Debugging.
  • You also need to turn off out-of-process support, until {{bug(797627)}} is fixed. Without doing so, only system scripts can be debugged.

Next, you need to do a little tinkering, in order to work around {{bug(764913)}}. You need to add a line to the prefs.js file on the device. To do that, open a terminal window on your computer and use the command adb shell to connect to the shell on the device. Then type:

ls /data/b2g/mozilla/

Your profile folder will be listed there. Note its name; mine was 9qojugvc.default, but of course yours will almost certainly be different. Quit the adb shell, then type the following command, replacing the profile folder name as appropriate:

adb pull /data/b2g/mozilla/9qojugvc.default/prefs.js prefs.js

Then open the prefs.js you just downloaded onto your computer and insert the following line into it:

user_pref("marionette.defaultPrefs.enabled", false); 

Now you can push the changed file back to the device:

adb push prefs.js /data/b2g/mozilla/9qojugvc.default/prefs.js

Now restart your device.

Reminder: If you flash your device, you'll need to redo these configuration changes.

Now you're ready to use the debugger!

Enabling console logging on a Firefox OS device

On production builds of Firefox OS, console logging (such as by {{domxref("console.log()")}}) is disabled by default. In order to enable it, open the Settings app and navigate down through Device Information->More Information->Developer, then toggle on the "Console Enabled" preference.

See also

Revision Source

<p>Firefox OS supports the same remote debugging protocol that Firefox mobile supports on Android. This means you can use the Firefox development tools to debug Gaia applications running on a Firefox OS device or emulator. In order to debug Firefox OS running on your device or on the Firefox OS Simulator, you need to use Firefox 18 or later; in addition, there are settings that need to be changed both in your desktop browser's configuration and on your Firefox OS device or simulator.</p>
<h2 id="Firefox_desktop">Firefox desktop</h2>
<p>You need to be sure you have a build of Firefox 18 or later in order to have remote debugging support. If you don't already have a recent copy of Firefox, download the <a href="http://www.mozilla.org/en-US/firefox/fx/#desktop" title="http://www.mozilla.org/en-US/firefox/fx/#desktop">latest stable release of Firefox</a>, or get a more recent <a href="http://www.mozilla.org/en-US/firefox/channel/" title="http://www.mozilla.org/en-US/firefox/channel/">Beta, Aurora</a> or <a href="http://nightly.mozilla.org/" title="http://nightly.mozilla.org/">Nightly</a> build. Uncompress it, install it in your favorite place for applications, quit any already-running copies of Firefox, then start up Nightly.</p>
<p>Once you're running an appropriate version of Firefox on your computer, type <code>about:config</code> in the URL bar and change the value of <code>devtools.debugger.remote-enabled</code> to <code>true</code>. Then you'll need to restart Firefox to get remote debugging enabled. After restarting Firefox, you'll see new Remote Debugger and Remote Web Console options in the Web Developer menu. (On recentl Nightly builds this menu option is called "Connect..." instead.)</p>
<h2 id="Enabling_debugging_on_the_Firefox_OS_Simulator">Enabling debugging on the Firefox OS Simulator</h2>
<p>When using the <a href="/en-US/docs/Mozilla/Firefox_OS/Using_Firefox_OS_Simulator" title="/en-US/docs/Mozilla/Firefox_OS/Using_Firefox_OS_Simulator">Firefox OS Simulator</a> (or B2G Desktop), setting up for debugging is pretty easy. You don't need to do any port forwarding like you do when debugging on a physical device. Simply open the Settings app, then <code>Device Information</code> &gt; <code>More Information</code> &gt; <code>Developer</code>. In that menu, enable Remote Debugging.</p>
<p>Now you're ready to <a href="/en-US/docs/Tools/Debugger" title="/en-US/docs/Tools/Debugger">use the debugger</a>!</p>
<h2 id="Enabling_debugging_on_a_Firefox_OS_device">Enabling debugging on a Firefox OS device</h2>
<div class="note">
  <p><strong>Note:</strong> As of January 10, 2013, device builds of Firefox OS have debugging disabled. There will eventually be a way to build your own build with it re-enabled, but this doesn't exist yet. This document will be updated once that happens. In addition, the preference for turning off out-of-process support has been removed. For now, you'll need to do your debugging in the <a href="/en-US/docs/Mozilla/Firefox_OS/Using_Firefox_OS_Simulator" title="/en-US/docs/Mozilla/Firefox_OS/Using_Firefox_OS_Simulator">Firefox OS Simulator</a>.</p>
</div>
<p>On your Firefox OS device, open the Settings app, then <code>Device Information</code> &gt; <code>More Information</code> &gt; <code>Developer</code>. In the developer menu:</p>
<ul>
  <li>Turn on Remote Debugging.</li>
  <li>You also need to turn off out-of-process support, until {{bug(797627)}} is fixed. Without doing so, only system scripts can be debugged.</li>
</ul>
<p>Next, you need to do a little tinkering, in order to work around {{bug(764913)}}. You need to add a line to the <code>prefs.js</code> file on the device. To do that, open a terminal window on your computer and use the command <code>adb shell</code> to connect to the shell on the device. Then type:</p>
<pre class="brush: bash">
ls /data/b2g/mozilla/</pre>
<p>Your profile folder will be listed there. Note its name; mine was <code>9qojugvc.default</code>, but of course yours will almost certainly be different. Quit the adb shell, then type the following command, replacing the profile folder name as appropriate:</p>
<pre class="brush: bash">
adb pull /data/b2g/mozilla/9qojugvc.default/prefs.js prefs.js</pre>
<p>Then open the <code>prefs.js</code> you just downloaded onto your computer and insert the following line into it:</p>
<pre>
<span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><span style="background-color: transparent; color: black; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">user_pref("marionette.defaultPrefs.enabled", false);</span></span> </pre>
<p>Now you can push the changed file back to the device:</p>
<pre class="brush: bash">
adb push prefs.js /data/b2g/mozilla/9qojugvc.default/prefs.js</pre>
<p>Now restart your device.</p>
<div class="note">
  <p><strong>Reminder:</strong> If you flash your device, you'll need to redo these configuration changes.</p>
</div>
<p>Now you're ready to <a href="/en-US/docs/Tools/Debugger" title="/en-US/docs/Tools/Debugger">use the debugger</a>!</p>
<h2 id="Enabling_console_logging_on_a_Firefox_OS_device">Enabling console logging on a Firefox OS device</h2>
<p>On production builds of Firefox OS, console logging (such as by {{domxref("console.log()")}}) is disabled by default. In order to enable it, open the Settings app and navigate down through Device Information-&gt;More Information-&gt;Developer, then toggle on the "Console Enabled" preference.</p>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/Mozilla/Firefox_OS/Debugging" title="/en-US/docs/Mozilla/Firefox_OS/Debugging">Debugging on Firefox OS</a></li>
  <li><a href="/en-US/docs/Tools/Debugger" title="/en-US/docs/Tools/Debugger">Debugger</a></li>
  <li><a href="/en-US/docs/Mozilla/Firefox_OS/Debugging/Developer_settings" title="/en-US/docs/Mozilla/Firefox_OS/Debugging/Developer_settings">Developer settings on Firefox OS</a></li>
</ul>
Revert to this revision