index.rst (18785B)
1 =============== 2 about:debugging 3 =============== 4 5 The ``about:debugging`` page provides a single place from which you can attach the Firefox Developer Tools to a number of debugging targets. At the moment it supports three main sorts of targets: restartless add-ons, tabs, and workers. 6 7 This is also the main entry point to remotely debug Firefox, in particular Firefox for Android. 8 9 Opening the about:debugging page 10 ******************************** 11 12 There are two ways to open ``about:debugging``: 13 14 - Type ``about:debugging`` in the Firefox URL bar. 15 - In the **Tools** > **Browser Tools** menu, click **Remote Debugging**. 16 17 18 When about:debugging opens, on the left-hand side, you'll see a sidebar with two options and information about your remote debugging setup: 19 20 21 Setup 22 Use the Setup tab to configure the connection to your remote device. 23 This Firefox 24 Provides information about temporary extensions you have loaded for debugging, extensions that are installed in Firefox, the tabs that you currently have open, and service workers running on Firefox. 25 26 .. image:: about_debugging_setup.png 27 :class: border 28 29 30 If your ``about:debugging`` page is different from the one displayed here, go to ``about:config``, find and set the option ``devtools.aboutdebugging.new-enabled`` to **true**. 31 32 33 Setup tab 34 ********* 35 36 .. _about-colon-debugging-connecting-to-a-remote-device: 37 38 Connecting to a remote device 39 ----------------------------- 40 41 Firefox supports debugging over USB with Android devices, using the about:debugging page. 42 43 Before you connect: 44 45 0. Ensure clicking once on "Enable USB Devices" in about:debugging homepage. 46 47 .. image:: about_debugging_home.png 48 :class: border 49 50 1. Enable Developer settings on your Android device. 51 Press 7 times on "Build Number" from your "About your phone" in the device settings app. 52 2. Enable "USB debugging" in the Android Developer settings. 53 `Detailed guide for 1. and 2. <https://developer.android.com/studio/debug/dev-options>`_ 54 55 .. image:: android_usb_debugging.png 56 :class: border 57 58 3. Enable **Remote Debugging via USB** in the Advanced Settings in Firefox on the Android device. 59 60 .. image:: android_firefox_debugging_option.png 61 :class: border 62 63 4. Connect the Android device to your computer using a USB cable. 64 If a USB cable is not available, :ref:`connect to Android over Wi-Fi <about-colon-debugging-connecting-to-android-over-wi-fi>`. 65 66 67 If your device doesn't appear in the lefthand side of the about:debugging page, try clicking the **Refresh devices** button. 68 69 **If it still doesn't appear**, it may be because the link between your Android device and your computer is not authorized yet. First make sure you have installed `Android Debug Bridge <https://developer.android.com/studio/command-line/adb.html>`_ from Android Tools on your computer in order for it to be able to connect to your device. Next, disable every debugging setting already activated and repeat the steps described before. Your device should show a popup to authorize your computer to connect to it — accept this and then click the **Refresh devices** button again. The device should appear. 70 71 .. note:: 72 73 You do not need to install the full Android Studio SDK. Only adb is needed. 74 75 76 To start a debugging session, first open the page that you wish to debug and then click **Connect** next to the device name to open a connection to it. If the connection was successful, you can now click the name of the device to switch to a tab with information about the device. 77 78 .. image:: device_information.png 79 :alt: Screenshot of the debugging page for an Android device 80 :class: border 81 82 83 The information on this page is the same as the information on the **This Firefox** tab, but instead of displaying information for your computer, it displays the information for the remote device with the addition of a **Tabs** section with an entry for each of the tabs open on the remote device. 84 85 Note: If the version of Firefox on your remote device is more than one major version older than the version running on your computer, you may see a message like the following: 86 87 .. image:: version_warning.png 88 :alt: The connected browser has an old version (68.2.0). The minimum supported version (69.0a1). This is an unsupported setup and may cause DevTools to fail. Please update the connected browser. 89 :class: center 90 91 92 The message can look like the following: 93 94 .. image:: fxand-68-error.png 95 :alt: This version of Firefox cannot debug Firefox for Android (68). We recommend installing Firefox for Android Nightly on your phone for testing. More details 96 :class: center 97 98 See Connection for Firefox for Android 68 for more information. 99 100 In the image above, there are three tabs open: **Network or cache Recipe**, **Nightly Home**, and **About Nightly**. To debug the contents of one of these tabs, click the **Inspect** button next to its title. When you do, the Developer Tools open in a new tab. 101 102 103 .. image:: remote-debugger-w-url-buttons.png 104 :class: border 105 :alt: Screenshot showing the remote debugging window, with the editable URL bar 106 107 108 Above the usual list of tools, you can see information about the device you are connected to, including the fact that you are connected (in this example) via USB, to Firefox Preview, on a Pixel 2, as well as the title of the page that you are debugging, and the address of the page. 109 110 The URL bar is editable, so that you can change the URL used by the browser on the remote device, by typing in Firefox for Desktop. You can also reload the page by clicking the **Reload** button next to the URL bar, and navigate backward or forward in the browsing history with the **Back** and **Forward** buttons. 111 112 113 .. _about-colon-debugging-connecting-to-android-over-wi-fi: 114 115 Connecting to Android over Wi-Fi 116 -------------------------------- 117 118 Firefox can debug Firefox for Android through `adb` and the `"Wireless debugging" feature <https://developer.android.com/tools/adb#connect-to-a-device-over-wi-fi>`_ of Android 11+, without requiring any USB cable. 119 120 Prerequisites: 121 122 - Device must run Android 11 or later. 123 - The `adb <https://developer.android.com/tools/adb>`_ program is available. You do not need Android Studio nor the full Android SDK. 124 - The Android device and the computer with ``about:debugging`` are in the same network. 125 126 Steps to connect wirelessly with the Android device: 127 128 1. Determine the IP address of your Android device on your local network. For example by locating the Internet/Wi-Fi setting and viewing details of the current (Wi-Fi) network. 129 2. `Enable Developer options <https://developer.android.com/studio/debug/dev-options#enable>`_ on your Android device. 130 3. Enable Wireless debugging by tapping on the toggle at the "Wireless debugging" bar at the Developer options, then tap on the "Wireless debugging" bar (before the toggle) to open the "Wireless debugging" screen. 131 132 1. An alternative to the previous step is to open "Quick settings developer tiles" at Developer options, and enabling the "Wireless debugging" tile. After this, you can long-press the "Wireless debugging" tile from the Quick Settings panel to launch the "Wireless debugging" screen. 133 134 4. Tap on "Pair device with pairing code" in the "Wireless debugging" screen. This displays a six-digit code and an IP address and port. The port is unique to the pairing setup. 135 5. From the terminal, run ``adb pair [ip address from step 1]:[port from step 4]`` and enter the six-digit code from step 4. 136 6. To finally connect wirelessly, look up the (random) port at the "IP address & Port" section of the "Wireless debugging" screen. The port is distinct from step 4. Run ``adb connect [ip address from step 1]:[port from step 6]`` to connect. 137 138 Now, the adb server on your computer is connected with the adb daemon on the Android device. All Firefox apps with the "Remote Debugging via USB" setting enabled will now appear in ``about:debugging``. 139 140 If you do not see any Firefox for Android debugging target: 141 142 - Confirm that adb is connected by running ``adb devices``. 143 - Confirm that the Firefox app is running and that the "Remote Debugging via USB" setting is checked. 144 145 146 Connecting over the Network 147 --------------------------- 148 149 .. note:: 150 The steps below do not work for Android. Follow the instructions at :ref:`Connecting to Android over Wi-Fi <about-colon-debugging-connecting-to-android-over-wi-fi>` instead. 151 152 153 You can connect to a Firefox Debug server on your network, or on your debugging machine using the **Network Location** settings of the about:debugging page. 154 155 .. image:: network_location.png 156 :class: center 157 158 159 Enter the location and port on which the debugger server is running. When you do, it is added to the Network locations list along with the devices, as shown below: 160 161 .. image:: connect_network_location.png 162 :class: center 163 164 165 This Firefox 166 ************ 167 168 The **This Firefox** tab combines the features of Extensions, Tabs, and Workers into a single tab with the following sections: 169 170 171 Temporary Extensions 172 Displays a list of the extensions that you have loaded using the **Load Temporary Add-on** button. 173 Extensions 174 This section lists information about the extensions that you have installed on your system. 175 Service Workers, Shared Workers, and Other Workers 176 There are three sections on this page that deal with Service Workers, Shared Workers, and Other Workers. 177 178 179 .. image:: about_debugging_this_firefox.png 180 :class: border 181 182 183 Whether internal extensions appear in the list on this page depends on the setting of the ``devtools.aboutdebugging.showHiddenAddons`` preference. If you need to see these extensions, navigate to ``about:config`` and make sure that the preference is set to ``true``. 184 185 186 Extensions 187 ********** 188 189 Loading a temporary extension 190 ----------------------------- 191 192 With the **Load Temporary Add-on** button you can temporarily load a WebExtension from a directory on disk. Click the button, navigate to the directory containing the add-on and select its manifest file. The temporary extension is then displayed under the **Temporary Extensions** header. 193 194 You don't have to package or sign the extension before loading it, and it stays installed until you restart Firefox. 195 196 The major advantages of this method, compared with installing an add-on from an XPI, are: 197 198 199 - You don't have to rebuild an XPI and reinstall when you change the add-on's code; 200 - You can load an add-on without signing it and without needing to disable signing. 201 202 203 Once you have loaded a temporary extension, you can see information about it and perform operations on it. 204 205 .. image:: temporary_extension.png 206 :alt: Screenshot of the debugging information panel for a temporary extension 207 :class: center 208 209 210 You can use the following buttons: 211 212 213 Inspect 214 Loads the extension in the debugger. 215 Reload 216 Reloads the temporary extension. This is handy when you have made changes to the extension. 217 Remove 218 Unloads the temporary extension. 219 220 221 Other information about the extension is displayed: 222 223 224 Location 225 The location of the extension's source code on your local system. 226 Extension ID 227 The temporary ID assigned to the extension. 228 Internal UUID 229 The internal UUID assigned to the extension. 230 Manifest URL 231 If you click the link, the manifest for this extension is loaded in a new tab. 232 233 234 Updating a temporary extension 235 ------------------------------ 236 237 If you install an extension in this way, what happens when you update the extension? 238 239 240 - If you change files that are loaded on demand, like `content scripts <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts>`_ or `popups <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#browser_actions_2>`_, then changes you make are picked up automatically, and you'll see them the next time the content script is loaded or the popup is shown. 241 242 - For other changes, click the **Reload** button. This does what it says: 243 244 - Reloads any persistent scripts, such as `background scripts <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#background_scripts>`_ 245 - Parses the ``manifest.json`` file again, so changes to `permissions <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions>`_, `content_scripts <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts>`_, `browser_action <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action>`_ or any other keys take effect 246 247 248 Installed Extensions 249 -------------------- 250 251 The permanently installed extensions are listed in the next section, **Extensions**. For each one, you see something like the following: 252 253 .. image:: installed_extension.png 254 :alt: Screenshot of the debugging information panel for an installed extension 255 :class: center 256 257 258 The **Inspect** button, and the **Extension ID** and **Internal UUID** fields are the same as for temporary extensions. 259 260 Just as it does with temporarily loaded extensions, the link next to **Manifest URL** opens the loaded manifest in a new tab. 261 262 .. note:: 263 264 It's recommended that you use the Browser Toolbox, not the Add-on Debugger, for debugging WebExtensions. See `Debugging WebExtensions <https://extensionworkshop.com/documentation/develop/debugging/>`_ for all the details. 265 266 267 The Add-ons section in about:debugging lists all WebExtensions that are currently installed. Next to each entry is a button labeled **Inspect**. 268 269 .. note:: 270 271 This list may include add-ons that came preinstalled with Firefox. 272 273 274 If you click **Inspect**, the Add-on Debugger will start in a new tab. 275 276 .. raw:: html 277 278 <iframe width="560" height="315" src="https://www.youtube.com/embed/efCpDNuNg_c" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> 279 <br/> 280 <br/> 281 282 283 Workers 284 ******* 285 286 The Workers section shows all the workers you've got registered on your Firefox, categorized as follows: 287 288 289 - All registered `Service Workers <https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API>`_ 290 - All registered `Shared Workers <https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker>`_ 291 - Other workers, including Chrome Workers and `Dedicated Workers <https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#dedicated_workers>`_ 292 293 294 You can connect the developer tools to each worker, and send push notifications to service workers. 295 296 .. image:: about_debugging_workers.png 297 :class: border 298 299 300 Service worker state 301 -------------------- 302 303 The list of service workers shows the state of the service worker in its `lifecycle <https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle>`_. Three states are possible: 304 305 306 - *Registering*: this covers all states between the service worker's initial registration, and its assuming control of pages. That is, it subsumes the *installing*, *activating*, and *waiting* states. 307 - *Running*: the service worker is currently running. It's installed and activated, and is currently handling events. 308 - *Stopped*: the service worker is installed and activated, but has been terminated after being idle. 309 310 311 .. image:: sample_service_worker.png 312 :alt: Screenshot of the debugging panel for a service worker that is in the Running state 313 :class: center 314 315 316 This section uses a simple ServiceWorker demo, hosted at https://serviceworke.rs/push-simple/. 317 318 .. note:: 319 320 You can access similar information on the Service Workers registered on a particular domain by going to the Firefox DevTools :doc:`Application panel <../application/index>`. 321 322 323 Unregistering service workers 324 ----------------------------- 325 326 Click the **Unregister** button to unregister the service worker. 327 328 329 Sending push events to service workers 330 -------------------------------------- 331 332 To debug push notifications, you can set a breakpoint in the `push event <https://developer.mozilla.org/en-US/docs/Web/API/PushEvent>`_ listener. However, you can also debug push notifications locally, without needing the server. Click the **Push** button to send a push event to the service worker. 333 334 335 Service workers not compatible 336 ------------------------------ 337 338 A warning message is displayed at the top of the **This Firefox** tab if service workers are incompatible with the current browser configuration, and therefore cannot be used or debugged. 339 340 .. image:: worker_warning.png 341 :class: center 342 343 344 Service workers can be unavailable if: 345 346 - ``dom.serviceWorkers.enable`` preference is set to false in ``about:config``. 347 - ``browser.privatebrowsing.autostart`` preference is set to true in ``about:config`` or through Firefox preferences UI. 348 349 350 The ``browser.privatebrowsing.autostart`` preference is set to true if the user selects **Never remember history** option or enables **Always use private browsing mode** in preferences UI, see about:preferences#privacy 351 352 353 Always use private browsing mode: 354 355 .. image:: always_use_private_browsing_mode.png 356 :class: center 357 358 359 Never remember history: 360 361 .. image:: never_remember_history.png 362 :class: center 363 364 365 Connection to Firefox for Android 68 366 ************************************ 367 368 Releases of Firefox for Android that are based on version 68 cannot be debugged from desktop Firefox versions 69 or later, because of the difference in release versions. Until such time as Firefox for Android is updated to a newer major release, in synch with desktop Firefox, you should use one of the following Firefox for Android versions: 369 370 371 - `Firefox Preview <https://play.google.com/store/apps/details?id=org.mozilla.fenix>`_, if your desktop Firefox is the main release or Developer Edition 372 - `Firefox for Android Nightly <https://play.google.com/store/apps/details?id=org.mozilla.fenix>`_ 373 374 375 If you prefer to test with the main release of Firefox for Android (i.e., based on release 68), you can do so with the desktop `Firefox Extended Support Release (ESR) <https://support.mozilla.org/en-US/kb/switch-to-firefox-extended-support-release-esr>`_, which is also based on version 68. 376 377 Note that ``about:debugging`` is not enabled by default in Firefox ESR. To enable it, open the `Configuration Editor <https://support.mozilla.org/en-US/kb/about-config-editor-firefox>`_ (``about:config``) and set ``devtools.aboutdebugging.new-enabled`` to **true**. 378 379 If you used a higher version of Firefox prior to installing Firefox ESR, you will be prompted to create a new user profile, in order to protect your user data. For more information, see `What happens to my profile if I downgrade to a previous version of Firefox? <https://support.mozilla.org/en-US/kb/dedicated-profiles-firefox-installation#w_what-happens-to-my-profile-if-i-downgrade-to-a-previous-version-of-firefox>`_