https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging/Firefox_for_Android

This guide explains how to use remote debuggingto inspect or debug code running inFirefox for Androidover USB.

This guide's split into two parts: the first part, "Prerequisites" covers stuff you only need to do once, while the second part, "Connecting", covers stuff you need to do each time you connect the device.

Prerequisites

First, you'll need:

  • a desktop or laptop computer with Firefox running on it
  • an Android device capable of running Firefox for Android with Firefox for Android running on it
  • a USB cable to connect the two devices

ADB setup

Next, you'll need to get the desktop and the Android device talking to each other using the adb command-line tool.

On the Android device

On the desktop

  • Install the correct version of the Android SDK for your device.
  • Using the Android SDK, install the Android Platform Tools.
  • Android Platform Tools installs adb in the "platform-tools" directory under the directory in which you installed the Android SDK. Make sure the "platform-tools" directory is in your path.

To check it worked, open up a command shell on the desktop and type:

adb devices

You should see some output like:

List of devices attached
51800F220F01564 device

(The long hex string will be different.)

If you do, then adb has found your device and you've successfully set up ADB.

Enable remote debugging

Next, you need to enable remote debugging on both the Android device and the desktop.

Firefox for Android 24 and earlier

To enable remote debugging on the device, you need to set thedevtools.debugger.remote-enabled preference to true.

Go to about:config in Firefox for Android, type "devtools" into the search box and press the Search key. You'll see all the devtools preferences. Find thedevtools.debugger.remote-enabled preference, and press "Toggle".

Firefox for Android 25 and later

On Firefox for Android 25 and later, there's a menu item to enable remote debugging. Open the menu, select "Settings", then "Developer tools" (on some Android devices you may need to select "More" to see the "Settings" option). Check the "Remote debugging" box:

The browser will display a notification reminding you to set up port forwarding, which we'll do later on.

On the desktop

On the desktop, remote debugging is enabled by a setting in the Toolbox. Open the Toolbox, click the "Settings" button in the toolbar, and check "Enable remote debugging" in the Settingstab:

If you're using a version of Firefox older than 27, you'll need to restart the browser for the setting to take effect.

You'll then see a new option in the Web Developer menu labeled "Connect...":

Connecting

Now you can connect the remote debugging tools to the device. First, attach the device to the desktop with a USB cable, if you haven't already.

On the desktop

Go to a command prompt, and type:

adb forward tcp:6000 tcp:6000

(If you've changed the value the Android device uses for a debugging port, you'll need to adjust this accordingly.)

For Firefox OS, type:

adb forward tcp:6000 localfilesystem:/data/local/debugger-socket

You'll need to reissue this command each time you physically attach desktop and device with the USB cable.

Then go to the Web Developer menu on Firefox, and select "Connect...". You'll see a page that looks like this:

Unless you've changed the port numbers, choose 6000 and press the "Connect" button.

On the Android device

Next you'll see a dialog on the Android device asking you to confirm the connection:

Press "OK". The desktop waits for a few seconds to give you time to acknowledge this dialog: if it times out, just press "Connect" in the desktop dialog again.

On the desktop

Next, the desktop shows you a dialog that looks something like this:

This is asking whether you want to debug web content running in a browser tab, or to debug the browser code itself.

  • You'll see one entry under "Available remote tabs" for each open tab, and clicking it will attach the debugging tools to the web content hosted by that tab. If you want to debug your web content, you'll choose the relevant content tab.
  • You'll see one entry under "Available remote processes": this is the browser process itself. You'll choose this option if you want to debug the browser's own code.

Let's choose to attach to the mozilla.org website. The Toolbox will open in its own window, attached to the Firefox for Android tab that's currently hosting mozilla.org:

The Toolbox, and the tools it hosts, work in just the same way as they do when attached to local content.

Attachments

File Size Date Attached by
remote-debugger-about-config-toggle

 
95831 bytes 2013-08-01 15:36:19 wbamberg
remote-debugging-connect-menuitem

 
81023 bytes 2013-08-01 17:15:16 wbamberg
remote-debugging-deskopt-connect

 
85186 bytes 2013-08-01 17:20:07 wbamberg
remote-debugging-device-connect

 
167472 bytes 2013-08-01 17:26:11 wbamberg
remote-debugging-deskopt-select-target

 
90358 bytes 2013-08-01 19:41:30 wbamberg
remote-debugging-console

 
124892 bytes 2013-08-01 20:35:29 wbamberg
remote-debugging-debugger

 
266637 bytes 2013-08-01 20:35:45 wbamberg
remote-debugger-toolbox-settings

 
123586 bytes 2013-08-01 23:09:18 wbamberg
remote-debugging-device-enable

 
45182 bytes 2013-08-02 09:37:26 wbamberg
remote-debugging-overview

 
394293 bytes 2013-08-02 12:25:02 wbamberg

最新文章

  1. stopPropagation, preventDefault 和 return false
  2. css3学习总结1--CSS3选择器
  3. PBS
  4. wlan的QOS配置
  5. 苹果iOS手机系统诊断功能是后门吗?
  6. [Windows Phone 8]如何解决Lumia手机无法进入系统或开启?
  7. Duanxx的STM32学习:STM32F103中等容量的功能和外设
  8. Linux笔记(二) - 权限管理
  9. C语言程序设计第三次作业--选择结构(1)
  10. 图文浅析APK程序运行的过程
  11. (转)RBAC权限管理
  12. Epplus DataTable一次性导出
  13. 小程序中通过判断id来删除数据,当数据长度为0时,显示隐藏部分(交流QQ群:604788754)
  14. 【转载】【原创】华硕F8TR笔记本更换主板及喇叭教程
  15. ArcGIS for qml -关于空间参考如何选择设置
  16. Tensorflow学习资源
  17. pythonweb框架Flask学习笔记01-ubuntu18.04下安装Flask
  18. maven +IEDA+log4j
  19. Verilog HDL与C语言的比较
  20. C语言版kafka消费者代码运行时异常kafka receive failed disconnected

热门文章

  1. solr服务中集成IKAnalyzer中文分词器、集成dataimportHandler插件
  2. 谈谈一些有趣的CSS题目(二)-- 从条纹边框的实现谈盒子模型
  3. 使用蓝灯后,IE浏览器以及内置IE浏览器的程序不能使用的解决方案
  4. JavaScript学习笔记(二)——闭包、IIFE、apply、函数与对象
  5. CSS3新特性应用之结构与布局
  6. 原生JavaScript实现hasClass、addClass、removeClass、toggleClass
  7. git快速get
  8. 如何编译Zookeeper源码
  9. JavaScript
  10. Struts的拦截器