diff --git a/devtools/docs/user/3d_view/index.rst b/devtools/docs/user/3d_view/index.rst new file mode 100644 index 000000000000..bab91a0c1723 --- /dev/null +++ b/devtools/docs/user/3d_view/index.rst @@ -0,0 +1,89 @@ +======= +3D view +======= + +.. warning:: + + From Firefox 47 onwards, 3D view is no longer available. + +When you click on the 3D view button, the page goes into 3D view mode; in this mode, you can see your page presented in a 3D view in which nested blocks of HTML are increasingly "tall," projecting outward from the bottom of the page. This view makes it easy to visualize the nesting of your content. + +.. image:: 3dview.png + :class: center + +By clicking and dragging the view, you can rotate and re-orient the 3D presentation of the DOM hierarchy of your page to see it from different angles, to better examine its structure. Off-screen elements become visible, so that you can see where your elements are located in relation to the visible content. You can click on elements to see their HTML in the :doc:`HTML panel ` or the :doc:`Style panel `. Conversely, you can click on elements in the breadcrumb bar to change which element is selected in the 3D view. + +If you do not see the 3D button in the page inspector, it is possible that your graphics driver needs to be updated. See the `blocklisted drivers page `_ for more information. + + +Controlling the 3D view +*********************** + +There are keyboard shortcuts and mouse controls available for the 3D view. + +.. list-table:: + :widths: 20 20 60 + :header-rows: 1 + + * - Function + - Keyboard + - Mouse + + * - Zoom in/out + - :kbd:`+` / :kbd:`-` + - Scroll wheel up/down + + * - Rotate left/right + - :kbd:`a` / :kbd:`d` + - Mouse left/right + + * - Rotate up/down + - :kbd:`w` / :kbd:`s` + - Mouse up/down + + * - Pan left/right + - :kbd:`←` / :kbd:`→` + - Mouse left/right + + * - Pan up/down + - :kbd:`↑` / :kbd:`↓` + - Mouse up/down + + * - Reset zoom level + - :kbd:`0` + - Resets the zoom level to the default + + * - Focus on selected node + - :kbd:`f` + - Makes sure the currently selected node is visible + + * - Reset view + - :kbd:`r` + - Resets zoom, rotation, and panning to the default + + * - Hide current node + - :kbd:`x` + - Makes the currently selected node invisible; this can be helpful if you need to get at a node that's obscured + + +Use cases for the 3D view +************************* + +There are a variety of ways the 3D view is useful: + + +- If you have broken HTML causing layout problems, looking at the 3D view can help find where you've gone wrong. Often, layout problems are caused by improper nesting of content. This can become much more obvious when looking at the 3D view and seeing where your elements are nested wrong. +- If content isn't displaying, you may be able to figure out why; since the 3D view lets you zoom out to see elements that are rendering outside the visible area of the page, you can find stray content this way. +- You can get a look at how your page is structured to see if there may be ways to optimize your layout. +- And, of course, it looks **awesome**. + + +See also +******** + +- :doc:`Page Inspector <../page_inspector/index>` +- :ref:`HTML panel ` +- :ref:`Style panel ` +- :doc:`Tools <../index>` +- `New Developer Tools in Firefox 11 Aurora `_ (blog post) + diff --git a/devtools/docs/user/about_colon_debugging/about_colon_debugging_before_firefox_68/index.rst b/devtools/docs/user/about_colon_debugging/about_colon_debugging_before_firefox_68/index.rst new file mode 100644 index 000000000000..67401c7c9484 --- /dev/null +++ b/devtools/docs/user/about_colon_debugging/about_colon_debugging_before_firefox_68/index.rst @@ -0,0 +1,227 @@ +=================================== +about:debugging (before Firefox 68) +=================================== + +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. + + +Opening the about:debugging page +******************************** + +There are several different ways to open about:debugging: + +.. |image1| image:: hamburger.png + :width: 20 + +- Type "about:debugging" in the Firefox URL bar. +- In the Tools > Web Developer menu, click "Service Workers". +- Select the Web Developer menu under the Hamburger menu (|image1|), then select "Service Workers". + + +When about:debugging opens, on the left-hand side, you'll see a sidebar enabling you to switch between the two main views: one for add-ons and one for workers. + +Whether or not system add-ons appear in the list on this page depends on the setting of the ``devtools.aboutdebugging.showSystemAddons`` preference. If you need to see system add-ons, navigate to ``about:config`` and make sure that this value is set to ``true``. + + +Add-ons +******* + +.. note:: + The Add-ons section in about:debugging only supports restartless add-ons, including basic bootstrapped extensions, Add-on SDK add-ons, and `WebExtensions `_. + + +This page enables you to do two things: + +- Load an add-on temporarily from disk +- Connect the **Add-on Debugger** to any restartless add-ons + + +.. image:: debugger-revised.png + :class: center + + +Connecting the Add-on Debugger +------------------------------ + +.. note:: + + Note that at the moment, it's recommended that you use the Browser Toolbox, not the Add-on Debugger, for debugging WebExtensions. See `Debugging WebExtensions `_ for all the details. + + +The Add-ons page in about:debugging lists all restartless add-ons that are currently installed (note that this list may include add-ons that came preinstalled with your Firefox). Next to each entry is a button labeled "Debug". + +If the "Debug" button is disabled, check the "Enable add-on debugging" box. + +If you click "Debug", you'll see a dialog asking you to accept an incoming connection. Click "OK", and the **Add-on Debugger** will start in a separate window. Note that sometimes the debugger window is hidden by the main Firefox window. + + +See the page on the **Add-on Debugger** for all the things you can do with this tool. + +.. note:: + + The "Enable add-on debugging" button works by turning on the ``devtools.chrome.enabled`` and ``devtools.debugger.remote-enabled`` preferences. Both preferences must be true to enable add-on debugging. Checking the box sets both preferences to ``true``, and unchecking it sets them both to ``false``. + +You can also modify the preferences directly in about:config, or by checking "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" in the :ref:`Developer Tools Settings `. + + +Loading a temporary add-on +-------------------------- + +With the "Load Temporary Add-on" button you can load any sort of restartless add-on temporarily, from a directory on disk. Just click the button, navigate to the directory containing the add-on's file, and select any file in that directory. The temporary add-on will be displayed under the "Temporary Extensions" header. + +You don't have to package or sign the add-on. The add-on will stay installed until you restart Firefox. + + +The big advantages of this method, compared with installing an add-on from an XPI, are: + +- you don't have to rebuild an XPI and reinstall when you change the add-on's code +- you can load an add-on without signing it and without needing to disable signing. + + +Updating a temporary add-on +--------------------------- + +If you install the add-on in this way, what happens when you update the add-on's files? + + +Before Firefox 48 +~~~~~~~~~~~~~~~~~ + +- If you change files that are loaded on demand, like `content scripts `__ or `popups `_, 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. +- If you change files that stay loaded the whole time, like `background scripts `_, then you can pick up changes you've made by disabling and then re-enabling the add-on in the about:addons page. +- If you change files that are only parsed at install time, like the `manifest.json `_ file, you'll need to restart Firefox, then load the add-on again. + + +.. note:: + + Note that before Firefox 48, loading the add-on again by pressing "Load Temporary Add-on" without restarting Firefox *does not work*. + + +Firefox 48 onwards +~~~~~~~~~~~~~~~~~~ + +From Firefox 48 onwards: + + +- as before: if you change files that are loaded on demand, like `content scripts `__ or `popups `_, 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. +- there's a better way to handle the other cases: click the "Reload" button next to the "Debug" button. This does what it says: + + - reloading any persistent scripts, such as `background scripts `_ + - parsing the manifest.json file again, so changes to `permissions `_, `content_scripts `__, `browser_action `_ or any other keys will take effect. + + +.. note:: + + Note that in Firefox 49 onwards, the Reload button is only enabled for temporary add-ons. It will be disabled for all other add-ons. + + +Tabs +**** + +In Firefox 49 onwards, a Tabs page is available in ``about:debugging`` — this provides a complete list of all the debuggable tabs open in the current Firefox instance. + +.. image:: about-debugging-tabs.png + :class: center + + +Each tab entry has a *Debug* button next to it — when clicked, this will open up a toolbox specific to that tab, allowing you to debug that tab's contents. + +.. image:: about-debugging-tabs-toolbox.png + :class: center + + +.. note:: + + Note that this feature isn't that immediately useful to debugging desktop tabs — you can open up a toolbox to debug a tab easily enough already — but this will become far more useful when ``about:debugging`` starts to support remote debugging, and this page can begin to list tabs available for debugging on mobile device browsers, simulators, etc. See `bug 1212802 `_ for the latest on this work. + + +Workers +******* + +The Workers page shows your workers, categorized as follows: + +- All registered `Service Workers `_ +- All registered `Shared Workers `_ +- Other workers, including **Chrome Workers** and `Dedicated Workers `_ + + +You can connect the developer tools to each worker, and send push notifications to service workers. + +.. image:: about-debugging-workers.png + :class: center + + +Service worker state +-------------------- + +From Firefox 52, the list of service workers shows the state of the service worker in its `lifecycle `_. Three states are distinguished: + + +- *"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. +- *"Running"*: the service worker is currently running. It's installed and activated, and is currently handling events. +- *"Stopped"*: the service worker is installed and activated, but has been terminated after being idle. + + +.. image:: service-worker-status.png + :class: center + + +.. note:: + This section uses a simple ServiceWorker demo, hosted at https://serviceworke.rs/push-simple/. + + +Debugging workers +----------------- + +For a service worker, if it is already running, you'll see two buttons next to it, labeled "Debug" and "Push". If it's not already running, you'll see one button, labeled "Start": click this to start the service worker. + +Clicking "Debug" connects the JavaScript Debugger and Console to this worker. You can set breakpoints, step through code, watch variables, evaluate code, and so on. + + +Registering workers +------------------- + +At first, you won't see any workers listed under *Service Workers* or *Shared Workers*. As soon as a worker is registered, the listing is updated. + +.. note:: + Before Firefox 47, service workers were only shown when they were actually running. + + +Unregistering service workers +----------------------------- + +New in Firefox 48. + +Starting in Firefox 48, you'll see a link named "unregister" next to each registered service worker: + +.. image:: unregister-sw.png + :class: center + + +Click the link to unregister the service worker. + + +Sending push events to service workers +-------------------------------------- + +.. note:: + Sending push events in about:debugging is new in Firefox 47. + + +To debug push notifications, you can set a breakpoint in the `push event `_ listener. However, you can also debug push notifications locally, without needing the server. Just click the "Push" button to send a push event to the service worker. + + +Service workers not compatible +------------------------------ + +In Firefox 49+, a warning message will be displayed in the Service Workers section of the Workers page if service workers are incompatible with the current browser configuration, and therefore cannot be used or debugged. + +.. image:: sw-not-compatible.png + :class: center + +Service workers can be unavailable for several reasons: + +- If you are using a Private Browsing window. +- If your History preference is set to "Never Remember History" or "Always use private browsing mode". +- If the ``dom.serviceWorkers.enable`` preference is set to false in ``about:config``. + diff --git a/devtools/docs/user/about_colon_debugging/index.rst b/devtools/docs/user/about_colon_debugging/index.rst new file mode 100644 index 000000000000..c9d308859ac4 --- /dev/null +++ b/devtools/docs/user/about_colon_debugging/index.rst @@ -0,0 +1,304 @@ +=============== +about:debugging +=============== + +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. + +Opening the about:debugging page +******************************** + +There are two ways to open ``about:debugging``: + +- Type ``about:debugging`` in the Firefox URL bar. +- In the **Tools** > **Web Developer** menu, click **Remote Debugging**. + + +When about:debugging opens, on the left-hand side, you'll see a sidebar with two options and information about your remote debugging setup: + + +Setup + Use the Setup tab to configure the connection to your remote device. +This Firefox + 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. + +.. image:: about_debugging_setup.png + :class: border + + +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**. + + +Setup tab +********* + +Connecting to a remote device +----------------------------- + +Firefox supports debugging over USB with Android devices, using the about:debugging page. + +Before you connect: + +1. Enable Developer settings on your Android device. +2. Enable USB debugging in the Android Developer settings. +3. Enable **Remote Debugging via USB** in the Advanced Settings in Firefox on the Android device. +4. Connect the Android device to your computer using a USB cable. + + +If your device doesn't appear in the lefthand side of the about:debugging page, try clicking the **Refresh devices** button. + +**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 `_ 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. + +.. note:: + + You do not need to install the full Android Studio SDK. Only adb is needed. + + +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. + +.. image:: device_information.png + :alt: Screenshot of the debugging page for an Android device + :class: border + + +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. + +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: + +.. image:: version_warning.png + :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. + :class: center + + +In Firefox 76 and above, the message can look like the following: + +.. image:: fxand-68-error.png + :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 + :class: center + +See Connection for Firefox for Android 68 for more information. + +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. + + +.. image:: remote-debugger-w-url-buttons.png + :class: border + :alt: Screenshot showing the remote debugging window, with the editable URL bar + + +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. + +Starting in Firefox 78, 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 (starting 79), navigate backward or forward in the browsing history with the **Back** and **Forward** buttons. + + +Connecting over the Network +--------------------------- + +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. + +.. image:: network_location.png + :class: center + + +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: + +.. image:: connect_network_location.png + :class: center + + +This Firefox +************ + +The **This Firefox** tab combines the features of Extensions, Tabs, and Workers into a single tab with the following sections: + + +Temporary Extensions + Displays a list of the extensions that you have loaded using the **Load Temporary Add-on** button. +Extensions + This section lists information about the extensions that you have installed on your system. +Service Workers, Shared Workers, and Other Workers + There are three sections on this page that deal with Service Workers, Shared Workers, and Other Workers. + + +.. image:: about_debugging_this_firefox.png + :class: border + + +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``. + + +Extensions +********** + +Loading a temporary extension +----------------------------- + +With the **Load Temporary Add-on** button you can temporarily load a web extension 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. + +You don't have to package or sign the extension before loading it, and it stays installed until you restart Firefox. + +The major advantages of this method, compared with installing an add-on from an XPI, are: + + +- You don't have to rebuild an XPI and reinstall when you change the add-on's code; +- You can load an add-on without signing it and without needing to disable signing. + + +Once you have loaded a temporary extension, you can see information about it and perform operations on it. + +.. image:: temporary_extension.png + :alt: Screenshot of the debugging information panel for a temporary extension + :class: center + + +You can use the following buttons: + + +Inspect + Loads the extension in the debugger. +Reload + Reloads the temporary extension. This is handy when you have made changes to the extension. +Remove + Unloads the temporary extension. + + +Other information about the extension is displayed: + + +Location + The location of the extension's source code on your local system. +Extension ID + The temporary ID assigned to the extension. +Internal UUID + The internal UUID assigned to the extension. +Manifest URL + If you click the link, the manifest for this extension is loaded in a new tab. + + +Updating a temporary extension +------------------------------ + +If you install an extension in this way, what happens when you update the extension? + + +- If you change files that are loaded on demand, like `content scripts `_ or `popups `_, 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. + +- For other changes, click the **Reload** button. This does what it says: + + - Reloads any persistent scripts, such as `background scripts `_ + - Parses the ``manifest.json`` file again, so changes to `permissions `_, `content_scripts `_, `browser_action `_ or any other keys take effect + + +Installed Extensions +-------------------- + +The permanently installed extensions are listed in the next section, **Extensions**. For each one, you see something like the following: + +.. image:: installed_extension.png + :alt: Screenshot of the debugging information panel for an installed extension + :class: center + + +The **Inspect** button, and the **Extension ID** and **Internal UUID** fields are the same as for temporary extensions. + +Just as it does with temporarily loaded extensions, the link next to **Manifest URL** opens the loaded manifest in a new tab. + +.. note:: + + It's recommended that you use the Browser Toolbox, not the Add-on Debugger, for debugging WebExtensions. See `Debugging WebExtensions `_ for all the details. + + +The Add-ons section in about:debugging lists all web extensions that are currently installed. Next to each entry is a button labeled **Inspect**. + +.. note:: + + This list may include add-ons that came preinstalled with Firefox. + + +If you click **Inspect**, the Add-on Debugger will start in a new tab. + +.. raw:: html + + +
+
+ + +Workers +******* + +The Workers section shows all the workers you've got registered on your Firefox, categorized as follows: + + +- All registered `Service Workers `_ +- All registered `Shared Workers `_ +- Other workers, including Chrome Workers and `Dedicated Workers `_ + + +You can connect the developer tools to each worker, and send push notifications to service workers. + +.. image:: about_debugging_workers.png + :class: border + + +Service worker state +-------------------- + +The list of service workers shows the state of the service worker in its `lifecycle `_. Three states are possible: + + +- *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. +- *Running*: the service worker is currently running. It's installed and activated, and is currently handling events. +- *Stopped*: the service worker is installed and activated, but has been terminated after being idle. + + +.. image:: sample_service_worker.png + :alt: Screenshot of the debugging panel for a service worker that is in the Running state + :class: center + + +This section uses a simple ServiceWorker demo, hosted at https://serviceworke.rs/push-simple/. + +.. note:: + + From Firefox 79 onwards, 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>`. + + +Unregistering service workers +----------------------------- + +Click the **Unregister** button to unregister the service worker. + + +Sending push events to service workers +-------------------------------------- + +To debug push notifications, you can set a breakpoint in the `push event `_ 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. + + +Service workers not compatible +------------------------------ + +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. + +.. image:: worker_warning.png + :class: center + + +Service workers can be unavailable if the ``dom.serviceWorkers.enable`` preference is set to false in ``about:config``. + + +Connection to Firefox for Android 68 +************************************ + +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: + + +- `Firefox Preview `_, if your desktop Firefox is the main release or Developer Edition +- `Firefox for Android Nightly `_ + + +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) `_, which is also based on version 68. + +Note that ``about:debugging`` is not enabled by default in Firefox ESR. To enable it, open the `Configuration Editor `_ (``about:config``) and set ``devtools.aboutdebugging.new-enabled`` to **true**. + +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? `_ diff --git a/devtools/docs/user/accessibility_inspector/index.rst b/devtools/docs/user/accessibility_inspector/index.rst new file mode 100644 index 000000000000..6bd3901d791c --- /dev/null +++ b/devtools/docs/user/accessibility_inspector/index.rst @@ -0,0 +1,289 @@ +======================= +Accessibility Inspector +======================= + +The Accessibility Inspector provides a means to access important information exposed to assistive technologies on the current page via the accessibility tree, allowing you to check what's missing or otherwise needs attention. This article takes you through the main features of the Accessibility Inspector and how to use it. + +A (very) brief guide to accessibility +************************************* + +Accessibility is the practice of making your websites usable by as many people as possible. This means trying your best to not lock anyone out of accessing information because of any disability they may have, or any other personal circumstances such as the device they are using, the speed of their network connection, or their geographic location or locale. You can find more extensive information in the `Accessibility `_ section of MDN Web Docs. + +Here we are mainly talking about exposing information to people with visual disabilities — this is done via the `accessibility APIs `_ available inside web browsers, which expose information on what roles the different elements on your page play (e.g., are they just text, or are they buttons, links, form elements, etc.?). + +Semantic DOM elements have roles assigned to them by default that hint at what their purpose is. Sometimes, however, you need to use some non-semantic markup (e.g., `div `_ s) to build a complex custom control, and the control won't have a default role that reflects its purpose. In such a situation, you can use `WAI-ARIA `_ role attributes to provide your own roles. + +Roles and other information exposed by browser accessibility APIs are presented in a hierarchical structure called the accessibility tree. This is a bit like the DOM tree, except that it contains a more limited set of elements and slightly different information about them. + +Assistive technologies like screenreaders use this information to find out what's on a web page, tell their users what's there, and enable them to interact with the page. The Accessibility Inspector also uses this information to provide valuable accessibility debugging capabilities in the DevTools. + + +Accessing the Accessibility Inspector +************************************* + +When you first open any of the other Developer Tools, the accessibility features are turned off (unless you've already got them turned on in another browser tab, or got the Firefox accessibility engine started already, e.g., you might be a screenreader user or tester). + +The accessibility inspector is automatically enabled when you do one of the following(beforeFirefox 79, it had to be explicitly enabled): + + +- Choose **Accessibility** in the **Tools > Web Developer** menu. +- Select the **Accessibility** tab in the Developer Tools toolbox. +- Right-click in the main browser window, and choose **Inspect Accessibility Properties** in the context menu. +- Right-click an item in the HTML pane of the :doc:`Page Inspector <../page_inspector/index>`, and choose **Show Accessibility Properties** in the context menu. + + +Once activated, the accessibility engine remains running until you close the Developer Tools toolbox. + +.. note:: + + The accessibility engine runs in the background when the accessibility features are turned on. When enabled it may affect the metrics from other panels such as :doc:`Memory <../memory/index>` and :doc:`Performance <../performance/index>`, and have some impact onoverall browser performance. + + +If you don't wish to allow the accessibility features to be automatically enabled, you can use the `Configuration Editor `__ (also known as ``about:config``) to define the preference ``devtools.accessibility.auto-init.enabled``, and set it to ``False``. + +If you don't wish to use the accessibility features at all, you can use the `Configuration Editor `__ to set the preference ``devtools.accessibility.enabled`` to ``False``. If you do this, the methods listed above for activating the Accessibility Inspector do nothing. + + +Features of the Accessibility panel +*********************************** + +The enabled accessibility panel looks like so: + +.. image:: accessibility-inspector-tabbing_order.png + :class: border + :alt: Shows issue checker toolbar with "contrast" and "text label" options + + +On the left-hand side, there is a tree diagram representing all the items in the accessibility tree for the current page. Items with nested children have arrows that can be clicked to reveal the children, so you can move deeper into the hierarchy. Each item has two properties listed: + + +- *Role* — the role this item has on the page (e.g., ``pushbutton``, or ``footer``). This can be either a default role provided by the browser, or a role given to it via a WAI-ARIA ``role`` attribute. +- *Name* — the name this item has on the page. The name depends on the element; for example, the name of most text elements is their ``textContent``, whereas form elements' names are the contents of their associated `label `_. + + +On the right-hand side, you can see further information about the currently selected item. The listed properties are as follows: + + +- *name* — the item's name, as described above. +- *role* — the item's role, as described above. +- *actions* — a list of actions that can be performed on the item, for example, a pushbutton would have "Press" listed, while a link would have "Jump" listed. +- *value* — the value of the item. This can mean different things depending on the type of the item; for example, a form input (role: entry) would have a value of whatever is entered in the input, whereas a link's value would be the URL in the corresponding ```` element's ``href``. +- *DOMNode* — the type of DOM node that the item in the accessibility tree represents. You can click on the "target" icon that comes after it to select the node in the :doc:`Page Inspector <../page_inspector/index>`. Hovering over the "target" icon highlights the DOM node in the page content. + + .. image:: dom-node-target-icon.png + :alt: DOMNode property in accessibility inspector with target icon highlighted + +- *description* — any further description provided on the element, usually by the content of a title attribute. +- *keyboardShortcut* — any keyboard shortcut that is available to activate the element, as specified in an ``accessKey`` attribute. Note that this works correctly as of Firefox 62 `bug 1467381 Download Firefox Developer Edition + + +General +******* + +Activation +---------- + +Firebug's activation is URL based respecting the `same origin policy `_. That means that when you open a page on the same origin in a different tab, Firebug gets opened automatically. And when you open a page of a different origin in the same tab, it closes automatically. The DevTools' activation on the other hand is tab based. That means, that when you open the DevTools in a tab, they stay open even when you switch between different websites. When you switch to another tab, though, they're closed. + + +Open the tools +-------------- + +Firebug can be opened by pressing F12. To open it to inspect an element it is possible to press :kbd:`Ctrl` + :kbd:`Shift` + :kbd:`C` / :kbd:`Cmd` + :kbd:`Opt` + :kbd:`C`. The DevTools share the same shortcuts, but also provide :ref:`shortcuts for the different panels `. E.g. the :doc:`Network Monitor <../network_monitor/index>` can be opened via :kbd:`Ctrl` + :kbd:`Shift` + :kbd:`Q` / :kbd:`Cmd` + :kbd:`Opt` + :kbd:`Q`, the :doc:`Web Console <../web_console/index>` via :kbd:`Ctrl` + :kbd:`Shift` + :kbd:`K` / :kbd:`Cmd` + :kbd:`Opt` + :kbd:`K` and the :doc:`Debugger <../debugger/index>` via :kbd:`Ctrl` + :kbd:`Shift` + :kbd:`S` / :kbd:`Cmd` + :kbd:`Opt` + :kbd:`S`. + + +Web Console +*********** + +The :doc:`Web Console <../web_console/index>` is the equivalent of Firebug's Console panel. It shows log information associated with a web page and allows you to execute JavaScript expressions via its :doc:`command line <../web_console/the_command_line_interpreter/index>`. The display between both is somewhat different. This may be changed in `bug 1269730 `_. + + +Filter log messages +------------------- + +Firebug offers two ways to filter log messages, via the options menu and via the filter buttons within the toolbar. The Developer Tools console offers similar functionality via the :ref:`filter buttons inside its toolbar ` — centralized at one place. + + +Command Line API +---------------- + +The Command Line API in Firebug provides some special functions for your convenience. The Developer Tools command line has :ref:`some functions in common `, but also has some other functions and misses others. + + +Console API +----------- + +To log things to the console from within the web page Firebug makes a Console API available within the page. The Developer Tools share the `same API `_, so your ``console.*`` statements will continue to work. + + +Persist logs +------------ + +In Firebug you can click the *Persist* button within the toolbar to keep the logged messages between page navigations and reloads. In the DevTools this option is called :ref:`Enable persistent logs ` and is available within the Toolbox Options panel. + + +Server logs +----------- + +Firebug extensions like FirePHP allow to log server-side messages to the Firebug console. This functionality is already :ref:`integrated into the DevTools ` using the `ChromeLogger `_ protocol and doesn't require any extensions to be installed. + + +Command history +--------------- + +The :ref:`command history ` available through a button in Firebug's command line, is available by pressing :kbd:`↑`/:kbd:`↓` within the DevTools command line. + + +Inspect object properties +------------------------- + +By clicking on an object logged within the console you can inspect the object's properties and methods within the DOM panel. In the Firefox DevTools you can also inspect the objects. The difference is that they :ref:`show the properties and methods within a side panel inside the Web Console `. + + +Show network requests +--------------------- + +The Console panel in Firebug allows to log `AJAX `_ requests (aka `XMLHttpRequest `_). This option is also available within the DevTools Web Console via the *Net* > *XHR*. Furthermore, the Web Console even allows to display all other network requests via *Net* > *Log*. + + +View JSON and XML structures +---------------------------- + +To view JSON and XML responses of `AJAX `_ requests, Firebug has special tabs when expanding the request within the Console panel. The DevTools Web Console shows those structures directly under the "Response" tab. + + +Multi-line command line +----------------------- + +Firebug's console has a multi-line command line called Command Editor. The DevTools have a :ref:`side panel ` like the Command Editor. + + +Response preview +---------------- + +There is a *Preview* tab when a network request logged to the console is expanded in Firebug. The Web Console displays a preview within the *Response* tab. It is currently missing the preview for HTML, XML and SVG, though, which is tracked in `bug 1247392 `_ and `bug 1262796 `_, but when you click on the URL of the request you switch to the :doc:`Network Monitor <../network_monitor/index>`, which has a *Preview* tab. + + +Inspector +********* + +Firebug has an HTML panel, which allows to edit HTML/XML/SVG and the CSS related to it. Within the DevTools this functionality is served by the :doc:`Page Inspector <../page_inspector/index>`. + + +Edit HTML +--------- + +Within the Page Inspector the tag attributes and the contents can be edited inline just like in Firebug. Beyond that it allows to edit the tag names inline. + +You can also edit the HTML directly. In Firebug you do this by right-clicking a node and clicking Edit HTML... in the context menu. In the DevTools this option is also available via the context menu. There the option is called :ref:`Edit As HTML `. Only the live preview of changes is currently missing, which is tracked in `bug 1067318 `_ and `bug 815464 `_. + + +Copy HTML and related information +--------------------------------- + +Firebug's HTML panel allows to copy the inner and outer HTML of an element as well as the CSS and XPath to it via the context menu of an element. The Page Inspector provides the same functionality except copying XPaths. This is covered by `bug 987877 `_. + + +Edit CSS +-------- + +Both tools allow to view and edit the CSS rules related to the element selected within the node view in a similar way. Firebug has a Style side panel for this, the DevTools have a :doc:`Rules side panel <../page_inspector/how_to/examine_and_edit_css/index>`. + +In Firebug you add new rules by right-clicking and choosing *Add Rule...* from the context menu. The DevTools also have a context menu option for that named :ref:`Add New Rule and additionally have a + button ` within the Rules panel's toolbar to create new rules. + +To edit element styles, i.e. the CSS properties of the `style `_ attribute of an element, in Firebug you have to right-click into the Style side panel and choose Edit Element Style... from the context menu. The DevTools display an :ref:`element {} rule ` for this purpose, which requires a single click into it to start editing the properties. + + +Auto-completion of CSS +---------------------- + +As in Firebug, the Rules view provides an auto-completion for the CSS property names and their values. A few property values are not auto-completed yet, which is tracked in `bug 1337918 `_. + + +Copy & paste CSS +---------------- + +Firebug's Style side panel as well as the DevTools' Rules side panel provide options within their context menus to copy the CSS rule or the style declarations. The DevTools additionally provide an option to copy the selector of a rule and copy disabled property declarations as commented out. They are missing the option to copy the whole style declaration, though this can be achieved by selecting them within the panel and copying the selection by pressing :kbd:`Ctrl` + :kbd:`C` or via the context menu. + +The Rules side panel of the DevTools is smarter when it comes to pasting CSS into it. You can paste whole style declarations into an existing rule property declarations which are commented out are automatically disabled. + + +Toggle pseudo-classes +--------------------- + +Firebug lets you toggle the CSS `pseudo-classes `_ `:hover `_, `:active `_ and `:focus `_ for an element via the options menu of the Style side panel. In the DevTools there are two ways to do the same. The first one is to toggle them via the pseudo-class panel within the Rules side panel. The second one is to right-click and element within the node view and toggle the pseudo-classes via the :ref:`context menu `. + + +Examine CSS shorthand properties +-------------------------------- + +CSS `shorthand properties `_ can be split into their related longhand properties by setting the option *Expand Shorthand Properties* within the Style side panel. The DevTools' Rules panel is a bit smarter and allows you to expand individual shorthand properties by clicking the twisty besides them. + + +Only show applied styles +------------------------ + +The Style side panel in Firebug has an option to display only the properties of a CSS rule that are applied to the selected element and hide all overwritten styles. There is no such feature in the :doc:`Rules side panel <../page_inspector/how_to/examine_and_edit_css/index>` of the DevTools, but it is requested in `bug 1335327 `_. + + +Inspect box model +----------------- + +In Firebug the `box model `_ can be inspected via the Layout side panel. In the DevTools the :doc:`box model is part of the Computed side panel <../page_inspector/how_to/examine_and_edit_the_box_model/index>`. Both tools highlight the different parts of the box model within the page when hovering them in the box model view. Also, both tools allow you to edit the different values inline via a click on them. + + +Inspect computed styles +----------------------- + +The computed values of CSS properties are displayed within the DevTools' :ref:`Computed side panel ` like within Firebug's Computed side panel. The difference is that in the DevTools the properties are always listed alphabetically and not grouped (see `bug 977128 `_) and there is no option to hide the Mozilla specific styles, therefore there is an input field allowing to filter the properties. + + +Inspect events +-------------- + +Events assigned to an element are displayed in the Events side panel in Firebug. In the DevTools they are shown when clicking the small 'ev' icon besides an element within the node view. Both tools allow to display wrapped event listeners (e.g. listeners wrapped in jQuery functions). To improve the UI of the DevTools, there is also a request to add an Events side panel to them like the one in Firebug (see `bug 1226640 `_). + + +Stop script execution on DOM mutation +------------------------------------- + +In Firebug you can break on DOM mutations, that means that when an element is changed, the script execution is stopped at the related line within the JavaScript file, which caused the change. This feature can globally be enabled via the *Break On Mutate* button, or individually for each element and for different types of changes like attribute changes, content changes or element removal. Unfortunately, the DevTools do not have this feature yet (see `bug 1004678 `_). To stop the script execution there, you need to set a breakpoint on the line with the modification within the :doc:`Debugger panel <../debugger/index>`. + + +Search for elements via CSS selectors or XPaths +----------------------------------------------- + +Firebug allows to search for elements within the HTML panel via CSS selectors or XPaths. Also the :ref:`DevTools' Inspector panel allows to search for CSS selectors `. It even displays a list with matching IDs or classes. Searching by XPaths is not supported though (see `bug 963933 `_). + + +Debugger +******** + +What's the Script panel in Firebug, is the :doc:`Debugger panel <../debugger/index>` in the DevTools. Both allow you to debug JavaScript code executed on a website. + + +Switch between sources +---------------------- + +Firebug has a Script Location Menu listing all JavaScript sources related to the website. Those sources can be static, i.e. files, or they can be dynamically generated (i.e. scripts executed via event handlers, ``eval()``, ``new Function()``, etc.). In the DevTools' Debugger panel the scripts are listed at the left side within the :ref:`Sources side panel `. Dynamically generated scripts are only listed there when they are :doc:`named via a //# sourceURL comment <../debugger/how_to/debug_eval_sources/index>`. + + +Managing breakpoints +-------------------- + +In Firebug you can set different types of breakpoints, which are all listed within the Breakpoints side panel. In the DevTools the breakpoints are shown below each script source within the :ref:`Sources side panel `. Those panels allow you to enable and disable single or all breakpoints and to remove single breakpoints or all of them at once. They do currently only allow to set script breakpoints. XHR, DOM, Cookie and Error breakpoints are not supported yet (see `bug 821610 `_, `bug 1004678 `_, `bug 895893 `_ and `bug 1165010 `_). While there are no breakpoints for single JavaScript errors, there is a setting *Pause on Exceptions* within the :ref:`Debugger panel options `. + + +Step through code +----------------- + +Once the script execution is stopped, you can step through the code using the Continue (:kbd:`F8`), Step Over (:kbd:`F10`), Step Into (:kbd:`F11`) and Step Out (:kbd:`Shift` + :kbd:`F11`) options. They work the same in both tools. + + +Examine call stack +------------------ + +When the script execution is paused, Firebug displays the function call stack within its Stack side panel. In there the functions are listed together with their call parameters. In the DevTools the function call stack is shown within the :ref:`Call Stack side panel `. To see the call parameters in the DevTools, you need to have a look at the :doc:`Variables side panel <../debugger/how_to/set_watch_expressions/index>`. + + +Examine variables +----------------- + +The Watch side panel in Firebug displays the `window `_ object (the global scope) by default. With the script execution halted it shows the different variable scopes available within the current call stack frame. Furthermore, it allows you to add and manipulate watch expressions. The DevTools have a :doc:`Variables side panel <../debugger/how_to/set_watch_expressions/index>`, which works basically the same. The main difference is that it is empty when the script execution is not stopped, i.e. it doesn't display the ``window`` object. Though you can inspect that object either via the :doc:`DOM property viewer <../dom_property_viewer/index>` or via the :doc:`Web Console <../web_console/index>`. + + +Style Editor +************ + +The :doc:`Style Editor <../style_editor/index>` in the Firefox DevTools allows you to examine and edit the different CSS style sheets of a page like Firebug's CSS panel does it. In addition to that it allows to create new style sheets and to import existing style sheets and apply them to the page. It also allows you to toggle individual style sheets. + + +Switch between sources +---------------------- + +The CSS panel of Firebug allows to switch between different CSS sources using the CSS Location Menu. The Style Editor has a :ref:`sidebar ` for this purpose. + + +Edit a style sheet +------------------ + +Firebug's CSS panel offers three different ways for editing style sheets. The default one is to edit them inline like within the Style side panel. Furthermore it has a Source and a Live Edit mode, which allow to edit the selected style sheet like within a text editor. The Style Editor of the DevTools only has one way to edit style sheets, which corresponds to Firebug's Live Edit mode. + + +Try out CSS selectors +--------------------- + +Firebug's Selectors side panel provides a way to validate a CSS selector. It lists all elements matching the entered selector. The DevTools don't have this feature yet, but it's requested in `bug 1323746 `_. + + +Searching within the style sheets +--------------------------------- + +Firebug allows to search within the style sheets via the search field. The Style Editor in the DevTools also provides a way to search within a style sheet, though there is currently no option to search within multiple sheets (see `bug 889571 `_ and also not via a regular expression (see `bug 1362030 `_). + + +Performance Tool +**************** + +Firebug allows to profile JavaScript performance via the "Profile" button within the Console panel or the ``console.profile()`` and ``console.profileEnd()`` commands. The DevTools provide advanced tooling regarding performance profiling. A profile can be created via `console.profile() `_ and `console.profileEnd() `_ like in Firebug or via the "Start Recording Performance" button in the :doc:`Performance Tool <../performance/index>`. The output of the :doc:`Call Tree <../performance/call_tree/index>` is the one that comes nearest to the output in Firebug, but the Performance panel provides much more information than just the JavaScript performance. E.g. it also provides information about HTML parsing or layout. + +This is the part where Firebug and the DevTools differ the most, because the outputs are completely different. While Firebug focuses on JavaScript performance and provides detailed information about JavaScript function calls during the profiling session, the Performance Tool in the DevTools offers a broad spectrum of information regarding a website's performance but doesn't go into detail regarding JavaScript function calls. + + +View JavaScript call performance +-------------------------------- + +What comes nearest to Firebug's profiler output is the :doc:`Call Tree view <../performance/index>` in the Performance panel. Like in Firebug it lists the total execution time of each function call under *Total Time* as well as the number of calls under *Samples*, the time spent within the function under *Self Time* and the related percentages in reference to the total execution time. + + +.. note:: + + The times and percentages listed in the DevTools' Call Tree view is not equivalent to the ones shown in Firebug, because it uses different APIs sampling the execution of the JavaScript code. + + +Jump to function declaration +---------------------------- + +Like in Firebug's profiler output the :doc:`Call Tree view <../performance/call_tree/index>` of the DevTools' Performance Tool allows to jump to the line of code where the called JavaScript function is defined. In Firebug the source link to the function is located at the right side of the Console panel output while within the DevTools the link is placed on the right side within the Call Tree View. + + +Network Monitor +*************** + +To monitor network requests Firebug provides a Net panel. The Firefox DevTools allow to inspect the network traffic using the :doc:`Network Monitor <../network_monitor/index>`. Both tools provide similar information including a timeline showing the request and response times of the network requests. + + +Inspect request information +--------------------------- + +Both Firebug and the Firefox DevTools' Network Monitor allow you to inspect the information about a request by clicking on it. The only difference is that Firebug shows the information below the request while the Network Monitor displays it within a side panel. + +In both tools there are different tabs containing different kinds of information for the selected request. They contain a *Headers*, *Params*, *Response* and *Cookies* panel. A preview of the response is shown within specifically named panels like *HTML*. The Network Monitor has a *Preview* panel for this purpose. It doesn't provide information about the cached data yet (see `bug 859051 `_), but provides a *Security* tab in addition to Firebug's information and a *Timings* tab showing detailed information about the network timings. + + +View request timings +-------------------- + +Firebug offers detailed information about the network timings related to a request by hovering the Timeline column within its Net panel. The Network Monitor shows this information within a :ref:`Timings side panel ` when you select a request. + + +View remote address +------------------- + +The remote address of a request is shown within the Remote IP column within Firebug. In the Network Monitor the address is shown at *Remote Address* in the *Headers* tab when a request is selected. + + +Search within requests +---------------------- + +The search field within Firebug allows to search within the requests. The search field in the Firefox DevTools filters the requests by the entered string. + +Firebug allowed to search within the response body of the network requests by checking *Response Bodies* within its search field options. This feature is not available yet within the Network Monitor, but it's requested in `bug 1334408 `_. While response bodies can't be searched yet, the Network Monitor allows to :ref:`filter by different request properties `. + + +Storage Inspector +***************** + +The Cookies panel in Firebug displays information related to the cookies created by a page and allows to manipulate the information they store. Within the DevTools this functionality is located within the :doc:`Storage Inspector <../storage_inspector/index>`. In contrast to Firebug the Storage Inspector not only allows to inspect cookies but also other kinds of storages like the local and session storage, the cache and `IndexedDB `_ databases. + + +Inspect cookies +--------------- + +All cookies related to a website are listed inside the Cookies panel in Firebug. Inside the DevTools, the cookies are grouped by domain under the Cookies section within the :doc:`Storage Inspector <../storage_inspector/index>`. Both show pretty much the same information per cookie, i.e. the name, value, domain, path, expiration date and whether the cookie is HTTP-only. + +The DevTools don't show by default whether a cookie is secure, but this can be enabled by right-clicking the table header and checking *Secure* from the context menu. Additionally, the DevTools allow to display the creation date of a cookie as well as when it was last accessed and whether it is host-only. + + +Edit cookies +------------ + +To edit a cookie in Firebug you have to right-click the cookie and choose *Edit* from the context menu. Then a dialog pops up allowing you to edit the data of the cookie and save it. Inside the Storage Inspector you just have to double-click the data you want to edit. Then an inline editor allows you to edit the value. + +Delete cookies +-------------- + +Firebug's Cookies panel allows you to delete all cookies of a website via the menu option *Cookies* > *Remove Cookies* or by pressing :kbd:`Ctrl` + :kbd:`Shift` + :kbd:`O`. It also allows you to only remove session cookies via *Cookies* > *Remove Session Cookies* and to remove single cookies by right-clicking them and choosing *Delete*. The DevTools Storage Inspector allows to remove all cookies and a single one by right-clicking on a cookie and choosing *Delete All* resp. *Delete ""*. Additionally, it allows to delete all cookies from a specific domain via the context menu option *Delete All From ""*. It currently does not allow to only delete session cookies (see `bug 1336934 `_). + + +Feedback +******** + +We are always happy to respond to feedback and questions. If you have any queries or points of view, feel free to share them on our `DevTools Discourse Forum `_. diff --git a/devtools/docs/user/network_monitor/index.rst b/devtools/docs/user/network_monitor/index.rst new file mode 100644 index 000000000000..be18c70aa9a7 --- /dev/null +++ b/devtools/docs/user/network_monitor/index.rst @@ -0,0 +1,62 @@ +=============== +Network Monitor +=============== + +The Network Monitor shows you all the HTTP requests Firefox makes (for example, when it loads a page, or due to `XMLHttpRequests `_), how long each request takes, and details of each request. + +Opening the Network Monitor +*************************** + +There are a few different ways to open the Network Monitor: + +- Press :kbd:`Ctrl` + :kbd:`Shift` + :kbd:`E` (:kbd:`Cmd` + :kbd:`Opt` + :kbd:`E` on a Mac). + +- Select "Network" from the Web Developer menu, (which is a submenu of the Tools menu on OS X and Linux). + +- Click the wrench icon |image1|, which is in the main toolbar or under the Hamburger menu |image2|, then select "Network". + +.. |image1| image:: wrench-icon.png + :width: 20 + +.. |image2| image:: hamburger.png + :width: 20 + +The Network Monitor will appear at the bottom of the browser window. When it first opens, the Network Monitor does not show request information. The just opened tool looks like this: + +.. image:: network_monitor_new.png + :class: border + +Either action causes the Network Monitor to begin monitoring network activity. Once the tool is monitoring network requests, the display looks like this: + +.. image:: network_monitor.png + :class: border + +When it is actively monitoring activity, the Network Monitor records network requests any time the Toolbox is open, even if the Network Monitor itself is not selected. This means you can start debugging a page in, for example, the Web Console, then switch to the Network Monitor to see network activity without having to reload the page. + +UI overview +*********** + +The UI is divided into four main pieces: + +- The main screen contains the :doc:`toolbar `, the :doc:`network request list `, and the :doc:`network request details pane `: + +.. image:: network_monitor_closeup.png + :class: border + +- The :doc:`performance analysis ` view is a separate screen: + +.. image:: network_performance.png + :class: border + +Working with the network monitor +******************************** + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar ` +- :doc:`Network request list ` +- :doc:`Network request details ` +- :doc:`Network traffic recording ` +- :doc:`Throttling ` +- :doc:`Inspecting web sockets ` +- :doc:`Inspecting server-sent events ` diff --git a/devtools/docs/user/network_monitor/inspecting_server-sent_events/index.rst b/devtools/docs/user/network_monitor/inspecting_server-sent_events/index.rst new file mode 100644 index 000000000000..a75666e618b7 --- /dev/null +++ b/devtools/docs/user/network_monitor/inspecting_server-sent_events/index.rst @@ -0,0 +1,63 @@ +============================= +Inspecting server-sent events +============================= + +`Server-sent events `_ allow for an inversion of the traditional client-initiated web request model, with a server sending new data to a web page at any time by pushing messages. From Firefox 82 onwards, you can inspect server-sent events and their message contents using the :doc:`Network Monitor <../index>`. This article shows you how. + +Inspecting the SSE network activity +*********************************** + +When you are viewing a document that is receiving server-sent events, you can go to the Network Monitor, select the file that is sending the server-sent events, and view the received messages in the *Response* tab on the right-hand panel. + +.. image:: basic-sse-message-view.png + :class: border + + +At the top of the panel there is a trash can icon, which allows you to trash the messages sent so far, and a filter field in which you can enter a text string to filter the displayed messages by. + + +Viewing the message contents +**************************** + +Select one of the messages listed in the *Response* tab, and you'll see the message contents displayed at the bottom of that same tab. + +.. image:: see-message-detail-view.png + :class: border + +In the above example, you can see that JSON and raw data representations of the content are shown. For a plain text message, you'd just see a raw data section. + +The supported data formats are as follows: + +- Mercure protocol +- JSON + + +Customizing the displayed columns +********************************* + +For each message, you'll see *Data* and Time columns by default, but you can right-click on the table header to bring up a context menu in which you can toggle columns on and off, and reset it back to its original state. + +.. image:: customize-columns.png + :class: border + +The available columns are as follows: + +- *Data*: A summary of the contained message data. +- *Size*: The size of the message. +- *Time*: A timestamp representing when the message was sent. +- *Event Name*: The name of the event type that resulted in the message being sent (e.g. ```message``` or ```ping```). +- *Last Event ID*: The ID of the last event that was fired. +- *Retry*: The interval after which failed message will be resent. + + +Network Monitor features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar <../toolbar/index>` +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../performance_analysis/index>` +- :doc:`Throttling <../throttling/index>` +- :doc:`Inspecting web sockets <../inspecting_web_sockets/index>` diff --git a/devtools/docs/user/network_monitor/inspecting_web_sockets/index.rst b/devtools/docs/user/network_monitor/inspecting_web_sockets/index.rst new file mode 100644 index 000000000000..f69edfa770fb --- /dev/null +++ b/devtools/docs/user/network_monitor/inspecting_web_sockets/index.rst @@ -0,0 +1,121 @@ +====================== +Inspecting web sockets +====================== + +Since Firefox 71, the :doc:`Network Monitor <../index>` has had the ability to inspect `web socket `_ connections. This article explores what functionality the Web Socket Inspector makes available. + +Accessing the inspector +*********************** + +When you are inspecting a web app that utilizes a web socket connection, the web socket requests are listed in the list of requests in the Network Monitor along with all other requests. + +.. image:: wsi-filiter.png + :alt: WS filter in the network inspector + +You can use the WS button to filter the list for just web socket connections. Only requests with the `101 status code `_ (WebSocket Protocol Handshake) are visible, which indicates that the server is switching to a web socket connection. + +Clicking on a web socket request opens the usual sidebar to reveal additional details. Choose the **Response** tab to inspect web socket frames sent and received through the selected connection. + +.. image:: new-web-sockets.png + :alt: Messages panel in the web socket inspector + :class: border + +The live-updated table shows data for sent (green arrow) and received (red arrow) frames. Each frame expands on click, so you can inspect the formatted data. + +Pausing web socket traffic +************************** + +You can use the pause/resume button in the Network Monitor toolbar to stop intercepting web socket traffic. This allows you to capture only the frames that you are interested in. + +.. image:: ws-pause.png + :alt: Pausing the web socket inspector + +Filtering web socket frames +*************************** + +To focus on specific messages, frames can be filtered using the filter at the top of the *Response* panel. + +.. image:: ws_response_text_filter.png + :class: border + :alt: web socket frame filter + +There are also predefined filters, available in the tool bar of the Response pane, grouped into a selection list. + +.. image:: ws_filter_menu.png + :alt: Screenshot showing the filter menu for WebSocket messages + +The following filters are available: + +.. list-table:: + :widths: 20 80 + :header-rows: 0 + + * - **All** + - Displays all messages (by default, except control messages). + + * - **Sent** + - Displays only messages sent by the browser (by default, except control messages). + + * - **Received`** + - Displays only messages received from the server (by default, except control messages). + + * - **Control** + - (Available starting in Firefox 76). Displays messages for control frames (Ping, Pong, or Close). This filter can be combined with the others, to display, for example, only messages for control frames sent by the browser. + +Columns in the Response pane +**************************** + +In the **Response** pane, you can choose to show the following information about each frame: + +- Data +- Size +- Time +- OpCode +- MaskBit +- FinBit + +The *Data* and *Time* columns are visible by default, but you can customize the interface to see more columns by choosing which ones to show from the context menu that is opened by right-clicking in the table header. + + +.. image:: ws_message_columns.png + :class: border + :alt: columns in the messages panel + + +Expanding each message +********************** + +Selecting a message in the list shows a preview of the data being sent in that message, at the bottom of the Response pane. + +.. image:: ws_expand_message.png + :class: border + :alt: web socket payload preview + + +Supported WS protocols +********************** + +The inspector currently supports the following web socket protocols: + +- Plain JSON +- Socket.IO +- SockJS +- SignalR +- WAMP +- STOMP +- STOMP inside SockJS + +The payload based on those protocols is parsed and displayed as an expandable tree for easy inspection, although you can of course still see the raw data (as sent over the wire) as well. + +Network Monitor features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar <../toolbar/index>` +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../performance_analysis/index>` +- :doc:`Throttling <../throttling/index>` +- :doc:`Inspecting web sockets <../inspecting_web_sockets/index>` +- :doc:`Inspecting server-sent events <../inspecting_server-sent_events/index>` diff --git a/devtools/docs/user/network_monitor/performance_analysis/index.rst b/devtools/docs/user/network_monitor/performance_analysis/index.rst new file mode 100644 index 000000000000..f6eeacfc24b2 --- /dev/null +++ b/devtools/docs/user/network_monitor/performance_analysis/index.rst @@ -0,0 +1,35 @@ +==================== +Performance Analysis +==================== + +The Network Monitor includes a performance analysis tool, to help show you how long the browser takes to download the different parts of your site. + +Using the Performance analysis tool +*********************************** + +To run the performance analysis tool click the stopwatch icon in the :doc:`Toolbar <../toolbar/index>` + +(Alternatively, if you have only just opened the Network Monitor, so it's not yet populated with the list of requests, you'll get a stopwatch icon in the main window.) + +The Network Monitor then loads the site twice: once with an empty browser cache, and once with a primed browser cache. This simulates the first time a user visits your site, and subsequent visits. It displays the results for each run side by side, or vertically if the browser window is narrow: + +.. image:: network_performance.png + :class: border + +The results for each run are summarized in a table and a pie chart. The tables group resources by type, and show the total size of each resource and the total time it took to load them. The accompanying pie chart shows the relative size of each resource type. + +To get back to the Network Monitor's list of network requests click the "Back" button on the left. + +Clicking on a slice of the pie takes you to the Network Monitor for that run, with a filter automatically applied to see :ref:`only that resource type `. + +Network Monitor Features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar <../toolbar/index>` +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../recording/index/>` +- :doc:`Network traffic recording <../recording/index/>` +- :doc:`Throttling <../throttling/index>` diff --git a/devtools/docs/user/network_monitor/recording/index.rst b/devtools/docs/user/network_monitor/recording/index.rst new file mode 100644 index 000000000000..379ac43f4212 --- /dev/null +++ b/devtools/docs/user/network_monitor/recording/index.rst @@ -0,0 +1,34 @@ +========================= +Network monitor recording +========================= + +You can pause and resume the monitoring of network traffic using the pause button. + +Pausing and resume network traffic recording +******************************************** + +The Network Monitor has a button that pauses and resumes recording of the current page's network traffic. This is useful in situations where, for example, you are trying to get a stable view of a page for debugging purposes, but under normal circumstances the view keeps evolving due to persistent network requests. The pause button allows you to look at a certain snapshot. + +The button can be found at the far left of the main Network Monitor toolbar, and looks like a typical pause button — |image1|. + +.. |image1| image:: pause-icon.png + :width: 20 + +You can see it here in context: + +.. image:: play-pause-network-traffic.png + :class: border + +Once pressed, the button changes to a play icon, and you can toggle network traffic recording back on by pressing it again. + +Network Monitor features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar <../toolbar/index>` +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../recording/index/>` +- :doc:`Performance analysis <../performance_analysis/index>` +- :doc:`Throttling <../throttling/index>` diff --git a/devtools/docs/user/network_monitor/request_details/index.rst b/devtools/docs/user/network_monitor/request_details/index.rst new file mode 100644 index 000000000000..67a6fbc754c0 --- /dev/null +++ b/devtools/docs/user/network_monitor/request_details/index.rst @@ -0,0 +1,501 @@ +======================= +Network request details +======================= + +The request details pane appears when you click on a network request in the request list. This pane provides more detailed information about the request. + +Network request details +*********************** + +Clicking on a row displays a new pane in the right-hand side of the network monitor, which provides more detailed information about the request. + +.. image:: network-details-fx78.png + :alt: Screenshot of the Network Request details pane, without callouts for the close-pane button and the detail tabs + :class: center + +.. note:: + + The screenshots and descriptions in this section reflect Firefox 78. Earlier versions appeared similarly, but might not include some functionality. + + +The tabs at the top of this pane enable you to switch between the following pages: + +- :ref:`Headers ` +- **Messages** (only for WebSocket items) +- :ref:`Request ` +- :ref:`Response ` +- :ref:`Cache ` +- :ref:`Timings ` +- :ref:`Security ` +- :ref:`Stack trace ` (only when the request has a stack trace, e.g. a script called by another script). + + +Clicking the icon at the right-hand end of the :doc:`toolbar <../toolbar/index>` closes the details pane and returns you to the list view. + + +.. _network-monitor-request-details-headers-tab: + +Headers tab +----------- + +The Headers tab has a toolbar, followed by three main sections. + +This includes: + + +- Information about the request + + - Status: The response status code for the request; click the "?" icon to go to the reference page for the status code. + - Version: The version of HTTP used. + - Transferred: The amount of data transferred for the request. + - Referrer policy: The value of the `Referrer-policy header `_. + +- **HTTP Response headers** +- **HTTP Request headers** + +Each section has a disclosure triangle to expand the section to show more information. + + +Headers toolbar +~~~~~~~~~~~~~~~ + +Using the Headers toolbar, you can: + + +- Filter the headers in the Response Headers and Request Headers sections. +- **Block** the domain involved in this request. The domain is added to the :ref:`Blocking sidebar `. +- Resend the request. The **Resend** button opens a menu with two items: + + - **Resend**: Resends the request. + - **Edit and Resend**: Enables an editing mode, where you can modify the method, URL, request headers, or request body of the request. Click **Send** to send the modified request, or **Cancel** to cancel editing. + + +Request Information +~~~~~~~~~~~~~~~~~~~ + +The following information is shown only when the section is expanded: + +- **Scheme**: The scheme used in the URL +- **Host**: The server involved in the request +- **Filename**: The full path to the file requested +- **Address**: The IP address of the host + +The following information is shown in both the collapsed and the expanded states: + + +- **Status:** The `HTTP response code `_ for the request. +- **Version**: The HTTP version used +- **Transferred**: The amount of data transferred with the request +- The **Referrer Policy**, which governs which referrer information, sent in the `Referer `_ header, should be included with requests. (See `Referrer-Policy `_ for a description of possible values) +- **Blocking**: If the request is to a site that is associated with a known tracker, an icon and a message are shown; otherwise, this field is not shown. + + +Response headers +~~~~~~~~~~~~~~~~ + +The response headers section shows details about the response. For each line in the response headers section, a question mark links to the documentation for that response header, if one is available. + +A **Raw** toggle button in the section heading controls whether the headers are shown with formatting, or as plain, unformatted text. + +.. note:: + Note that the keys in the response header are all in lowercase, while the request headers keys are not. `HTTP/2 requires that all headers be lowercase `_; response headers are shown as they are received from the server. (There may be some exceptions, such as ``X-Firefox-Spdy``, which is added by Firefox.) + + +.. image:: response-headers-fx78.png + :alt: Screenshot showing the Request headers section of the Request details pane + :class: border + +You can copy some or all of the response header in JSON format by using the context menu: + +.. image:: copy-response-headers-fx78.png + :alt: Screenshot showing the Response headers pane, and its context menu with "Copy" and "Copy all" items + :class: border + +If you select **Copy**, a single key word, value pair is copied. If you select **Copy All**, the entire header is copied in JSON format, giving you something like this (after running the results through a JSON validator): + + +.. code-block:: json + + { + "Response headers (1.113 KB)": { + "headers": [ + { + "name": "accept-ranges", + "value": "bytes" + }, + { + "name": "age", + "value": "0" + }, + { + "name": "backend-timing", + "value": "D=74716 t=1560258099074460" + }, + { + "name": "cache-control", + "value": "private, must-revalidate, max-age=0" + }, + { + "name": "content-disposition", + "value": "inline; filename=api-result.js" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-length", + "value": "673" + }, + { + "name": "content-type", + "value": "text/javascript; charset=utf-8" + }, + { + "name": "date", + "value": "Tue, 11 Jun 2019 13:01:39 GMT" + }, + { + "name": "mediawiki-login-suppressed", + "value": "true" + }, + { + "name": "p3p", + "value": "CP=\"This is not a P3P policy! See https://en.wikipedia.org/wiki/Special:CentralAutoLogin/P3P for more info.\"" + }, + { + "name": "server", + "value": "mw1316.eqiad.wmnet" + }, + { + "name": "server-timing", + "value": "cache;desc=\"pass\"" + }, + { + "name": "strict-transport-security", + "value": "max-age=106384710; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "Accept-Encoding,Treat-as-Untrusted,X-Forwarded-Proto,Cookie,Authorization,X-Seven" + }, + { + "name": "via", + "value": "1.1 varnish (Varnish/5.1), 1.1 varnish (Varnish/5.1)" + }, + { + "name": "x-analytics", + "value": "ns=-1;special=Badtitle;WMF-Last-Access=11-Jun-2019;WMF-Last-Access-Global=11-Jun-2019;https=1" + }, + { + "name": "x-cache", + "value": "cp1075 pass, cp1075 pass" + }, + { + "name": "x-cache-status", + "value": "pass" + }, + { + "name": "x-client-ip", + "value": "204.210.158.136" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "X-Firefox-Spdy", + "value": "h2" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-powered-by", + "value": "HHVM/3.18.6-dev" + }, + { + "name": "x-search-id", + "value": "esvan0r5bnnwscyk2wq09i1im" + }, + { + "name": "x-varnish", + "value": "766019457, 417549316" + } + ] + }, + "Request headers (665 B)": { + "headers": [ + { + "name": "Accept", + "value": "*/*" + }, + { + "name": "Accept-Encoding", + "value": "gzip, deflate, br" + }, + { + "name": "Accept-Language", + "value": "en-US,en;q=0.5" + }, + { + "name": "Connection", + "value": "keep-alive" + }, + { + "name": "Cookie", + "value": "WMF-Last-Access=11-Jun-2019; WMF-Last-Access-Global=11-Jun-2019; mwPhp7Seed=5c9; GeoIP=US:NY:Port_Jervis:41.38:-74.67:v4" + }, + { + "name": "DNT", + "value": "1" + }, + { + "name": "Host", + "value": "en.wikipedia.org" + }, + { + "name": "Referer", + "value": "https://www.wikipedia.org/" + }, + { + "name": "TE", + "value": "Trailers" + }, + { + "name": "User-Agent", + "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" + } + ] + } + } + +Request headers +~~~~~~~~~~~~~~~ + +The Request headers section shows details about the request headers. For each line in the request headers section, a question mark links to the documentation for that request header, if one is available. + +A **Raw** toggle button in the section heading controls whether the headers are shown with formatting, or as plain, unformatted text. + +.. image:: request-headers-fx78.png + :alt: Screenshot showing the Request headers section of the Request details pane + :class: border + + +.. _network-monitor-request-details-cookies-tab: + +Cookies tab +----------- + +This tab lists full details of any cookies sent with the request or response: + +.. image:: network_cookies.png + :class: border + +As with headers, you can filter the list of cookies displayed. The full list of cookie attributes is shown—see the following screenshot showing Response cookies with further attributes shown. + +.. image:: highlight-samesite-attribute.png + :alt: cookies panel in firefox devtools network monitor, showing a number of cookie attributes including samesite + +The ``samesite`` attribute has been shown since Firefox 62 (`bug 1452715 `_). + + +.. _network-monitor-request-details-request-tab: + +Request tab +----------- + +Request shows the complete request parameters, by default, in a formatted view: + +.. image:: json_formatted_request.png + :class: border + + +Switch the toggle button to have the raw view presented: + +.. image:: json_raw_request.png + :class: border + + +.. _network-monitor-request-details-response-tab: + +Response tab +------------ + +The complete content of the response. If the response is HTML, JS, or CSS, it will be shown as text: + +.. image:: html_formatted_response.png + :class: border + + +The toggle button for switching between raw and formatted response view has been implemented (`bug 1693147 `_). The previous HTML example makes use of the formatted view. When the toggle button is turned on, the raw response view will be enabled: + +.. image:: html_raw_response.png + :class: border + + +If the response is JSON, it will be shown as an inspectable object: + +.. image:: json_formatted_response.png + :class: border + + +In the raw response view the response will be shown as a string: + +.. image:: json_raw_response.png + :class: border + + +If the response is an image, the tab displays a preview: + +.. image:: response_pane_image.png + :class: border + + +If the response is a web font, the tab also displays a preview: + +.. image:: response_font.png + :class: border + + +For network responses that are initiated by a `WebSocket `_ connection, the details pane shows any associated messages. For more information, see :doc:`Inspecting web sockets <../inspecting_web_sockets/index>`. + + +.. _network-monitor-request-details-cache-tab: + +Cache tab +--------- + +If the response is cached (i.e. a 304), the Cache tab displays details about that cached resource. + +.. image:: response_cache.png + :class: border + +These details include: + +- **Last fetched:** The date the resource was last fetched +- **Fetched count:** The number of times in the current session that the resource has been fetched +- **Data size:** The size of the resource. +- **Last modified:** The date the resource was last modified. +- **Expires:** The date the resource expires. +- **Device:** The device the resource was fetched from (e.g. "disk"). + + +HTML preview +~~~~~~~~~~~~ + +If the response is HTML, a preview of the rendered HTML appears inside the Response tab, above the response payload. + + +.. _network-monitor-request-details-timings-tab: + +Timings tab +----------- + +The Timings tab provides information about how long each stage of a network request took, with a more detailed, annotated, view of the timeline bar, so it is easy to locate performance bottlenecks. + +.. image:: network-timings-tab.png + :class: border + + +This tab can include the following sections. + + +Queued, Started, Downloaded +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +New in Firefox 72, we now show the following timings at the top of the Timings tab, making dependency analysis a lot easier: + +- Queued: When the resource was queued for download. +- Started: When the resource started downloading. +- Downloaded: When the resource finished downloading. + + +.. note:: + Future versions will also show this information when entries in the network monitor timeline graph are moused over (see `bug 1580493 `_). + + +Request Timing +~~~~~~~~~~~~~~ + +The *Request Timing* section breaks a network request down into the following subset of the stages defined in the `HTTP Archive `_ specification: + + +.. list-table:: + :widths: 20 80 + :header-rows: 0 + + * - Name + - Description + + * - Blocked + - Time spent in a queue waiting for a network connection. + + The browser imposes a limit on the number of simultaneous connections that can be made to a single server. In Firefox this defaults to 6, but can be changed using the `network.http.max-persistent-connections-per-server `_ preference. If all connections are in use, the browser can't download more resources until a connection is released. + + * - DNS resolution + - Time taken to resolve a host name. + + * - Connecting + - Time taken to create a TCP connection. + + * - Sending + - Time taken to send the HTTP request to the server. + + * - Waiting + - Waiting for a response from the server. + + * - Receiving + - Time taken to read the entire response from the server (or cache). + + +Server Timing +~~~~~~~~~~~~~ + +New in Firefox 71, the *Server Timing* section lists any information provided in the `Server-Timing `_ header — this is used to surface any backend server timing metrics you've recorded (e.g. database read/write, CPU time, file system access, etc.). + +The header takes a series of descriptions and durations, which can be anything you like. In the above screenshot for example, the highlighted request's ``Server-Timing`` header contains 4 items — *data*, *markup*, *total*, and *miss*. + + +.. _network-monitor-request-details-security-tab: + +Security tab +------------ + +If the site is being served over HTTPS, you get an extra tab labeled "Security". This contains details about the secure connection used including the protocol, the cipher suite, and certificate details: + +.. image:: network_security.png + :alt: border + +The Security tab shows a warning for security weaknesses. Currently it warns you about two weaknesses: + +1. Using SSLv3 instead of TLS +2. Using the RC4 cipher + +.. image:: security-warning.png + :class: center + + +.. _network-monitor-request-details-stack-trace-tab: + +Stack trace tab +--------------- + +Stack traces are shown in the *Stack Trace* tab, for responses that have a stack trace of course. + +.. image:: network_stack_trace.png + :class: border + + +Network Monitor Features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar <../toolbar/index>` +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../performance_analysis/index>` +- :doc:`Throttling <../throttling/index>` +- :doc:`Inspecting web sockets <../inspecting_web_sockets/index>` diff --git a/devtools/docs/user/network_monitor/request_list/index.rst b/devtools/docs/user/network_monitor/request_list/index.rst new file mode 100644 index 000000000000..c0345290c803 --- /dev/null +++ b/devtools/docs/user/network_monitor/request_list/index.rst @@ -0,0 +1,497 @@ +==================== +Network request list +==================== + +The request list of the Network Monitor shows a list of all the network requests made in the course of loading the page. + + +Network request list +-------------------- + +By default, the Network Monitor shows a list of all the network requests made in the course of loading the page. Each request is displayed in its own row: + +.. image:: network_request_list.png + :class: border + +By default, the Network Monitor is cleared each time you navigate to a new page or reload the current page. You can override this behavior by checking "Enable persistent logs" in the :ref:`Settings `. + + +Network request columns +----------------------- + +You can toggle columns on and off by right-clicking on the table header and choosing the specific column from the context menu. A **Reset Columns** command is available on the context menu to reset the columns to their initial configuration. + +You can also change the width of the columns to help make the information you are looking for easier to view. The mouse pointer changes to a resize icon when you move it over the border of a column. You can drag to manually set the size of column. Starting in Firefox 76 you can double-click a column divider to resize the column to the left of it to fit its contents. + +The **Reset Columns** command on the context menu also resets the width of the columns to the default values. + +.. raw:: html + + +
+
+ +Clicking the column header label sorts the request list by that column. You can reset the sort to the default by selecting "Reset Sorting" from the context menu. + +.. image:: network_monitor_columns_menu.png + :alt: Screenshot of the context menu for selecting columns to display in the Network monitor + :class: center + + +Here is a list of all available columns: + +.. |image1| image:: blocked_nw_icon.png + :alt: Red circle with a diagonal slash + :width: 20 + +.. |image2| image:: nwmon-turtle-tooltip.png + :alt: Screenshot of a network request with a turtle icon, and a tooltip explaining the problem + :class: border + + +- **Status**: The HTTP status code returned. The numeric code is displayed on a colored background, to help unusual ones stand out. If there was no response, this column is empty. Or you might see a |image1| red circle with a diagonal slash for responses that were blocked by the browser or the server. +- **Method**: The HTTP request method used. +- **Domain**: Domain of the path requested. + + - If the request used SSL/TLS and the connection had security weaknesses such as weak ciphers, you'll see a warning triangle next to the domain. Y + - Hover over the domain to see the IP address. + - There's an icon next to the domain that gives you extra information about the security status of that request. See :ref:`Security icons `. + +- **File**: The basename of the file requested. + + - (Starting in Firefox 80) On the right edge of the File column, a turtle icon appears if the server waiting time exceeds a threshold (default: 500 ms). A tooltip explains the problem. You can configure the threshold in the `Configuration Editor `_ (about:config) by modifying the ``devtools.netmonitor.audits.slow`` setting. + - |image2| + +- **URL**: The `URL `_ of the file requested. +- **Protocol:** The network protocol used to transfer the data, this column is hidden by default. +- **Scheme:** The scheme (https/http/ftp/...) of the path requested. This column is hidden by default. +- **Remote IP**: The IP address of the server answering the request. This column is hidden by default. +- **Type**: ``Content-type`` of the response. +- **Cookies:** The number of request cookies associated to the request. This column is hidden by default. This is new in Firefox 55. +- **Set-Cookies:** The number of response cookies associated to the request. This column is hidden by default. This is new in Firefox 55. +- **Transferred**: The number of bytes that were actually transferred to load the resource, or a message about why the resource was not transferred. A number value is less than **Size** if the resource was compressed. + + - If the resource was fetched from a `service worker `_ cache, then this cell displays "service worker". + - Cached resources may be fetched from the cache and the network simultaneously, which may improve load time for slow caches. `Starting with Firefox 68 `_, the transferred column lists either "cached (raced)" or "[size] (raced)" depending on the faster source. This feature is called `Race Cache With Network (RCWN) `_. + - If the resource was blocked, the message indicates why it was blocked. For example, "CSP", "Malware", "CORS Missing Allow Origin", "Blocked by [Name of Extension]". + +- **Size**: The size of the transferred resource. + + +Image thumbnails +~~~~~~~~~~~~~~~~ + +If the request is for an Image, hovering over its filename shows a preview of the image in a tooltip: + +.. image:: image_preview.png + :class: border + + +.. _network-monitor-request-list-security-icons: + +Security icons +~~~~~~~~~~~~~~ + +The Network Monitor displays an icon in the Domain column: + +.. image:: network_message_list_63.png + :class: border + + +This gives you extra information about the security status of the request: + +.. |image3| image:: https.svg + :width: 20 + +.. |image4| image:: https-weak.svg + :width: 20 + +.. |image5| image:: https-failed.svg + :width: 20 + +.. |image6| image:: http.svg + :width: 20 + +.. |image7| image:: localhost.svg + :width: 20 + +.. |image8| image:: tracker_icon.png + :width: 20 + + +.. list-table:: + :widths: 25 75 + :header-rows: 1 + + * - Icon + - Meaning + + * - |image3| + - HTTPS + + * - |image4| + - Weak HTTPS (for example, a weak cipher was used) + + * - |image5| + - Failed HTTPS (for example, a certificate was invalid) + + * - |image6| + - HTTP + + * - |image7| + - Localhost + + * - |image8| + - Indicates that the URL belongs to a known tracker that would be blocked with content blocking enabled. + + +Timeline +-------- + +The request list also displays a timeline for the different parts of each request. + +.. image:: timeline.png + :class: border + + +Each timeline is given a horizontal position in its row relative to the other network requests, so you can see the total time taken to load the page. For more details on the color-coding used here, see the section on the :ref:`Timings ` page. + +Starting in Firefox 45, the timeline also contains two vertical lines: + + +- The blue line marks the point at which thepage's `DOMContentLoaded `_ event is triggered. +- The red line marks the point at which the page's `load `_ event is triggered. + + +.. _network_monitor_blocking_specific_urls: + +Blocking specific URLs +---------------------- + +If you want to view your page as it would look without a resource (e.g., if it were blocked by the browser or an extension), you can block requests matching patterns you specify. + + +1. Click the **Request Blocking** icon in the toolbar. This opens the **Blocking** sidebar. (Click the icon again when you want to close the sidebar.) + + .. image:: request_blocking_panel.png + :alt: Screen shot of the Blocking panel, with arrows indicating the panel and the Request Blocking toolbar icon + :class: center + +2. Enter a string in the field with the placeholder text *Block resource when URL contains*. +3. Reload the page to test it with the specified URL blocked. + + +Other actions you can take with Request Blocking: + + +- To turn all request blocking off or on: Toggle the checkbox next to Enable Request Blocking. +- To turn a specific block off or on: Toggle the checkbox next to that item. +- To delete a blocked item, click the X icon that appears when you focus the item. +- (Starting with Firefox 77) Right-click any item in the list and choose from the context menu: + + - **Enable all** enables blocking of all items in the list. + - **Disable all** disables blocking of all items in the list. + - **Remove all** deletes all items in the list. + + +Blocking a specific URL from the request list +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also block a URL from the request list: + +.. image:: beforeblocking.png + :class: border + + +1. Hover over the item you want to block in the Request List. +2. Select Block URL from the context menu. +3. When you refresh the page, that specific URL will be blocked and a message will be added to the item in the list indicating that it has been blocked by the DevTools. + +.. image:: afterblocking.png + :class: border + + +Stop blocking a URL from the Request List +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. image:: unblockurl.png + :class: border + +1. Hover over the item. +2. Select **Unblock URL**. +3. Now when you refresh the page, the item will once enabled. + + +.. note:: + (Starting in Firefox 80) You can also block and unblock URLs from the :doc:`Web Console <../../web_console/index>`, using the ``:block`` and ``:unblock`` helper commands. These accept any string, and affect any URL containing the string. + + +.. _request-list-filtering-requests: + +Filtering requests +****************** + +You can filter requests by content type, by whether they are XMLHttpRequests or WebSocket requests, or by request properties. + +.. |br| raw:: html + +
+ + +.. list-table:: + :widths: 25 75 + :header-rows: 1 + + * - Filter type + - How to apply + + * - Content type + - Use the buttons in the :doc:`toolbar <../toolbar/index>` (**HTML**, **CSS**, **JS**). + + * - `XHR `_ requests + - Use the **XHR** button in the :doc:`toolbar <../toolbar/index>`. + + * - `WebSocket `_ connections + - Use the **WS** button in the :doc:`toolbar <../toolbar/index>`. You can filter by plain text (in which case the text is used to find partial matches; entering "for" will match any message that contains the word "for") or—as of `Firefox 75 `_ — using `regular expressions `_ (by writing the regexp bracketed within slashes; "/.+Corp.*/" will look for any occurrence of "Corp" which has at least one character before it and may or may not have any characters after it, for example). |br| |br| The third-party add-on `WebSocket Sniffer `_ may be helpful as well. + + * - URL + - Use the *Filter URLs* box in the :doc:`toolbar <../toolbar/index>`. You can focus it by clicking in the filter box, or by pressing :kbd:`Ctrl` + :kbd:`F` (or :kbd:`Cmd` + :kbd:`F` on a Mac); then start typing. The list of network requests is filtered to include only requests that contain your filter string, in either the Domain or the File portions. |br| |br| You can filter requests that *don't* contain your filter string by prefixing your query with the "-" operator. For example, the query "-google.com" will show all requests that don't have "google.com" in the URL. + + * - Request properties + - Use the search box in the :doc:`toolbar <../toolbar/index>`. See next section. + + +.. _request-list-filtering-by-properties: +.. _request-list-requst-list-cause-column: + +Filtering by properties +~~~~~~~~~~~~~~~~~~~~~~~ + +The search box recognizes specific keywords, which can be used to filter the requests by specific request properties. Those keywords are followed by a colon and a related filter value. The filter values are matched case insensitive. Prepending a minus (``-``) negates the filter. You can combine different filters together by separating them with a space. + + +.. list-table:: + :widths: 20 40 40 + :header-rows: 1 + + * - Keyword + - Meaning + - Examples + + * - ``status-code`` + - Shows resources that have the specific HTTP status code. + - ``status-code:304`` + + * - ``method`` + - Shows resources that have were requested via the specific HTTP request method. + - ``method:post`` + + * - ``domain`` + - Shows resources coming from a specific domain. + - ``domain:mozilla.org`` + + * - ``remote-ip`` + - Shows resources coming from a server with the specified IP. + - ``remote-ip:63.245.215.53`` |br| |br| ``remote-ip:[2400:cb00:2048:1::6810:2802]`` + + * - ``cause`` + - Shows resources matching a specific cause type. The types can be found in the description of the cause column. + - ``cause:js`` |br| |br| ``cause:stylesheet`` |br| |br| ``cause:img`` + + * - ``transferred`` + - Shows resources having a specific transferred size or a transferred size close to the one specified. ``k`` can be used as suffix for kilobytes and ``m`` for megabytes, e.g. the value ``1k`` is equivalent to ``1024``. + - ``transferred:1k`` + + * - ``size`` + - Shows resources having a specific size (after decompression) or a size close to the one specified. ``k`` can be used as suffix for kilobytes and ``m`` for megabytes, e.g. the value ``1k`` is equivalent to ``1024``. + - ``size:2m`` + + * - ``larger-than`` + - Shows resources that are larger than the specified size in bytes. ``k`` can be used as suffix for kilobytes and ``m`` for megabytes, e.g. the value ``1k`` is equivalent to ``1024``. + - ``larger-than:2000`` |br| |br| ``-larger-than:4k`` + + * - ``mime-type`` + - Shows resources that match the specified MIME type. + - ``mime-type:text/html`` |br| |br| ``mime-type:image/png`` |br| |br| ``mime-type:application/javascript`` + + * - ``is`` + - ``is:cached`` and ``is:from-cache`` shows only resources coming from cache. ``is:running`` shows only resources, which are currently being transferred. + - ``is:cached`` |br| |br| ``-is:running`` + + * - ``scheme`` + - Shows resources transferred via the given scheme. + - ``scheme:http`` + + * - ``has-response-header`` + - Shows resources that contain the specified HTTP response header. + - ``has-response-header:cache-control`` |br| |br| ``has-response-header:X-Firefox-Spdy`` + + * - ``set-cookie-domain`` + - Shows the resources that have a ``Set-Cookie`` header with a ``Domain`` attribute that matches the specified value. + - ``set-cookie-domain:.mozilla.org`` + + * - ``set-cookie-name`` + - Shows the resources that have a ``Set-Cookie`` header with a name that matches the specified value. + - ``set-cookie-name:_ga`` + + * - ``set-cookie-value`` + - Shows the resources that have a ``Set-Cookie`` header with a value that matches the specified value. + - ``set-cookie-value:true`` + + * - ``regexp`` + - Shows the resources having a URL that matches the given `regular expression `_. + - ``regexp:\d{5}`` |br| |br| ``regexp:mdn|mozilla`` + + +For example, to find all 404, not found, errors, you can type "404" into the search and auto-complete suggests "status-code:404" so you'll end up with something like this: + +.. image:: 404_filter.png + :class: border + + +Search in requests +------------------ + +Use the *Search* panel to run a full-text search on headers and content. + + +1. Click the **Search** icon in the toolbar. This opens the Search sidebar. + +.. image:: search_panel.png + :alt: Screenshot of the Network monitor, with the request search sidebar displayed, and arrows indicating the search toolbar icon and the search box. + :class: border + +2. Enter a string in the search field of the sidebar, and press :kbd:`Enter` or :kbd:`Return`. The search results area below the search field displays the requests that contain that string in the request or response headers or in the content of the response. You can expand each item to show the specific item that matches the string. Clicking an item in the search results highlights that item in the monitor list, and displays the corresponding information in the request details pane. + +.. image:: search_panel_matches.png + :alt: Screenshot of the search panel, with "newsletter" as the search string, and callouts for the expanded results, and corresponding items displayed in the request list and headers tab. + :class: border + + +Other ways to use the search panel: + + +- To clear the search string: click the **X** icon in the search field. +- To make the search case sensitive: click the **Case Sensitive** (**Aa**) icon next to the search field. +- To close the search panel, do one of the following: + + - Click the **X** icon next to the search field. + - Click the **Search** icon in the Network Monitor toolbar. + + +.. _network-monitor-request-list-edit-and-resend: + +Context menu +------------ + +Context-clicking on a row in the list displays a context menu with the following options: + +.. list-table:: + :widths: 25 75 + :header-rows: 1 + + * - Menuitem + - Description + + * - Copy > Copy URL + - Copies the URL. + + * - Copy > Copy as cURL + - Copies the network request to the clipboard as a `cURL `_ command, so you can execute it from a command line. See :ref:`Copy as cURL `, below. + + * - Copy > Copy as Fetch + - Copies the request as a call to the fetch() method, including the URL and any settings object. + + * - Copy > Copy Request Headers + - Copies the request's header to the clipboard. + + * - Copy > Copy Response Headers + - Copies the headers of the response for this request, to the clipboard. + + * - Copy > Copy Response + - Copies the entire response that was sent for this request. + + * - Copy > Copy All As HAR + - Creates an `HTTP Archive `_ (HAR) for all requests listed, and copies it to the clipboard. + + * - Save All As HAR + - Creates an `HTTP Archive `_ (HAR) for all requests listed, and opens a file dialog, so you can save it to a file. + + * - Resend + - Resends the request as it was originally sent with no changes made. + + * - Edit and Resend + - Opens an editor enabling you to edit the request's method, URL, parameters, and headers, and resend the request. + + * - Block URL + - Blocks the selected URL for future requests. See :ref:`Blocking a specific URL from the Request List `. + + * - Open in New Tab + - Resends the request in a new tab — very useful for debugging asynchronous requests. + + * - Open in Style Editor + - For a CSS resource, opens it in the :doc:`Style Editor <../../style_editor/index>`. + + * - Start :doc:`Performance Analysis <../performance_analysis/index>` + - + + * - Use as Fetch in Console + - Submits the request as a call to the `fetch() ` method in the console. + + +.. _request-list-copy-as-curl: + +Copy as cURL +~~~~~~~~~~~~ + +The command may include the following options: + +.. list-table:: + :widths: 25 75 + :header-rows: 0 + + * - ``-X [METHOD]`` + - If the method is not GET or POST + + * - ``--data`` + - For URL encoded request parameters + + * - ``--data-binary`` + - For multipart request parameters + + * - ``--http/VERSION`` + - If the HTTP version is not 1.1 + + * - ``-I`` + - If the method is HEAD + + * - ``-H`` + - One for each request header. |br| |br| If the "Accept-Encoding" header is present, the cURL command includes ``--compressed`` instead of ``-H "Accept-Encoding: gzip, deflate"``. This means that the response will be automatically decompressed. + + + * - ``--globoff`` + - Suppresses cURL's globbing (wildcard matching) feature if the copied URL includes square bracket characters (``[`` or ``]``). (Starting in Firefox 76) + + + +Managing HAR data +~~~~~~~~~~~~~~~~~ + +The HAR format enables you to export detailed information about network requests. In addition to the **Copy** and **Save** menu items for HAR in the context menu, similar menu items are available in the **HAR** dropdown menu in the toolbar, as well as an **Import** menuitem. + +.. image:: har-dropdown.png + :class: border + + +Network Monitor features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar <../toolbar/index>` +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../performance_analysis/index>` +- :doc:`Throttling <../throttling/index>` +- :doc:`Inspecting web sockets <../inspecting_web_sockets/index>` +- :doc:`Inspecting server-sent events <../inspecting_server-sent_events/index>` diff --git a/devtools/docs/user/network_monitor/throttling/index.rst b/devtools/docs/user/network_monitor/throttling/index.rst new file mode 100644 index 000000000000..137894520348 --- /dev/null +++ b/devtools/docs/user/network_monitor/throttling/index.rst @@ -0,0 +1,45 @@ +========== +Throttling +========== + +The network monitor allows you to throttle your network speed to emulate various connection speeds so you can see how your app will behave under different connection types. + +Throttling +********** + +The toolbar includes a Throttling dropdown, which allows you to throttle your network speed to emulate various different network speed conditions. Choose an option from the menu, and it will persist across reloads. + +.. image:: throttling.png + :class: border + +The characteristics emulated are: + +- Download speed +- Upload speed +- Minimum latency + +The table below lists the numbers associated with each network type, but please do not rely on this feature for exact performance measurements; it's intended to give an approximate idea of the user experience in different conditions. The speeds are expressed in multiples of bits per second. + +.. csv-table:: + :header: "Selection", "Download speed", "Upload speed", "Minimum latency" + :widths: auto + + GPRS, 50 Kbps, 20 Kbps, 500 + Regular 2G, 250 Kbps, 50 Kbps, 300 + Good 2G, 50 Kbps, 150 Kbps, 150 + Regular 3G, 750 Kbps, 250 Kbps, 100 + Good 3G, 1.5 Mbps, 750 Kbps, 40 + Regular 4G/LTE, 4 Mbps, 3 Mbps, 20 + DSL, 2 Mbps, 1 Mbps, 5 + Wi-Fi, 30 Mbps, 15 Mbps, 2 + +Network Monitor Features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Toolbar <../toolbar/index>` +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../recording/index/>` +- :doc:`Performance analysis <../performance_analysis/index>` diff --git a/devtools/docs/user/network_monitor/toolbar/index.rst b/devtools/docs/user/network_monitor/toolbar/index.rst new file mode 100644 index 000000000000..9407c4fba0ec --- /dev/null +++ b/devtools/docs/user/network_monitor/toolbar/index.rst @@ -0,0 +1,59 @@ +======================= +Network monitor toolbar +======================= + +The network monitor provides two toolbar areas, one above the main section, and another below. + +Toolbar +******* + +The toolbar is at the top of the main network monitor window. (Prior to Firefox 77, this toolbar was arranged somewhat differently.) + +.. image:: network_toolbar_callouts.png + :alt: Screenshot of the Network toolbar, without callouts for the parts + :class: border + +It provides: + +- An icon to clear the :doc:`network request list <../request_list/index>` +- A box enabling you to :ref:`filter requests ` by URL and by properties. +- A set of tool icons: + + - Pause (or **resume**) recording network log + - **Search** the log + - **Request Blocking** + +- An array of buttons to filter the network request list by type: + + - by the content type of the response + - XHR requests + - WebSocket upgrades and messages (labeled **WS**) + - Other requests + +- A checkbox that allows you to disable caching. +- **Throttling** menu, to simulate various connection types +- A menu of other actions: + + - **Persist Logs**: By default, the Network Monitor is cleared each time you navigate to a new page or reload the current page. When you select **Persist Logs**, the log is not cleared on page load. + - **Import HAR** imports a HAR (HTTP Archive) file. + - **Save All as HAR** opens a file dialog box so you can save the current contents of the Network log as a HAR file with the extension ```.har```. + - **Copy All as HAR** copies the current contents of the Network log to the clipboard in HAR format. + +A second toolbar area at the bottom of the network monitor provides: + +.. image:: network_monitor_bottom_toolbar.png + +- An icon to launch :doc:`performance analysis <../performance_analysis/index>`. +- A summary of this page, including the number of requests, total size, and total time. + + +Network Monitor features +************************ + +The following articles cover different aspects of using the network monitor: + +- :doc:`Network request list <../request_list/index>` +- :doc:`Network request details <../request_details/index>` +- :doc:`Network traffic recording <../recording/index/>` +- :doc:`Performance analysis <../performance_analysis/index>` +- :doc:`Throttling <../throttling/index>` diff --git a/devtools/docs/user/page_inspector/3-pane_mode/index.rst b/devtools/docs/user/page_inspector/3-pane_mode/index.rst new file mode 100644 index 000000000000..0245a0b4abb2 --- /dev/null +++ b/devtools/docs/user/page_inspector/3-pane_mode/index.rst @@ -0,0 +1,79 @@ +========================== +Page inspector 3-pane mode +========================== + +This article explains how to use the Page Inspector's 3-pane mode. + +Feature summary +*************** + +From Firefox 62 onwards, the :doc:`Page Inspector <../index>` has a new mode available — **3-Pane mode**. When activated, this allows you to see the following simultaneously: + + +- The :doc:`HTML pane <../how_to/examine_and_edit_html/index>` on the left hand side, as usual. + +- The :ref:`CSS Rules ` in the middle in their own separate pane, rather than as a tab. + +- The other CSS related features — such as :ref:`Computed styles view `, :doc:`Animations view <../how_to/work_with_animations/index>`, and :doc:`Fonts view <../how_to/edit_fonts/index>` — in tabs on the right hand side, as usual. + +.. image:: 3-pane-view-final.png + :alt: The firefox page inspector in 3 pane mode, with HTML pane on left, CSS rules pane in center, and CSS tool tabs on right + :class: border + +.. note:: + + At narrower browser window widths, the tabs appear below the CSS Rules pane. + + +Having the CSS Rules in their own pane is very useful because it allows you to not only inspect your HTML and edit the CSS applied to it, but also see the effect this has on CSS features such as computed styles and grids in real time. You just need to have the relevant tab open to see the effect. + +A brief walkthrough +******************* + +The 3-pane inspector is disabled by default. It is enabled via a toggle control found in the tabs pane on the left hand side. + +.. image:: toggle-icon-final.png + :alt: a view of the tabs panel, showing the 2 to 3 pane toggle icon + :class: center + +Press the toggle control to toggle between the 2- and 3-pane views. + +.. image:: 2-pane-view-final.png + :alt: The firefox page inspector in 2 pane mode, with HTML pane on left and CSS tool tabs on right + :class: border + + +.. image:: 3-pane-view-final.png + :alt: The firefox page inspector in 3 pane mode, with HTML pane on left, CSS rules pane in center, and CSS tool tabs on right + :class: border + + +With the 3-pane mode enabled, you can observe live changes in CSS features as you edit the rules applied to the page. For example, you could edit a `CSS Grid `_ property and observe the change immediately in the :doc:`Grid Inspector <../how_to/examine_grid_layouts/index>`. + +.. raw:: html + + +
+
+ +Enabling the 3-pane inspector pre-Firefox 62 +******************************************** + +In earlier versions of Firefox (since Firefox 59/60), you can enable 3 pane mode in Release/Beta by going to about:config and flipping the following prefs to ``true``: + +``devtools.inspector.split-rule-enabled`` — this switches 3-pane mode on and off. + +``devtools.inspector.split-sidebar-toggle`` — this adds the UI toggle button that lets you toggle it on and off. + +In Firefox 61, these preferences got renamed to: + + +- ``devtools.inspector.three-pane-enabled`` +- ``devtools.inspector.three-pane-toggle`` + +You need to flip these two to ``true`` in Release/Beta to test the feature in Firefox 61. + +.. note:: + + The 3-pane inspector is already enabled in Nightly/Developer edition before Firefox 62. + diff --git a/devtools/docs/user/page_inspector/how_to/debug_scrollable_overflow/index.rst b/devtools/docs/user/page_inspector/how_to/debug_scrollable_overflow/index.rst new file mode 100644 index 000000000000..949aa72b6cad --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/debug_scrollable_overflow/index.rst @@ -0,0 +1,25 @@ +========================= +Debug scrollable overflow +========================= + +A `scroll container `_ is created by applying `overflow: scroll `_ to a container, or `overflow: auto `_ when there is enough content to cause overflow. The Firefox DevTools make it easy to discover both scrollable elements and any elements that are causing overflow. + + +In the :ref:`HTML Pane `, ascrollable element has the ``scroll`` badge next to it, as shown in the following image: + +.. image:: scroll_hover.png + :alt: HTML Pane Scroll badge + :class: center + +You can toggle the ``scroll`` badge to highlight elements causing an overflow, expanding nodes as needed to make the nodes visible: + +.. image:: scroll_badge_pressed.png + :alt: Scroll badge toggled on 1 + :class: center + +You will also see an ``overflow`` badge next to the node causing the overflow. + +.. image:: overflow_badge.png + :alt: HTML Pane: Overflow badge + :class: center + diff --git a/devtools/docs/user/page_inspector/how_to/edit_css_filters/index.rst b/devtools/docs/user/page_inspector/how_to/edit_css_filters/index.rst new file mode 100644 index 000000000000..1cf3e9e4bdd6 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/edit_css_filters/index.rst @@ -0,0 +1,36 @@ +================ +Edit CSS filters +================ + +`CSS filter `_ properties in the :ref:`Rules view ` have a circular gray and white swatch next to them: + +.. image:: click_to_edit_filter.png + :class: border + +Clicking the swatch opens a filter editor: + +.. image:: css_filter_edit.png + :class: center + +The filter editor lists each of the effects performed by that filter on a separate line. You can edit these lines, remove them individually, or drag the effects to change the order in which they are applied. + +You can also add new effects by selecting an effect from the dropdown list at the bottom of the dialog. Once you have selected the effect you want to add, click the plus sign (+) to the right of the dropdown list. + +.. image:: edit_filter_settings.png + :class: center + +Once you have added an effect, enter the settings you want and then press :kbd:`Enter` to update the effect. The change will be apparent as soon as you press :kbd:`Enter`. + +Saving filter presets +********************* + +From Firefox 42 onwards, you can also add filters to a list of presets. The list of presets will be preserved between browser sessions, making it easy to apply the settings in the future. You can save the current filter to the preset list: + + +1. Click to edit the filter, display the preset list by clicking the icon as shown below. +2. Type a name for your preset, and then click the plus sign to add it to the list of presets. + +.. image:: filter_presets.png + :class: center + +You can then apply saved filters to new elements. To apply one of your saved presets, click its name in the list. diff --git a/devtools/docs/user/page_inspector/how_to/edit_css_shapes/index.rst b/devtools/docs/user/page_inspector/how_to/edit_css_shapes/index.rst new file mode 100644 index 000000000000..d8eadf0c2c69 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/edit_css_shapes/index.rst @@ -0,0 +1,104 @@ +======================= +Edit Shape Paths in CSS +======================= + +The Shape Path Editor is a tool that helps you see and edit shapes created using `clip-path `_ and also the CSS `shape-outside `_ property and ` `_ values. This guide walks you through all of the available options. + + +Activate / deactivate the Shape Path Editor +******************************************* + +The Shape Path Editor is accessed via the CSS Rules Panel, which can be opened as described in the guide to :doc:`Opening the Inspector <../open_the_inspector/index>`. Once you have selected your element, you should see the shape icon alongside any valid value, e.g. one for ``shape-outside``. + +.. image:: enable-shapes-editor.png + :class: border + + +Clicking the icon will cause the Editor to highlight the shape. + +.. image:: circle.png + :class: center + + +To deactivate the Shape Path Editor click on the icon again, or select another element or a different editor. Note that the Shape Path Editor does not persist between page reloads — if you reload your page you will need to select the element again. + + +Understanding the lines drawn by the editor +******************************************* + +Once you have selected a shape on your page, the Shape Path Editor will draw lines to help you understand the path that is being created. + + +- **A solid line** shows the outline of the shape that is wrapping the text. This is your shape. If the shape is clipped by the margin box then the margin box will make up part of this line. +- **A dashed line** demonstrates the outline of the shape which extends past the margin box reference; this is the area that will be clipped by the margin box. To understand the margin box, and other boxes used by CSS Shapes see our guide to `Shapes from box values `_. + +.. image:: clipped-margin-box.png + :class: center + + +Editing Basic Shapes +******************** + +The options given to you by the tool will differ depending on the type of basic shape that you are editing. Options can be accessed by activating the Shape Path Editor with a regular click on the icon, and you can use the context menu (:kbd:`Ctrl`/:kbd:`Cmd` + click) to access additional functionality. + +circle() +-------- + +If the value of ``shape-outside`` is ``circle()``, you are creating a `circle basic shape `_. Clicking on the shapes icon next to the value of ``circle()`` will highlight the shape, and also give you the option to resize the circle or move its center. If you move or resize the circle past the margin box, the edges become clipped by it. + +.. image:: clipped-margin-box.png + :class: center + + +In the Rules Panel you can see the values for ``circle()`` change as you edit the shape. You can then copy these values back into your stylesheet to create the new, tweaked shape path. + + +ellipse() +--------- + +If the value of ``shape-outside`` is ``ellipse()`` then you are using the `ellipse basic shape `_. The ``ellipse()`` value works in much the same way as ``circle()`` in the Shape Path Editor. An ellipse is a squashed circle and therefore has the option to resize horizontally and vertically when you click on the shapes icon. + +.. image:: ellipse.png + :class: center + + +inset() +------- + +If the value of ``shape-outside`` is ``inset()`` then you are using the `inset basic shape `_, which enables the creation of offset values pulling the content in from the margin box. + +Each side of the rectangle can be targeted after clicking on the shapes icon to activate the Shape Path Editor, and dragging each side will update the values for the top, right, bottom, and left offset values. + +.. image:: inset.png + :class: center + + +polygon() +--------- + +If the value of ``shape-outside`` is ``polygon()`` then you are using the `polygon basic shape `_. This is the most complex of the basic shape values, therefore the tool gives you more options when editing these: + + +- Clicking on the shapes icon will activate the Shapes Path Editor and give you the option to move any of the points of your polygon shape. +- Double-click anywhere on a line of the shape and you will get a new point to adjust. +- Double click on an existing point and it will be removed. *Remember that a polygon needs at least three points*. + +.. image:: polygon-edit.png + :class: center + + +Moving and scaling shapes +------------------------- + +There is extra functionality available on the shape highlight — if you :kbd:`Ctrl`/:kbd:`Cmd` + click on the shapes icon for your shape the highlight will change, instead providing the ability to scale and/or move it. Once again, clipping will occur if you exceed the bounds of the margin box. + +.. image:: scaled-circle.png + :class: center + + +If your shape is a polygon, you also get the ability to rotate it around an axis. + +Browser support +*************** + +The Shape Path Editor currently works for shapes generated via `clip-path `_; it will also work for shapes generated via `shape-outside `_ as of Firefox 62. diff --git a/devtools/docs/user/page_inspector/how_to/edit_fonts/index.rst b/devtools/docs/user/page_inspector/how_to/edit_fonts/index.rst new file mode 100644 index 000000000000..2f20d4d3ab3a --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/edit_fonts/index.rst @@ -0,0 +1,258 @@ +========== +Edit fonts +========== + + +This article provides a tour of the Font tools available in the Firefox DevTools. This tool contains several useful features for viewing and manipulating fonts applied to any document loaded in the browser including inspection of all fonts applied to the page, and precise adjustment of variable font axis values. + +.. note:: + + The updated Font tools as shown in this article are available in Firefox 63 onwards; if you are using an older version of Firefox the tools will not look or behave quite the same, but they will be similar (most notably the Font Editor will not be available). + + +The Fonts tab +************* + +The Fonts tab is located on the right-hand side of the :doc:`Page Inspector <../../index>` when it is docked to the bottom of the screen. When it is docked to the right or left sides of the screen, the Fonts tab appears beneath the HTML pane. To access it: + + +1. :doc:`Open the Page Inspector <../open_the_inspector/index>`. +2. Select the Fonts tab; the last of the tabs shown in the right-hand side of the CSS pane. + +.. image:: full-fonts-tab-new63.png + :class: border + + +The Fonts tab has three major sections: + +- "Fonts used" by the currently inspected element. +- The new Fonts Editor. In Firefox 61 and 62, this section does not exist. +- "All fonts on page" — This section lists all of the fonts in use on the page. In Firefox 61 and 62, this area is labeled "Other fonts in page" and doesn't include the fonts mentioned in the "Fonts used" section. + + +Fonts used +********** + +The top section of the Font Editor shows the fonts used by the currently inspected element, grouped by font family. + +.. image:: fonts-used.png + :class: border + +Fonts are considered "used" when there is text content in the inspected element that has the font applied to it. Empty elements will not have any fonts used and will display the message "No fonts were found for the current element." + +Fonts will be included in this section for one of the following reasons: + + +- They are listed in the element's ``font-family`` CSS declaration value. +- They are applied to the element as part of the browser's default styling (Times New Roman for most browsers), and no author-defined font has been supplied. +- They are used by a descendant of the inspected element, for example, when it is a container for other elements which have text content with fonts applied. +- They are system fallback fonts used when nothing from the ``font-family`` CSS declaration has been applied. + + +Fonts Editor +************ + +Firefox 63 adds the Font Editor — a new area below "Fonts used" with additional controls for editing the fonts’ characteristics. + +.. image:: fonts-editor-closeup-63-cropped.png + :class: border + + +For standard (static) fonts, you will be able to change the settings listed below + + +Size +---- + +The `font-size `_ for the inspected element. + +.. image:: font-size_cropped.png + :class: border + + +This can be set using ``em``, ``rem``, ``%``, ``px``, ``vh``, or ``vw`` units. You can select values using the slider or enter a numeric value directly into the text box. + +.. note:: + If you want to use a different unit such as ``pt`` for ``font-size`` or ``line-height``, you can set the property value applied to the currently inspected element to use that unit via the :ref:`rules view `, and the font editor will automatically pick it up and make it available in the associated units dropdown menu. + + +Changing the unit of measure converts the numerical value to its equivalent in the new unit, so the same computed value is maintained. + +Example: If ``1rem`` is equivalent to 10 pixels, when you change the unit of measurement from ``rem`` to ``px``, ``2rem`` becomes ``20px``. + + +Line height +----------- + +The `line-height `_ of the inspected element. + +.. image:: line-height_cropped.png + :class: border + + +This can be set using unitless, ``em``, *%*, or ``px`` units. You can select values using the slider or enter a numeric value directly into the text box. + +Changing the unit of measure changes the value relative to the ``font-size`` setting. + +Example: If the font is 20 pixels high and the line-height is ``1.5em``, when you change the unit of measure from ``em`` to ``px``, the value will become ``30px``. + + +Weight +------ + +The `font-weight `_ for the inspected element. + +.. image:: font-weight_cropped.png + :alt: Font weight setting + :class: border + + +You can select values using the slider or enter a numeric value directly into the text box. For non-variable fonts the slider ranges from 100 to 900 in increments of 100. + +.. note:: + For `variable fonts `_ (see below) that define a ``wght`` variation axis, this range is custom. + + +Italic +------ + +The `font-style `_ for the inspected element. + +.. image:: font-italic_cropped.png + :class: border + + +This setting toggles between ``italic`` and ``normal`` values for the ``font-style`` CSS property. + +.. note:: + + As you change settings, Firefox applies inline styles to the element to make the changes instantly visible on the page. + + +All fonts on page +***************** + +The remaining area, at the bottom of the Fonts tab, shows an expandable list of all of the fonts in use on the page. + +.. image:: all-fonts-on-page_new63.png + :class: border + + +The list is useful because you can easily determine whether a font is a web font or a font hosted on your system. + +Each font listed in this section shows you: + + +- The ``font-family`` identifier and full name of the font. +- The URL to the font file in the case of web fonts not available on your system, or "System" in the case of fonts loaded from your computer (either default system fonts, or web fonts that you've also got installed on your system). You can copy the URL to the font file by clicking on the icon to the right of the URL. +- The `@font-face `_ descriptor that loads the font into the page, in the case of web fonts. The descriptor is expandable — when opened it shows its full syntax as defined in the stylesheet. +- A text sample, to give you an idea of what the font looks like when rendered. The default text for the sample is "Abc" but the preview text can be edited by clicking on the input field at the top of the section and entering a new value. Once entered, all of the sample text will be set to the same custom value. + + +Variable font support in Firefox Developer Tools +************************************************ + +Firefox 62 added support for variable fonts and Firefox 63 features support for editing the properties of variable fonts in the Font Editor. + +What are variable fonts? +------------------------ + +`Variable Fonts `_, or **OpenType Font Variations**, define a new font file format that allows the font designer to include multiple variations of a typeface inside a single font file. That means you no longer have to apply several different web fonts to a single page to represent a complete typeface for which a variable font is available, provided it includes the desired values for the different characteristics you want to vary. + +Variable fonts make it easy to vary font characteristics in a much more granular fashion because their allowable ranges are defined by **axes of variation** (see `Introducing the 'variation axis' `_ for more information). For example, `font-weight `_ can be set to any value between 1 and 1000 in variable fonts (although it is not guaranteed that a variable font will support this entire range). + +There are several registered axes. Although it isn't required that these axes be defined for every font, if the font designer *does* implement a registered axis, its behavior *must* follow the defined behavior. + +All variable font axes have a four-character axis tag. The CSS `font-variation-settings `_ property uses the tag as part of the key-value pair. For example, to set `font-weight `_ using ``font-variation-settings``, you could do something like this: + + +.. code-block:: css + + font-variation-settings: "wght" 350; + + +However, you should only use ``font-variation-settings`` as a last resort if there is no basic font property available for setting those characteristic values (e.g. custom axes). + +.. note:: + Font characteristics set using ``font-variation-settings`` will always override those set using the corresponding basic font properties, e.g. ``font-weight``, no matter where they appear in the cascade. + + +Here are the registered axes along with their corresponding CSS properties: + + +.. list-table:: + :widths: 40 60 + :header-rows: 1 + + * - Axis Tab + - CSS Property + + * - "wght" + - `font-weight `_ + + * - "wdth" + - `font-stretch `_ + + * - "slnt" (slant) + - `font-style `_: ``oblique + angle`` + + * - "ital" + - `font-style `_: ``italic`` + + * - "opsz" + - `font-optical-sizing `_ + + +Any axis that is not on the list of registered axes is considered a custom axis. Custom axes do not have corresponding CSS font properties. Font designers can define whatever axis they want; each one needs to be given a unique four-character tag. The axis name and its range is up to the font designer. + +.. note:: + Registered axis tags are identified using lower-case tags, whereas custom axes should be given upper-case tags. Note that font designers aren't forced follow this practice in any way, and some won't. The important takeaway here is that axis tags are case-sensitive. + + +.. warning:: + In order to use variable fonts, you need to make sure that your operating system is up to date. For example Linux OSes need the latest Linux Freetype version, and macOS prior to 10.13 does not support variable fonts. If your operating system is not up to date, you will not be able to use variable fonts in web pages or the Firefox Developer Tools. + + +Working with Variable fonts in the Font Editor +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If the inspected element uses a variable font, the Fonts tab shows the axes that have been implemented for that particular font, providing control to alter the value of each one. This is very useful for quickly finding out what axes are available in a particular font — they can vary quite dramatically as font designers can implement basically anything they like. + +.. image:: v_fonts_example_cropped.png + :class: border + + +You can adjust the axes individually or, if the font designer has included defined instances, you can select one from the "Instance" drop-down list and view the updates live on your page. + +Here are a couple of examples of fonts with different axes defined: + +.. image:: v_fonts-examples_cropped.png + :class: border + + +In the following example, you can see that the font "Cheee Variable" includes settings for Yeast and Gravity. These are custom axes defined by the font designer. + +.. image:: change_font_before_cropped.png + :class: border + + +The first image shows the font as it is used on the page with default settings. The second image shows the same font after selecting the "Hi Yeast Hi Gravity" variation. + +.. image:: change_font_after_cropped.png + :class: border + + +Tips +**** + +Finally, here are a few tips for making effective use of the Fonts tab: + + +- When using the Page Inspector's :doc:`3-pane mode <../../3-pane_mode/index>`, you can view the CSS rules for the inspected element simultaneously alongside the Fonts tab. +- If you hover over the `font-family `_ property in the Rules view, a tooltip shows a sample of the font: + + .. image:: fonts_62_tooltip_cropped.png + :class: border + +- You'll also notice in the above screenshot that the font in the ``font-family`` font stack that is actually applied to the inspected element is underlined. This makes it easy to see exactly what is being applied where, when font stacks are specified. + diff --git a/devtools/docs/user/page_inspector/how_to/examine_and_edit_css/index.rst b/devtools/docs/user/page_inspector/how_to/examine_and_edit_css/index.rst new file mode 100644 index 000000000000..f9b371d5305b --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/examine_and_edit_css/index.rst @@ -0,0 +1,475 @@ +==================== +Examine and edit CSS +==================== + +You can examine and edit CSS in the Inspector's :ref:`CSS pane `. + + +.. _page-inspector-how-to-examine-and-edit-css-examine-css-rules: + +Examine CSS rules +***************** + +The :ref:`Rules view ` lists all the rules that apply to the selected element, ordered from most-specific to least-specific: + +.. image:: rules_view_ff_87.png + :alt: Rules view panel as of Firefox 87 + :class: border + + +The six buttons on the right top of the rules view allow you to change the display of certain CSS and rules view features. You can: + + +- :ref:`toggle pseudo-classes `; +- :ref:`toggle classes ` +- add a new rule; +- change the display based on :ref:`prefers-color-scheme media rules `. +- change the display based on :ref:`print media rules `. + +.. image:: rules_view_buttons_fx_72.png + :alt: Toolbar buttons of the Rules view, as of Fx 72 + :class: center + + +Invalid value warnings +---------------------- + +A warning icon appears next to unsupported CSS properties or rules that have invalid values. This can help you understand why certain styles are not being applied. In the following example, a spelling error, "background-colour" instead of "background-color" has made the rule invalid: + +.. image:: invalid_property.png + :class: border + + +Browser compat warnings +----------------------- + +CSS properties have varied level of support across different browsers. From Firefox 81, compatibility tooltips may be displayed next to any CSS properties that have known compatibility issues,as shown below. + +.. note:: + This feature is enabled from Firefox 81 by setting the preference ``devtools.inspector.ruleview.inline-compatibility-warning.enabled`` to ``true`` (open ``about:config`` in the URL bar to view/set Firefox preferences). + + +.. image:: firefox_compatibility_tootips.jpg + :alt: Tooltip displayed next to CSS element. Hover to find out browsers with compatibility issues. + :class: center + + +The tooltips, which arepopulated from the MDN `browser compatibility project `_, identify the *reason* for the incompatibility (not supported, deprecated, experimental etc.), display icons for incompatible browsers, and provide a link to the associated property page for more information. + + +CSS Compatibility +----------------- + +In addition to compatibility tooltips, the *CSS Compatibility View* shows any CSS compatibility issues for both the selected element and for the current page (as a whole). + +.. image:: compat_view.png + :alt: Screenshot of the Compatibility view + :class: center + + +For more information see: :ref:`Page Inspector > CSS Compatibility View `. + + +Rule display +------------ + +It displays each rule as in a stylesheet, with a list of selectors followed by a list of ``property:value;`` declarations. + +.. image:: rules_pane.png + :class: center + + +- *Highlight matched elements*: next to the selector is a target icon: click this to highlight all nodes in the page that match this selector. +- *Overridden declaration*: declarations that are overridden by later rules are crossed out. See :ref:`overridden declarations `. +- *Inactive rules* (not shown): if a rule is inactive (e.g., ``padding`` on a ``:visited`` pseudo-element), it is colored gray, with an info icon that gives more information when clicked. +- *Filter rules containing this property*: next to overridden declarations is an icon you can click to filter the rules list to show only those rules that include that property. See :ref:`overridden declarations `. +- *Enable/disable*: if you hover over a declaration, a checkbox appears next to it: you can use this to toggle the declaration on or off. +- *Filename and line number*: on the right-hand side is a link to the rule. See :ref:`link to CSS file `. + + +.. |image1| image:: screen_shot_2016-12-16_at_10.51.15_am.png + :width: 20 + +If the element has a `display: grid `_ declaration, then it gets a grid icon next to it, like this: |image1|. Click that icon to display the grid overlaid on the page, including grid lines and tracks. See :doc:`Examine grid layouts <../examine_grid_layouts/index>` for more on this. + +To view `user-agent styles `_ (*i.e.,* browser-default CSS rules), enable "Inspector > Show Browser Styles" under the :doc:`developer tool settings <../../../settings/index>` panel. (Note that this setting is independent of the "Browser styles" checkbox in the :ref:`Computed view `.) + +User-agent styles are displayed against a different background, and the link to the filename and line number contains the prefix ``(user agent)``: + +.. image:: user-agent_css.png + :class: border + + +.. _page_inspector_how_to_examine_and_edit_css_element_rule: + +element {} rule +--------------- + +The ``element {}`` rule at the top of the rules list isn't actually a CSS rule. It represents the CSS properties assigned to the element via its `style `_ attribute. + +.. |image2| image:: target-icon.png + :width: 20 + +This also gets the target icon: |image2|, giving you a convenient way to highlight the currently selected element in the page. + + +Filtering rules +--------------- + +There's a box at the top of the Rules view labeled "Filter Styles": + +.. image:: filter_rules.png + :class: border + +As you type: + +- any rules which don't contain the typed string at all are hidden +- any declarations which contain the typed string are highlighted + +.. image:: filtered_rules.png + :class: border + +Click the "X" at the end of the search box to remove the filter. + +.. note:: + While in the Rules view, you can press :kbd:`Ctrl` / :kbd:`Cmd` + :kbd:`F` to focus the search field. Once you've typed in a filter, you can press :kbd:`Esc` to remove it again. + + +.. raw:: html + + +
+
+ +Strict search +~~~~~~~~~~~~~ + +By default, the search box highlights all declarations which contain any part of the string. For example, searching for "color" will highlight declarations containing `border-bottom-color `_ and `background-color `_ as well as just `color `_: + +.. image:: filter_rules_2.png + :class: border + +If you enclose the search query in backticks, like this: `color`, the search is restricted to exact matches: + +.. image:: filter_rules_2_strict.png + :class: border + + +Expanding shorthand properties +------------------------------ + +`Shorthand properties `_ can be expanded to display their related longhand properties by clicking the arrow besides them. + + +Displaying pseudo-elements +-------------------------- + +The Rule view displays the following `pseudo-elements `_, if they are applied to the selected element: + +- ``::after`` +- ``::backdrop`` +- ``::before`` +- ``::first-letter`` +- ``::first-line`` +- ``::selection`` +- ``:-moz-color-swatch`` +- ``:-moz-number-spin-box`` +- ``:-moz-number-spin-down`` +- ``:-moz-number-spin-up`` +- ``:-moz-number-text`` +- ``:-moz-number-wrapper`` +- ``:-moz-placeholder`` +- ``:-moz-progress-bar`` +- ``:-moz-range-progress`` +- ``:-moz-range-thumb`` +- ``:-moz-range-track`` +- ``:-moz-selection`` + +If the selected element has pseudo-elements applied to it, they are displayed before the selected element but hidden by a disclosure triangle: + +.. image:: pseudo-elements.png + :class: border + + +Clicking the triangle displays them: + +.. image:: pseudo-elements_displayed.png + :class: border + + +.. _page-inspector-how-to-examine-and-edit-css-viewing-common-pseudo-classes: + +Viewing common pseudo-classes +----------------------------- + +There's a button to the right of the filter box: + +.. image:: show_pseudo_classes.png + :class: border + + +Click the button to see checkboxes that you can use to enable the `:hover `_, `:active `_ and `:focus `_, `:focus-within `_, `:focus-visible `_, `:visited `_, and `:target `_ pseudo-classes for the selected element: + + +.. image:: show_pseudo_classes_hover.png + :class: border + +This feature can also be accessed from the :ref:`popup menu in the HTML view ` + +If you enable one of these pseudo-classes for a node, an orange dot appears in the markup view next to all nodes to which the pseudo-class has been applied. In addition, the information that appears on the page itself show you what pseudo-class you are examining. For example: + +.. image:: hover_indicators.png + :class: border + + +.. _page-inspector-how-to-examine-and-edit-css-viewing-and-changing-classes-on-an-element: + +Viewing and changing classes on an element +------------------------------------------ + +With an element selected in the HTML pane, you can click the **.cls** button in the Rules pane toolbar, to display the classes defined on that element. + + +- You can clear the checkbox for a particular class name, to see how the element would appear without that class applied to it. +- You can add a class to the element by typing a name in the *Add new class* field below the Rules toolbar. From Firefox 81, autocompletions based on existing classes are suggested as you type. + + +.. _page-inspector-how-to-examine-and-edit-css-link-to-css-file: + +Link to CSS file +---------------- + +At the top right of each rule, the source filename and line number is displayed as a link: clicking it opens the file in the :doc:`Style Editor <../../../style_editor/index>`. + +You can copy the location of the source file: right-click the link and select "Copy Location". + +The Inspector understands CSS source maps. That means that if you are using a CSS preprocessor that has support for source maps, and you've enabled source map support in the :ref:`Style Editor settings `, then the link will take you to the original source, not the generated CSS. Read more about CSS source map support in the :ref:`Style Editor documentation `. + + +.. _page-inspector-how-to-examine-and-edit-css-overridden-declarations: + +Overridden declarations +----------------------- + +If a CSS declaration is overridden by some other CSS rule with a greater weight, then the declaration is shown with a line through it. + +Overridden declarations have a funnel next to them. Click the funnel to filter the rule view to show only the rules applying to the current node that try to set the same property: that is, the complete cascade for the given property. + +This makes it easy to see which rule is overriding the declaration + + +.. _page-inspector-view-media-rules-for-print: + +View @media rules for Print +--------------------------- + +You can toggle the display into a mode that emulates @media rules for print. + +.. raw:: html + + +
+
+ + +When on, any rules defined for printing the page will be displayed similar to the "Print Preview" mode that many word processing applications provide. + + +.. _page-inspector-view-media-rules-for-prefers-color-scheme: + +View @media rules for prefers-color-scheme +------------------------------------------ + +The color scheme simulator buttons can be used to test the rendering of styles based on the `prefers-color-scheme `_ media query (if any are defined for the page). There are two buttons, which enable the light and dark preference, respectively. Selecting either button deselects the other. If neither button is selected then the simulator does not set a preference, and the browser renders using the default feature value set by the operating system. + + +.. |image3| image:: color_scheme_null.png + :class: border + +.. |image4| image:: color_scheme_light.png + :class: border + +.. |image5| image:: color_scheme_dark.png + :class: border + + +.. list-table:: + :widths: 30 20 50 + :header-rows: 1 + + * - Icon + - Value + - Description + + * - |image3| + - null + - The ``prefers-color-scheme`` media feature is not set by the simulator. + + + * - |image4| + - ``light`` + - The ``prefers-color-scheme`` media feature is set to ``light``. + + * - |image5| + - ``dark`` + - The ``prefers-color-scheme`` media feature is set to ``dark``. + + +Note that if the operating system mode is set to a particular mode, then simulating that mode will not change page rendering (i.e. simulating dark mode when the operating system is using dark mode will not change the display). + +.. note:: + If ``privacy.resistFingerprinting`` has been set **true**, the `prefers-color-scheme `_ preference is forced to ``light``. You must set``privacy.resistFingerprinting`` to **false** in order to use this feature. + + +.. note:: + Before Firefox 87 this feature is behind the preference ``devtools.inspector.color-scheme-simulation.enabled``. + + +.. _page_inspector_how_to_examine_and_edit_css_examine_computed_css: + +Examine computed CSS +******************** + +To see the complete computed CSS for the selected element, select the :ref:`Computed panel ` in the righthand pane.This panel shows the calculated value that each CSS property has for the selected element. (This calculated value is exactly the same as what `getComputedStyle `_ would return.) + +.. image:: computed_css.png + :class: border + + +You can :kbd:`Tab` through the stylesto select them, and you can find more information about each property— pressing :kbd:`F1` on a selected property will open up its MDN reference page. + +Clicking the arrow next to the property name (or pressing :kbd:`Enter` or :kbd:`Space` while it is selected) shows the rule that set this value, along with a link to the source filename and line number: + +.. image:: computed_css_details.png + :class: border + + +By default, this view only shows values that have been explicitly set by the page: to see all values, click the "Browser styles" box. You can :kbd:`Tab` through the filenames/line numbers; pressing :kbd:`Enter`/:kbd:`Return` will open up the relevant file at that point in the :doc:`Style Editor <../../../style_editor/index>`. + +Typing in the search box performs a live filtering of the list, so, for example, if you just want to see font-related settings, you can type "font" in the search box, and only properties with "font" in the name will be listed. You can also search for the values of properties: to find the rule responsible for setting the font to "Lucida Grande", type that in the search box. + +.. note:: + While in the Computed view, you can press :kbd:`Ctrl` / :kbd:`Cmd` + :kbd:`F` to focus the search field. Once you've typed in a filter, you can press :kbd:`Esc` to remove it again. + + +Edit rules +********** + +If you click on a declaration or a selector in the Rules view you can edit it and see the results immediately. You can also :kbd:`Tab` through the different existing properties and values, and start editing them by pressing :kbd:`Enter` or :kbd:`Space`. To add a new declaration to a rule, click on the last line of the rule (the line occupied by the closing brace). + +As you start typing a property name, you'll see a list of autocomplete suggestions. Press:kbd:`Tab` to accept the current suggestion or :kbd:`Up` and :kbd:`Down` to move through the list. The default choice is the most common property that starts with the letters you've typed. For example, here the user has typed "c" and the default choice is "color": + +.. image:: edit_rule_autocomplete.png + :class: border + + +If you enter an invalid value for a property when editing it, or an unknown property name, a yellow alert icon appears besides the declaration. + +Edits that you make in the Rules view are reflected in the :doc:`Style Editor <../../../style_editor/index>`, and vice versa. Any changes you make are temporary: reloading the page will restore the original styling. + +While you're editing CSS, the context menu you'll see is the normal one for working with editable text: + +.. image:: editable-context-menu.png + :class: center + + +CSS variable autocompletion +--------------------------- + +`CSS variable names `_ will auto-complete depending on the variables defined in the CSS. If you enter ``var(`` into a property value and then type a dash (``-``), any variables you have declared in your CSS will then appear in an autocomplete list, which shows a color swatch so you can see exactly what color each variable choice is storing (`bug 1451211 `_) + +.. image:: edit_rule_var_autocomplete.png + :class: border + + +In addition, hovering over a CSS variable name brings up a tooltip showing what color value is stored in that variable `bug 1431949 `_. + +.. image:: var_value.png + :class: border + + +Editing keyboard shortcuts +-------------------------- + +You can use the arrow and page up/down keys (along with others) to increase/decrease numeric rules while editing: + + +- The :kbd:`Up` arrow increments values by 1 — for example, "1px" changes to "2px". +- :kbd:`Shift` + :kbd:`Up`/:kbd:`Down` increments or decrements values by 10. +- :kbd:`Ctrl` + :kbd:`Up`/:kbd:`Down` (on Linux and Windows) or :kbd:`Alt` + :kbd:`Up`/:kbd:`Down` (on Mac) increments or decrements values by 0.1. +- :kbd:`Shift` + :kbd:`Page up`/:kbd:`Page down` increments or decrements values by 100. + + +Track changes +------------- + +When you are editing the rules in the rules view, you can see the changes you have made in the Changes pane. + +.. image:: track_changes.png + :class: border + + +.. note:: + You can view changes made to the rules view only. If you edit the CSS using the Style Editor, the changes will not be shown in the changes pane. + + Also remember, as noted above, that changes you make to the CSS rules are temporary and will be reset if you reload the page. + + +If you are satisfied with the changes you have made, you can copy the new settings to page the edited rule into your stylesheet. Right-click on the changes panel and select **Copy Rule** from the context menu. + +.. image:: save_changes_panel.png + :class: border + + +The Copy Rule command copies the entire element, class, or id definition, including any unchanged rules and the rules that describe your changes. For example, copying the changes in the preceding image, you get the following: + +.. code-block:: css + + .text-content p { + box-sizing:border-box; + max-width:24rem; + text-decoration: underline; + color: cadetblue; + font-weight: bold; + } + + +.. _page_inspector_how_to_examine_and_edit_css_add_rules: + +Add rules +********* + +You can add new rules in the Rules view. Just right-click to show the context menu and select "Add rule". This will add a new CSS rule whose selector matches the currently selected node. + +.. image:: add_new_rule.png + :class: border + + +There's also a button that enables you to do the same thing: + +.. image:: rules_panel.png + :class: border + + +Copy rules +********** + +To copy rules, and pieces of rules, use one of the following context menu items in the Rules view: + + +- Copy Rule +- Copy Selector +- Copy Property Declaration +- Copy Property Name +- Copy Property Value + +.. image:: rules_context_menu.png + :class: center + + +See also +******** + +- Complete list of Page Inspector :ref:`Keyboard shortcuts `. +- The Inspector also includes a number of specialized tools for working with particular CSS features, such as colors, fonts, and animations. To read about these see the list of :doc:`how to guides <../../index>`. + diff --git a/devtools/docs/user/page_inspector/how_to/examine_and_edit_html/index.rst b/devtools/docs/user/page_inspector/how_to/examine_and_edit_html/index.rst new file mode 100644 index 000000000000..741eb11a8797 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/examine_and_edit_html/index.rst @@ -0,0 +1,466 @@ +===================== +Examine and edit HTML +===================== + +You can examine and edit the page's HTML in the :ref:`HTML pane `. + + +Navigating the HTML +******************* + +.. _page-inspector-how-to-examine-and-edit-html-breadcrumbs: + +HTML breadcrumbs +---------------- + +At the bottom on the HTML pane is a breadcrumbs toolbar. This shows the complete hierarchy through the document for the branch containing the selected element: + +.. image:: html_breadcrumbs.png + :class: border + + +Hovering over a breadcrumb highlights that element in the page. + +The breadcrumbs bar has its own :ref:`keyboard shortcuts `. + + +.. _page_inspector_how_to_examine_and_edit_html_searching: + +Searching +--------- + +The Page Inspector's search box matches all markup in the current document and in any frames. + +To start searching the markup, click in the search box to expand it or press :kbd:`Ctrl` + :kbd:`F` , or :kbd:`Cmd` + :kbd:`F` on a Mac. There are three types of searches that are performed automatically depending on what you enter, a full text search, a CSS selector search, and an XPath search. + + +Full text search +~~~~~~~~~~~~~~~~ + +The full text search will always be executed, independently of what you enter. That allows you to find CSS selectors and XPath expressions occurring within the text. + + +CSS selector search +~~~~~~~~~~~~~~~~~~~ + +You can search elements by entering a `CSS selector `_ + +As you type, an autocomplete popup shows any class or ID attributes that match the current search term: + +.. image:: search_html.png + :class: border + + +Press :kbd:`Up` and :kbd:`Down` to cycle through suggestions, :kbd:`Tab` to choose the current suggestion, then :kbd:`Enter` to select the first node with that attribute. + + +To cycle through matches, press :kbd:`Enter`. You can cycle backwards through matches using :kbd:`Shift` + :kbd:`Enter`. + + +XPath search +~~~~~~~~~~~~ + +It is also possible to search via `XPaths `_. This allows you to search for specific elements without the conflict of matching words within the text. For example, ``//a`` matches all `a `_ elements but not the letter "a" within the text content. Furthermore it allows for some more advanced searches like finding elements that start with a specific text, for example. + +.. image:: xpath_search.png + :alt: Match of an Inspector search using an XPath expression + :class: border + + +HTML tree +--------- + +The rest of the pane shows you the page's HTML as a tree (this UI is also called the Markup View). Just to the left of each node is an arrow: click the arrow to expand the node. If you hold the Alt key while clicking the arrow, it expands the node and all the nodes underneath it. + +.. image:: html_tree.png + :alt: The new Firefox 57 inspector HTML tree. + :class: center + + +Moving the mouse over a node in the tree highlights that element in the page. + +Nodes that are not visible are shown faded/desaturated. This can happen for different reasons such as using `display: none `_ or that the element doesn't have any dimensions. + +.. |image1| image:: child-node-indicator.png + :width: 20 + +There is an ellipsis shown between the opening and closing tag of an element when the node is collapsed if it has larger contents. Now children are indicated in the tree with this icon: |image1| + + +Markers ("badges") are displayed to the right of some nodes. The table below explains the meaning of each badge: + +.. |br| raw:: html + +
+ + +.. list-table:: + :widths: 25 75 + :header-rows: 0 + + * - ``event`` + - The element has one or several event listeners attached to it. Clicking the marker opens a tooltip listing the event listeners and allows you for each listener to switch to the line of JavaScript code in the :doc:`Debugger <../../../debugger/index>` where the listener is defined. + + * - ``scroll`` + - The element is a `scroll container `_, i.e. it has either ``overflow: scroll`` applied, or ``overflow: auto`` and sufficient content to cause `scrollable overflow `_. |br| |br| If preference ``devtools.overflow.debugging.enabled`` is ``true``, toggling the ``scroll`` badge will highlight any elements causing the overflow, and these nodes will additionally display the ``overflow`` badge. + + * - ``overflow`` + - The element is causing `scrollable overflow `_ in a `scroll container `_ (either the current node or a parent node—the affected nodewill display the ``scroll`` badge). |br| |br| **Note**: The ``overflow`` badge is introduced in Firefox 83. In earlier versions it can be enabled using the preference ``devtools.overflow.debugging.enabled`` is ``true``. + + * - ``grid`` + - The element is a `grid container `_, i.e. it has `display: grid `_ applied to it. Clicking the marker enables the grid highlighter. + + * - ``flex`` + - The element is a `flex container `_, i.e. it has `display: flex `_ applied to it. Clicking the marker enables the flexbox highlighter. + + * - ``inline-grid`` + - The element is an inline grid container, i.e. it has `display: inline-grid `_ or ``display: inline grid`` applied to it. Clicking the marker enables the grid highlighter. + + * - ``inline-flex`` + - The element is an inline flex container, i.e. it has `display: inline-flex `_ or ``display: inline flex`` applied to it. Clicking the marker enables the flexbox highlighter. + + * - ``custom…`` + - The element is a custom element. Clicking the marker switches to the line of JavaScript code in the Debugger where the custom element got defined. + + + +.. note:: + There are some useful keyboard shortcuts that can be used in the HTML tree — see the :ref:`HTML pane keyboard shortcuts list `. + + +::before and ::after +-------------------- + +You can inspect pseudo-elements added using `::before `_ and `::after `_ + +.. raw:: html + + +
+
+ + +Custom element definition +------------------------- + +When you open the Inspector on a page that includes custom elements, you can view the class definition for the custom element in the Debugger: + + +1. Inspect the element +2. Click on the word ``custom`` + + +.. image:: custom_pc_01.png + :class: center + + +The source for the element's class will be displayed in the Debugger. + +.. image:: custom_pc_02.png + :class: center + + +Whitespace-only text nodes +-------------------------- + +Web developers don’t write all their code in just one line of text. They use white space such as spaces, returns, or tabs between their HTML elements because it makes markup more readable. + +Usually this white space seems to have no effect and no visual output, but in fact, when a browser parses HTML it will automatically generate anonymous text nodes for elements not contained in a node. This includes white space (which is after all a type of text). + +If these auto generated text nodes are `inline level `_, browsers will give them a non-zero width and height. Then you will find strange gaps between elements, even if you haven’t set any margin or padding on them. + +.. |image2| image:: new-whitespace-text-indicator.png + :width: 20 + +Since Firefox 52, the Inspector displays these whitespace nodes, so you can see where the gaps in your markup come from. Whitespace nodes are represented with a dot: |image2| and you get an explanatory tooltip when you hover over them: + +.. image:: white_space_only.png + :class: center + + +To see this in action, see the demo at https://mdn.github.io/devtools-examples/whitespace-only-demo/index.html. + + +Shadow roots +------------ + +Any shadow roots present in the DOM are exposed in the HTML page in the same manner as the regular DOM. The shadow root is signified by a node named ``#shadow-root`` — you can click its expansion arrow to see the full contents of the shadow DOM, and then manipulate the contained nodes in a similar way to other part of the page's DOM (although with a limited featureset — you can't, for example, drag and drop or delete shadow DOM nodes). + + +.. image:: inspector_shadowdom.png + :alt: A view of a shadow root shown inside the DOM tree in the Firefox DevTools + :class: center + + +If a shadow DOM contains a "slotted" element (an element with a ``slot`` attribute after it has been inserted inside a `slot `_ element — see `Adding flexibility with slots `_ for an explanation of how these are used), the "slotted" element will be shown inside its corresponding `slot `_ element, with a "reveal" link alongside it. Clicking the "reveal" link will highlight the element with the ``slot`` attribute as it exists outside the shadow DOM + +.. image:: inspector_slot.png + :alt: A view of a shadow root shown inside the DOM tree in the Firefox DevTools + :class: center + + +This is very useful when you've got a ```` element and you can't find the source of its content. + + +.. note:: + + Shadow DOM inspection was implemented in Firefox 61, but was hidden behind the ``dom.webcomponents.shadowdom.enabled`` pref until Firefox 63. It is now turned on by default. + + +.. _page-inspector-how-to-element-popup-context-menu: + +Element popup context menu +-------------------------- + +You can perform certain common tasks on a specific node using a popup context menu. To activate this menu, context-click the element. The menu contains the following items — click on the links to find the description of each command in the :ref:`Context menu reference `: + + +- Edit As HTML +- Create New Node +- Duplicate Node +- Delete Node +- Attributes + + - Add Attribute + - Copy Attribute Value + - Edit Attribute + - Remove Attribute + +- Break on ... + + - Subtree Modification + - Attribute Modification + - Node Removal + +.. _page_inspector_how_to_examine_and_edit_html_use_in_console: + +- Use in Console +- Show DOM Properties +- Show Accessibility Properties +- Change Pseudo-class + + - hover + - active + - focus + - focus-visible + - focus-within + - visited + +- Screenshot Node + +.. _page_inspector_how_to_examine_and_edit_scroll_into_view: + +- Scroll Into View +- Copy + + - Inner HTML + - Outer HTML + - CSS Selector + - CSS Path + - XPath + - Image Data-URL + - Attribute + +- Paste + + - Inner HTML + - Outer HTML + - Before + - After + - As First Child + - As Last Child + +- Expand All +- Collapse All +- Open Link in New Tab [1] +- Open File in Debugger [1] +- Open File in Style-Editor [1] +- Copy Link Address [1] + + +[1] These options only appear in certain contexts, for example the "Open File in Style-Editor" option only appears when you context-click over the top of a link to a CSS file. + + +.. _page_inspector_how_to_examine_and_edit_html_context_menu_reference: + +Context menu reference +---------------------- + +.. list-table:: + :widths: 30 70 + :header-rows: 0 + + * - Edit as HTML + - :ref:`Edit the element's HTML `. + + * - (Copy) Inner HTML + - Copy the inner HTML for the element. + + * - (Copy) Outer HTML + - Copy the outer HTML for the element. + + Pressing :kbd:`Ctrl` + :kbd:`C` (or :kbd:`Cmd` + :kbd:`C` on a Mac) also performs this action. + + + * - (Copy) Unique Selector/CSS Selector + - Copy a CSS selector that uniquely selects the element. + + * - (Copy) CSS Path + - Copy a CSS selector that represents the full path to the element. + + * - (Copy) Image Data-URL + - Copy image as a data:// URL, if the selected element is an image. + + * - (Copy) Attribute + - Copy the attribute of the element. + + * - Show DOM Properties + - Open the :doc:`split console <../../../web_console/split_console/index>` and enter the console command "``inspect($0)``" to :doc:`inspect <../../../web_console/index>` the currently selected element. + + * - Use in Console + - Assigns the currently selected node to a variable named ``temp0`` (or ``temp1`` if ``temp0`` is already taken, and so on), then opens the :doc:`split console <../../../web_console/split_console/index>`, enabling you to interact with that node using the console's command line. + + * - Expand All + - In the tree view, expand the current element and all the elements underneath it. This is equivalent to holding the :kbd:`Alt` key and clicking the disclosure triangle next to an element. + + * - Collapse + - In the tree view, collapse the current element. This is equivalent to clicking the disclosure arrow next to an element that's expanded. + + * - (Paste) Inner HTML + - Paste the clipboard contents into the node as its `innerHTML `_. + + * - (Paste) Outer HTML + - Paste the clipboard contents into the node as its `outerHTML `_. + + * - (Paste) Before + - Paste the clipboard contents into the document immediately before this node. + + * - (Paste) After + - Paste the clipboard contents into the document immediately after this node. + + * - (Paste) As First Child + - Paste the clipboard contents into the document as the first child of this node. + + * - (Paste) As Last Child + - Paste the clipboard contents into the document as the last child of this node. + + * - Scroll Into View + - Scrolls the web page so the selected node is visible. + + From Firefox 44, pressing the keyboard shortcut :kbd:`S` will also scroll the selected node into view. + + * - Screenshot Node + - Takes a screenshot of the selected node, saved to your Downloads directory. See :doc:`Taking screenshots <../../../taking_screenshots/index>`. + + * - Create New Node + - Create a new empty
as the last child of the currently selected element. See :ref:`Inserting new nodes `. + + * - Duplicate Node + - Create a copy of this element, and insert the copy immediately after this element. + + * - Delete Node + - Delete the element from the DOM. + + * - Attribute/Add Attribute + - Add an attribute to the element. + + * - Attribute/Edit Attribute + - (only when invoked on an attribute) Edit the attribute. + + * - Attribute/Remove Attribute + - (only when invoked on an attribute) Remove the attribute. + + * - Open Link in New Tab + - (only when invoked over a link, such as an href attribute) Opens the linked item in a new tab. + + * - Open File in Debugger + - (only when invoked over a link to a JS source) Opens the linked source in the Debugger. + + * - Open File in Style-Editor + - (only when invoked over a link to a CSS source) Opens the linked source in the Style Editor. + + * - Copy Link Address + - (only when invoked over a URL) Copy the URL. + + * - (Change Pseudo-class) hover + - Set the `:hover `_ CSS pseudo-class. + + * - (Change Pseudo-class) active + - Set the `:active `_ CSS pseudo-class. + + * - (Change Pseudo-class) focus + - Set the `:focus `_ CSS pseudo-class. + + * - (Change Pseudo-class) focus-visible + - Set the `:focus-visible `_ CSS pseudo-class. + + * - (Change Pseudo-class) focus-within + - Set the `:focus-within `_ CSS pseudo-class. + + * - (Change Pseudo-class) visited + - Set the :visited CSS pseudo-class. + + +.. _page-inspector-how-to-examine-and-edit-html-editing_html: + +Editing HTML +************ + +You can edit the HTML — tags, attributes, and content — directly in the HTML pane: double-click the text you want to edit, change it, and press Enter to see the changes reflected immediately. + +To edit an element's `outerHTML `_, activate the element's popup menu and select "Edit As HTML". You'll see a text box in the HTML pane: + +.. image:: edit_html.png + :alt: Edit HTML directly in the Inspector panel in Firefox 57 + :class: border + +You can add any HTML in here: changing the element's tag, changing existing elements, or adding new ones. Once you click outside the box, the changes are applied to the page. + +When you're editing HTML, the context menu you'll see is the normal one for working with editable text: + +.. image:: editable-context-menu.png + :class: center + + +Copy and paste +-------------- + +You can use the :ref:`popup menu ` to copy nodes in the HTML tree and paste them into the desired location. + + +Drag and drop +------------- + +You can reorganize the HTML content of a page by moving nodes in the HTML tree. Just click and hold on any element and drag it up or down in the tree. When you release the mouse button, the element will be inserted at the corresponding position: + +.. raw:: html + + +
+
+ +You can cancel the drag and drop by pressing the :kbd:`Esc` key. + + +.. _page-inspector-how-to-examine-and-edit-html-inserting-new-nodes: + +Inserting new nodes +------------------- + +There's a "+" icon at the top of the markup view: + +.. image:: html_tree.png + :class: border + + +Click this icon to insert an empty {{HTMLElement("div")}} into the document as the last child of the currently selected element. You can then edit the new node's content and styling just as you would any other node in the document. + +.. raw:: html + + +
+
+ +You can access the same functionality using the "Create New Node" popup menu item. + +Note that this button is disabled if the selected element's type is such that adding a last-child would have no effect (for example, if it is an `html `_ or `iframe `_ element). However, it is enabled in places where it is not valid to insert a `div `_, such as `style `_ or `link `_. In these cases the element is added as text. diff --git a/devtools/docs/user/page_inspector/how_to/examine_and_edit_the_box_model/index.rst b/devtools/docs/user/page_inspector/how_to/examine_and_edit_the_box_model/index.rst new file mode 100644 index 000000000000..691630f2119f --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/examine_and_edit_the_box_model/index.rst @@ -0,0 +1,52 @@ +============================== +Examine and edit the box model +============================== + +Viewing the box model +********************* + +With the :ref:`Select Element button ` pressed, if you hover over an element in the page, the `box model `_ for the element is shown overlaid on the page: + +.. raw:: html + + +
+
+ + +It's also shown overlaid if you hover over an element's markup in the HTML pane: + +.. raw:: html + + +
+
+ +If the element is inline and is split over multiple line boxes, the highlighter shows each individual line box that together make up the element: + +.. image:: inline-box-model.png + :class: center + + +.. _page-inspector-how-to-examine-and-edit-the-box-model-view: + + +The Box Model view +------------------ + +When an element's selected, you can get a detailed look at the box model in the :ref:`Box Model view `: + +.. image:: box-model.png + :class: center + + +If you hover over a value, you'll see a tooltip telling you which rule the value comes from: + +.. image:: box-model-tooltip.png + :class: center + + +Editing the box model +********************* + +You can also edit the values in the :ref:`Box Model view `, and see the results immediately in the page. diff --git a/devtools/docs/user/page_inspector/how_to/examine_event_listeners/index.rst b/devtools/docs/user/page_inspector/how_to/examine_event_listeners/index.rst new file mode 100644 index 000000000000..a95f66bae9a3 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/examine_event_listeners/index.rst @@ -0,0 +1,29 @@ +======================= +Examine Event Listeners +======================= + +The inspector shows the word "event" next to elements in the :ref:`HTML Pane `, that have event listeners bound to them: + +.. image:: inspect_element_with_eventhandler.png + :class: border + +Click the icon, then you'll see a popup listing all the event listeners bound to this element: + +.. image:: inspector_event_handlers.png + :class: border + +Each line contains: + + +- a right-pointing arrowhead; click to expand the row and show the listener function source code +- the name of the event for which a handler was attached to this element +- the name and line number for the listener; you can also click here to expand the row and view the listener function source code +- a curved arrow pointing to a stack; click it to show the code for the handler in the debugger +- a label indicating whether the event bubbles +- a label indicating the system that defines the event. Firefox can display: + + - standard DOM events + - `jQuery events `_ + - `React events `_ + + diff --git a/devtools/docs/user/page_inspector/how_to/examine_flexbox_layouts/index.rst b/devtools/docs/user/page_inspector/how_to/examine_flexbox_layouts/index.rst new file mode 100644 index 000000000000..cbd14ea5e850 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/examine_flexbox_layouts/index.rst @@ -0,0 +1,133 @@ +============================================== +CSS Flexbox Inspector: Examine Flexbox layouts +============================================== + +The **Flexbox Inspector** allows you to examine `CSS Flexbox Layouts `_ using the Firefox DevTools, which is useful for discovering flex containers on a page, examining and modifying them, debugging layout issues, and more. + + +Discovering Flex Containers +*************************** + +When an HTML element on your page has `display: flex `_ applied to it, a number of features are made available in the DevTools to provide easy access to Flexbox layout features. + + +In the HTML pane +---------------- + +In the :ref:`HTML Pane `, an element laid out with Flexbox has the word ``flex`` next to it as shown in the following image: + +.. image:: html-pane.png + :alt: Indicators in the inspector showing an element is a flex container + :class: center + + +Click the word ``flex`` in the HTML pane to keep the overlay visible when you move the mouse away from the container. + + +In the infobar +-------------- + +When you hover over an element in the HTML pane, you will see a tooltip that gives you more information about the element. When you hover over a flex container or flex item, the tooltip includes the appropriate information. + +This header is a flex container: + +.. image:: infobar-cont.png + :alt: Tooltip showing element is a flex container + :class: center + +Each navbar link is a flex item: + +.. image:: infobar-item.png + :alt: Tooltip showing an element is a flex item + :class: center + +The ``nav`` element within the header is both a flex item and a flex container which holds the navigation links: + +.. image:: infobar-both.png + :alt: Tooltip showing an element is both a flex container and a flex item + :class: center + + +In the CSS pane +--------------- + +.. |image1| image:: flexbox_icon.gif + :width: 20 + +In the :ref:`CSS pane `'s Rules view, any instance of a `display: flex `_ declaration gets a small Flexbox icon |image1| next to the word ``flex``. + +.. image:: css-pane.png + :alt: The CSS pane of the Firefox devtools, showing the CSS for a flex container with an icon to toggle the Flexbox overly + :class: center + + +Clicking the icon toggles the display of an overlay on the page, which appears over the selected flex container that displays an outline around each flex item: + +.. image:: overlay.png + :alt: Flexbox overlay showing a flex container and its children + :class: center + + +The overlay will still be shown when you select other elements from the Inspector panel, so you can edit related CSS properties and see how the flex items are affected by your changes. + + +The Layout Flex Container section +--------------------------------- + +The CSS pane's Layout view includes a collapsible "Flex Container" section. If you expand the section without selecting a flexbox container, it will only display the message, "Select a Flex container or item to continue". Once you select an element whose display is defined as flex, the panel will include a number of options for viewing details about the flex container and flex items within it. You can find out more about those in the section below. + +.. note:: + + The Layout view can be found underneath the *Layout* tab on the right-hand pane of the Page Inspector. The above and below screenshots should give you further hints on how to get to this. + + +Flex Container options +********************** + +The Flex Container section of the Layout view looks like this: + +.. image:: flex-cont.png + :alt: Layout pane in Firefox Devtools showing options for the flexbox overlay + :class: center + + +There are two settings you can change in the Flex Container section: + + +- You can control the color of the overlay by clicking on the small circle next to the selector. This will toggle a color picker so you can select a different color for the overlay. +- The switch on the right-hand side of the Flex Container section will also toggle the overlay on and off. + + +Flex item properties +******************** + +The flex items within the flex container are displayed as a numbered list in the Flex Items section. Each entry displays the item's selector. Hover over an element to highlight it on the page. + +.. image:: flex-items.png + :alt: List of flex items displayed in the Layout pane of Firefox Devtools + :class: center + +If you click on the item, the display shifts to show details about that element: + +.. image:: item-details.png + :alt: Details of flex item sizing in the Layout pane of Firefox DevTools + :class: center + + +This view shows information about the calculations for the size of the selected flex item: + + +- A diagram visualizing the sizing of the flex item +- Content Size - the size of the component without any restraints imposed on it by its parent +- Flexibility - how much a flex item grew or shrunk based on its flex-grow value when there is extra free space or its flex-shrink value when there is not enough space +- Minimum Size (only appears when an item is clamped to its minimum size) - the minimum content size of a flex item when there is no more free space in the flex container +- Final Size - the size of the flex item after all sizing constraints imposed on it have been applied (based on the values of flex-grow, flex-shrink and flex-basis) + +At the top of the section is a drop-down list of all the items in the selected flexbox container: + +.. image:: select-items.png + :alt: Dropdown in Layout pane that allows you to select between different flex children + :class: border + + +You can use this drop-down to select any of the other flex items in the flex container. diff --git a/devtools/docs/user/page_inspector/how_to/examine_grid_layouts/index.rst b/devtools/docs/user/page_inspector/how_to/examine_grid_layouts/index.rst new file mode 100644 index 000000000000..8edf301faaa4 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/examine_grid_layouts/index.rst @@ -0,0 +1,190 @@ +======================================== +CSS Grid Inspector: Examine grid layouts +======================================== + +The **Grid Inspector** allows you to examine `CSS Grid Layouts `_ using the Firefox DevTools, discovering grids present on a page, examining and modifying them, debugging layout issues, and more. + +.. note:: + + The examples shown in the screenshots appearing in this article are Jen Simmons' `Futurismo `_ and `Variations on a grid `_ experiments, and a `live named grid area example `_ from Rachel Andrew. + + +Discovering CSS grids +********************* + +When an HTML element on your page has `display: grid `_ applied to it, a number of features are made available in the DevTools to provide easy access to grid features. + + +In the HTML pane +---------------- + +In the :ref:`HTML Pane `, elements laid out using a grid have a "grid" marker beside them. + +.. image:: html-pane.png + :alt: The HTML pane of the Firefox devtools, showing an element annotated with a grid marker, meaning that it has display: grid set on it + :class: border + + +In the CSS pane +--------------- + +.. |image1| image:: screen_shot_2016-12-16_at_10.51.15_am.png + :width: 20 + +In the :ref:`CSS pane `'s Rules view, any instance of a `display: grid `_ declaration gets a grid icon included within it: |image1|. + +.. image:: css-pane.png + :alt: The CSS pane of the Firefox devtools, showing the CSS for a grid layout with a grid icon included next to display: grid + :class: border + + +Clicking the icon toggles the display of a grid overlay on the page, which appears over the element, laid out like a grid to show the position of its grid lines and tracks: + +.. image:: grid-overlay.png + :alt: A screenshot of the Firefox web browser, showing a colored overlay on top of a section of the page laid out like a grid + :class: border + + +The overlay is still shown when you select other elements, so you can edit related CSS properties and see how the grid is affected. + + +The Layout view Grid section +---------------------------- + +When grids are included on a page, the CSS pane's Layout view includes a "Grid" section containing a number of options for viewing those Grids. You can find out more about those in the section below. + +.. note:: + + The Layout view can be found underneath the *Layout* tab on the right-hand pane of the Page Inspector. The above and below screenshots should give you further hints on how to get to this. + + +Grid options +************ + +The Grid section of the Layout view looks like this: + +.. image:: grid-options.png + :alt: The grid options section of the Firefox devtools Layout view, showing multiple options for specifying how you want to see CSS grids displayed + :class: border + + +You'll see a number of options contained within: + + +- Overlay Grid: Contains a checkbox for each grid present on the page, along with various options. Allows overlay views to be toggled on and off. +- Grid Display Settings: + + - Display line numbers: Turn the line numbers shown for each grid overlay on and off (on by default). + - Display area names: Turn area names on and off, in the case of grids with named grid areas (on by default, where relevant). + - Extend lines infinitely: By default, grid lines/tracks are only shown inside the element with ``display: grid`` set on it; when toggling this option on, the grid lines extend to the edge of the viewport along each axis. + +- Mini grid view: A smaller view of the currently overlaid grid. + + +.. note:: + + Your grid preferences such as overlay color and display settings choices are persisted across page loads for each separate page. + +Let's examine these features in more detail. + + +Overlay grid +------------ + +Each grid present on a page has an entry in the "Overlay grid" section: + +.. image:: overlay-grid-entry.png + :alt: An entry for a single grid in the Overlay Grid section of the Grid options, showing a grid's name, overlay color, and more. + :class: border + +Each entry consists of (from left to right): + + +- A checkbox allowing you to toggle the grid overlay for that grid on and off. +- A name label to represent the grid, consisting of a selector identifying the HTML element that has the grid applied to it. Clicking this also toggles the grid overlay on and off. +- A target icon that when clicked immediately selects the HTML element that this grid entry relates to, inside the HTML pane. +- A color picker icon that allows you to change the primary color of the grid overlay. This is useful for selecting different colors so you can easily tell your grids apart. + + +Inspecting a subgrid +-------------------- + +When the page contains a grid with a subgrid, the entry for the subgrid is indented under its parent in the Overlay grid section. When you select the checkbox for the subgrid, the lines for the parent grid are displayed also displayed; if the checkbox for the parent grid is unselected, then its lines are translucent. + +.. image:: subgrid-lines.png + :alt: Screenshot showing the overlay lines for a subgrid, with the subgrid lines and parent grid lines called out. + :class: center + + +Display line numbers +-------------------- + +By default, the line numbers are displayed on the grid overlay. + +.. image:: line-numbers.png + :alt: A CSS grid overlay with grid line numbers displayed + :class: border + + +Unchecking the "Display line numbers" box turns them off. + +.. image:: no-line-numbers.png + :alt: A CSS grid overlay with grid line numbers not displayed + :class: border + + +Display area names +------------------ + +In a grid with named areas, the area names are shown on the grid overlay by default. + +.. image:: grid-named-areas.png + :alt: A CSS grid overlay with named area names displayed + :class: border + +Unchecking the "Display area names" box turns them off. + +.. image:: no-grid-named-areas.png + :alt: A CSS grid overlay with named area names not displayed + :class: border + + +Extend lines infinitely +----------------------- + +By default, the grid lines/tracks are only shown inside the element with ``display: grid`` set on it. + +.. image:: no-extend-lines.png + :alt: A CSS grid overlay with grid lines not extended infinitely + :class: border + +When you check the "Extend lines infinitely" option, the grid lines extend to the edge of the viewport along each axis. + +.. image:: extend-lines.png + :alt: A CSS grid overlay with grid lines extended infinitely + :class: border + + +Mini grid view +-------------- + +Shows a small version of the currently overlaid grid, which is in proportion to the real thing. + +.. image:: mini-grid-view.png + :alt: A mini CSS grid view from the Firefox DevTools + :class: border + +Hovering over the different areas of the mini grid causes the equivalent area on the grid overlay to also highlight, along with a tooltip containing useful information such as the dimensions of that area, its row and column numbers, etc. + +.. image:: mini-grid-highlight.png + :alt: A firefox screenshot showing an area of a mini CSS grid being highlighted in the DevTools, and the corresponding area in the real grid being highlighted on the web page. + :class: border + + +See also +******** + +- `labs.jensimmons.com `_ — lots of interesting grid examples. +- `Grid by Example `_ — CSS Grid learning resources from Rachel Andrew. +- `CSS Grid Layout `_ — MDN CSS Grid Layout references and tutorials. + diff --git a/devtools/docs/user/page_inspector/how_to/index.rst b/devtools/docs/user/page_inspector/how_to/index.rst new file mode 100644 index 000000000000..07b4fd5a8a64 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/index.rst @@ -0,0 +1,26 @@ +====== +How to +====== + +Links for various HOW TO's can be found here. These links describe in depth the HOW TO techniques. + + +- :doc:`CSS Flexbox Inspector: Examine Flexbox layouts ` +- :doc:`CSS Grid Inspector: Examine grid layouts ` +- :doc:`Debug scrollable overflow ` +- :doc:`Edit CSS filters ` +- :doc:`Edit Shape Paths in CSS ` +- :doc:`Edit fonts ` +- :doc:`Examine Event Listeners ` +- :doc:`Examine and edit CSS ` +- :doc:`Examine and edit HTML ` +- :doc:`Examine and edit the box model ` +- :doc:`Inspect and select colors ` +- :doc:`Open the Inspector ` +- :doc:`Reposition elements in the page ` +- :doc:`Select an element ` +- :doc:`Select and highlight elements ` +- :doc:`Use the Inspector from the Web Console ` +- :doc:`View background images ` +- :doc:`Visualize transforms ` +- :doc:`Work with animations ` diff --git a/devtools/docs/user/page_inspector/how_to/inspect_and_select_colors/index.rst b/devtools/docs/user/page_inspector/how_to/inspect_and_select_colors/index.rst new file mode 100644 index 000000000000..b273dc15e289 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/inspect_and_select_colors/index.rst @@ -0,0 +1,32 @@ +========================= +Inspect and select colors +========================= + +In the CSS Pane's :ref:`Rules view `, if a rule contains a color value, you'll see a sample of the color next to the value: + +.. image:: inspector-css-color-swatch.png + +A color sample is also shown for CSS custom properties (variables) that represent colors. + +.. image:: css_color_vars.png + :alt: CSS in the Rules pane showing a color swatch on a CSS variable + :class: border + +If you click on the color sample, you'll see a color picker popup, enabling you to change the color: + +.. image:: color-picker-good-contrast.png + :alt: Color picker showing a case of good contrast with the background + +.. image:: color-picker-bad-contrast.png + :alt: Color picker showing a case of poor contrast" src="color-picker-bad-contrast.png + +If the color is a foreground color, the color picker tells you whether its contrast with the background color meets accessibility guidelines. Hovering the mouse over the contrast message gives a more detailed explanation. + +The color picker includes an eyedropper icon: clicking this icon enables you to use the eyedropper to select a new color for the element from the page: + +.. raw:: html + + +
+
+ diff --git a/devtools/docs/user/page_inspector/how_to/open_the_inspector/index.rst b/devtools/docs/user/page_inspector/how_to/open_the_inspector/index.rst new file mode 100644 index 000000000000..0b71619cac6b --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/open_the_inspector/index.rst @@ -0,0 +1,32 @@ +================== +Open the Inspector +================== + +There are two main ways to open the Inspector: + +- Choose *Tools > Web Developer > Inspector* from the Menu Bar or the equivalent :ref:`keyboard shortcut `. +- Right-click an element on a web page and select *Inspect Element*. + + +The Inspector will appear at the bottom of the browser window: + +.. image:: pageinspector.png + :alt: The all-new Inspector in Firefox 57 DevTools. + :class: center + +You can also set the pane to appear at the left side of the browser window: + +.. image:: inspector_leftside.png + :class: center + +To the right side of the browser window: + +.. image:: inspector_rightside.png + :class: center + +Or in a separate window: + +.. image:: inspector_sidexside.png + :class: center + +To start finding your way around the Inspector, see the :doc:`UI tour <../../ui_tour/index>`. diff --git a/devtools/docs/user/page_inspector/how_to/reposition_elements_in_the_page/index.rst b/devtools/docs/user/page_inspector/how_to/reposition_elements_in_the_page/index.rst new file mode 100644 index 000000000000..80c3af69106e --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/reposition_elements_in_the_page/index.rst @@ -0,0 +1,20 @@ +=============================== +Reposition elements in the page +=============================== + +Starting in Firefox 48 you can move absolutely positioned elements by dragging them around the page. + +If an element has its `position `_ property set to ``absolute``, ``relative`` or ``fixed`` and one or more of the `top `_, `bottom `_ , `left `_ or `right `_ properties, :ref:`Box Model view ` displays a button: + +.. image:: box-model-reposition.png + :class: center + +If you click that button, two handles appear next to the element: + +.. image:: in-content-box-model-editing.png + :alt: Example for changing the position of an element within the content + :class: center + +You can use these handles to drag the element around the page. + +If the element is absolutely positioned, dashed lines are shown representing the offset parent. For relatively positioned elements the dashed lines indicate the original position of the node. The offsets are indicated by a line and a tooltip for each side. diff --git a/devtools/docs/user/page_inspector/how_to/select_an_element/index.rst b/devtools/docs/user/page_inspector/how_to/select_an_element/index.rst new file mode 100644 index 000000000000..b6cfe9fba1d4 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/select_an_element/index.rst @@ -0,0 +1,37 @@ +================= +Select an element +================= + +The *selected element* is the element in the page that the Inspector is currently focused on. The selected element is shown in the :ref:`HTML pane ` and its CSS is displayed in the :doc:`CSS pane <../../ui_tour/index>`. + +The *highlighted element* is the element that's overlaid in the page with a graphic showing the box model, and a tooltip showing its tag and size: + +.. image:: inspector-highlighted.png + :class: center + + +With the context menu +********************* + +To open the Inspector and select an element immediately, activate the context menu over the element in the page and select "Inspect Element" + + +With the HTML pane +****************** + +When the inspector is open, as you move the mouse around the elements listed in the HTML pane, the corresponding elements are highlighted in the page. Click an element in the HTML pane to select it. + +You can also use the arrow keys to move around the DOM with the keyboard. + + +.. _page-inspector-how-to-select-an-element-with-the-node-picker: + +With the node picker +******************** + +.. |image1| image:: node-picker.png + :width: 20 + +To select an element in the page itself, activate the "node picker" by clicking its icon: |image1| (also called the *Select Element* icon). After that, as you move the mouse around the page, the element under the mouse is highlighted. Click the element to select it: + +Starting in Firefox 52, if you :kbd:`Shift` + click the element, then it is selected but the picker stays active. This lets you see the rules for the element in the CSS pane, but conveniently select another element in the page. diff --git a/devtools/docs/user/page_inspector/how_to/select_and_highlight_elements/index.rst b/devtools/docs/user/page_inspector/how_to/select_and_highlight_elements/index.rst new file mode 100644 index 000000000000..dbcb0c918f0a --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/select_and_highlight_elements/index.rst @@ -0,0 +1,35 @@ +============================= +Select and highlight elements +============================= + +The *selected* element is the element in the page that the Inspector is currently focused on. The selected element is shown in the :ref:`HTML pane ` and its CSS is displayed in the :doc:`CSS pane <../../ui_tour/index>`. + +The *highlighted* element is the element that's overlaid in the page with a graphic showing the box model, and a tooltip showing its tag and size: + +.. image:: inspector-highlighted.png + :class: center + + +With the context menu +********************* + +To open the Inspector and select an element immediately, activate the context menu over the element in the page and select "Inspect Element" + + +With the HTML pane +****************** + +When the inspector is open, as you move the mouse around the elements listed in the HTML pane, the corresponding elements are highlighted in the page. Click an element in the HTML pane to select it + +You can also use the arrow keys to move around the DOM with the keyboard. + + +With the node picker +******************** + +.. |image1| image:: node-picker.png + :width: 20 + +To select an element in the page itself, activate the "node picker" by clicking its icon: |image1| (also called the *Select Element* icon). After that, as you move the mouse around the page, the element under the mouse is highlighted. Click the element to select it: + + diff --git a/devtools/docs/user/page_inspector/how_to/use_the_inspector_from_the_web_console/index.rst b/devtools/docs/user/page_inspector/how_to/use_the_inspector_from_the_web_console/index.rst new file mode 100644 index 000000000000..b3a015dbba7f --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/use_the_inspector_from_the_web_console/index.rst @@ -0,0 +1,13 @@ +====================================== +Use the Inspector from the Web Console +====================================== + +The element that's currently selected in the Page Inspector can be referenced in the Web Console using the variable ``$0``. + +.. image:: console-$0.png + :class: center + +DOM elements in the Web Console output get a target next to them. If you hover over this target, the element is highlighted in the page, and if you click the target, the element is selected in the Inspector: + +.. image:: console-highlight.png + :class: center diff --git a/devtools/docs/user/page_inspector/how_to/view_background_images/index.rst b/devtools/docs/user/page_inspector/how_to/view_background_images/index.rst new file mode 100644 index 000000000000..ae2a72aaddf4 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/view_background_images/index.rst @@ -0,0 +1,14 @@ +====================== +View background images +====================== + +In the :ref:`Rules view `, you can see a preview of images specified using `background-image `_. Just hover over the rule: + +.. image:: css-image-preview.png + :class: center + + +From Firefox 41, if you right-click the image declaration, you'll see an option to copy the image as a data: URL: + +.. image:: css-copy-image-data-url.png + :class: center diff --git a/devtools/docs/user/page_inspector/how_to/visualize_transforms/index.rst b/devtools/docs/user/page_inspector/how_to/visualize_transforms/index.rst new file mode 100644 index 000000000000..ae9eb3fbdb11 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/visualize_transforms/index.rst @@ -0,0 +1,9 @@ +==================== +Visualize transforms +==================== + +If you hover over a `transform `_ property in the :ref:`Rules view `, you'll see the transformation overlaid in the page: + +.. image:: transform.png + :class: center + diff --git a/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_(firefox_41_and_42)/index.rst b/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_(firefox_41_and_42)/index.rst new file mode 100644 index 000000000000..1771ac155086 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_(firefox_41_and_42)/index.rst @@ -0,0 +1,26 @@ +======================================= +Animation inspector (Firefox 41 and 42) +======================================= + +.. note:: + Note that the Animation inspector's UI was revamped in Firefox 43. To see what the Animation inspector looks like in Firefox 43 and subsequent releases, see `the main "Work with animations" page `_. + + +The Animation inspector enables you to: + + +- see information about all animations running in the page +- play/pause all animations +- play/pause/rewind/fast-forward each animation +- jump to a specific point in an animation +- highlight and inspect the animated node +- adjust the playback rate of each animation +- see whether an animation is running in the compositor thread (a lightning bolt icon is displayed next to such animations) + + +.. raw:: html + + +
+
+ diff --git a/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_example_colon__css_transitions/index.rst b/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_example_colon__css_transitions/index.rst new file mode 100644 index 000000000000..24d1d135002e --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_example_colon__css_transitions/index.rst @@ -0,0 +1,94 @@ +============================================ +Animation inspector example: CSS transitions +============================================ + +Firefox Logo Animation +********************** + +Example animation using `CSS transitions `_. + +HTML Content +------------ + +.. code-block:: html + +
+ + Firefox Developer Edition +
+ + +CSS Content +----------- + +.. code-block:: css + + .channel { + padding: 2em; + margin: 0.5em; + box-shadow: 1px 1px 5px #808080; + margin: 1.5em; + } + + .channel > * { + vertical-align: middle; + line-height: normal; + } + + .icon { + width: 50px; + height: 50px; + filter: grayscale(100%); + transition: transform 750ms ease-in, filter 750ms ease-in-out; + } + + .note { + margin-left: 1em; + font: 1.5em "Open Sans",Arial,sans-serif; + overflow: hidden; + white-space: nowrap; + display: inline-block; + + opacity: 0; + width: 0; + transition: opacity 500ms 150ms, width 500ms 150ms; + } + + .icon#selected { + filter: grayscale(0%); + transform: scale(1.5); + } + + .icon#selected+span { + opacity: 1; + width: 300px; + } + + +JavaScript Content +------------------ + +.. code-block:: JavaScript + + function toggleSelection(e) { + if (e.button != 0) { + return; + } + if (e.target.classList.contains("icon")) { + var wasSelected = (e.target.getAttribute("id") == "selected"); + clearSelection(); + if (!wasSelected) { + e.target.setAttribute("id", "selected"); + } + } + } + + function clearSelection() { + var selected = document.getElementById("selected"); + if (selected) { + selected.removeAttribute("id"); + } + } + + document.addEventListener("click", toggleSelection); + diff --git a/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_example_colon__web_animations_api/index.rst b/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_example_colon__web_animations_api/index.rst new file mode 100644 index 000000000000..8ff1634d9245 --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/work_with_animations/animation_inspector_example_colon__web_animations_api/index.rst @@ -0,0 +1,118 @@ +=============================================== +Animation inspector example: Web Animations API +=============================================== + +Firefox Logo Animation +********************** + +Example animation using the `Web Animations API `_. + + +HTML Content +------------ + +.. code-block:: html + +
+ + Firefox Developer Edition +
+ + +CSS Content +----------- + +.. code-block:: css + + .channel { + padding: 2em; + margin: 0.5em; + box-shadow: 1px 1px 5px #808080; + margin: 1.5em; + } + + .channel > * { + vertical-align: middle; + line-height: normal; + } + + #icon { + width: 50px; + height: 50px; + filter: grayscale(100%); + } + + #note { + margin-left: 1em; + font: 1.5em "Open Sans",Arial,sans-serif; + overflow: hidden; + white-space: nowrap; + display: inline-block; + opacity: 0; + width: 0; + } + + +.. _page-inspector-work-with-animations-web-example-js-content: + +JavaScript Content +------------------ + +.. code-block:: JavaScript + + var iconKeyframeSet = [ + { transform: 'scale(1)', filter: 'grayscale(100%)'}, + { filter: 'grayscale(100%)', offset: 0.333}, + { transform: 'scale(1.5)', offset: 0.666 }, + { transform: 'scale(1.5)', filter: 'grayscale(0%)'} + ]; + + var noteKeyframeSet = [ + { opacity: '0', width: '0'}, + { opacity: '1', width: '300px'} + ]; + + var iconKeyframeOptions = { + duration: 750, + fill: 'forwards', + easing: 'ease-in', + endDelay: 100 + } + + var noteKeyframeOptions = { + duration: 500, + fill: 'forwards', + easing: 'ease-out', + delay: 150 + } + + var icon = document.getElementById("icon"); + var note = document.getElementById("note"); + + var iconAnimation = icon.animate(iconKeyframeSet, iconKeyframeOptions); + var noteAnimation = note.animate(noteKeyframeSet, noteKeyframeOptions); + + iconAnimation.pause(); + noteAnimation.pause(); + + var firstTime = true; + + function animateChannel(e) { + if (e.button != 0) { + return; + } + if (e.target.id != "icon") { + return; + } + if (firstTime) { + iconAnimation.play(); + noteAnimation.play(); + firstTime = false; + } else { + iconAnimation.reverse(); + noteAnimation.reverse(); + } + } + + document.addEventListener("click", animateChannel); + diff --git a/devtools/docs/user/page_inspector/how_to/work_with_animations/index.rst b/devtools/docs/user/page_inspector/how_to/work_with_animations/index.rst new file mode 100644 index 000000000000..1dbfac4539bc --- /dev/null +++ b/devtools/docs/user/page_inspector/how_to/work_with_animations/index.rst @@ -0,0 +1,229 @@ +==================== +Work with animations +==================== + +This article covers three tools you can use to visualize and edit animations: + + +- :ref:`the animation inspector ` + +- :ref:`diting @keyframes ` + +- :ref:`editing timing functions ` + + +.. _page-inspector-how-to-work-with-animations-animation-inspector: + +Animation inspector +******************* + +The Page Inspector's :ref:`Animations view ` displays animations in the page synchronized along a timeline, with a draggable widget you can use to move to any point in the timeline and see the page at that point. + +It displays animations created using `CSS transitions `_, `CSS @keyframes rules `_, or the `Web Animations API `_. Starting in Firefox 48, it will show animations applied to the `::before `_ and `::after `_ pseudo-elements. + +To see how it works, we'll walk through an example. The box below contains a grayscale icon, representing `Firefox Developer Edition `_. If you click the icon, it enlarges and changes to color, and the name of the browser appears. Click the icon again to reverse the effect. + + +These animations are made using the `Web Animations API `_. + +Let's use the animation inspector to see what's going on in this example. + + +1. Right-click in the box and select "Inspect Element" +2. Make sure the selected element is the ``
`` +3. Switch over to the "Animations" tab +4. Play the animation + + +.. raw:: html + + +
+
+ + +Let's take a closer look at the contents of the animation inspector here: + +.. image:: animation_pane.png + :class: border + + +It shows a synchronized timeline for every animation applied to the selected element or its children. The timeline starts at the start of the first animation, ends at the end of the last animation, and is labeled with markers every 250 milliseconds (this depends on the time scale of the animations currently displayed). + + +Animation bars +-------------- + +Each animation or transition is shown as a horizontal bar laid across the timeline. The bar is: + + +- blue if a `transition `_) was used to animate a property +- orange if a `@keyframes animation `_ was used +- green if the `Web Animations API `_ was used + +.. |image1| image:: compositor.png + :width: 20 + +The bar contains a lightning bolt icon |image1| if the property was animated using the compositor thread (see more about the :ref:`cost of animating different CSS properties `). + +The bar is shaped to reflect the easing effect used for the animation. In the example above you can see that the first bar is concave, representing ease-in, and the second is convex, representing ease-out. + +If the animation used CSS transitions, there is one bar for each property transitioned, and it is labeled with the name of the property being transitioned. If the animation used CSS ``@keyframes``, there is one bar for each animation, labeled with its name. + +If the animation or transition had a delay, this is shown as a cross-hatched portion of the bar. `delay and endDelay `_ are both represented. + +If you hover over the bar, a tooltip appears, giving you more detailed information about the animation or transition, including: + + +- the type of animation: CSS transition, CSS animation, or Web Animations API +- the duration of the animation +- the animation's start and end delay +- the animation's easing (or timing function). +- the animation's fill +- the Playback rate of the animation + + +.. image:: animation_details.png + :class: border + + +Information about the animated element +-------------------------------------- + +To the left of each bar is a selector for the element that the animation applies to. If you hover over this selector, the element is highlighted in the page. Click the selector to select the element in the inspector. + +.. |image2| image:: target-icon.png + +To the left of the selector is a "target" icon (|image2|). Clicking this icon locks the highlighter on the element. + + +Animation details +----------------- + +If you click one of the bars, you'll see details of all the properties that were changed in the animation. For example, try clicking on the bar for ``img#icon`` animation: + +.. image:: animation_icon_details.png + :class: border + + +This is telling us that two properties were modified: `filter `_ and `transform `_. Each dot represents an entry for that property in the set of keyframes used for the animation. Both properties were initialized at 0ms and finalized at 750ms. ``filter`` was given a value at 250ms and ``transform`` at 500ms. If you hover over a dot, you'll see the value assigned to that property at that point in the timeline: + +.. image:: animation_icon_scale.png + :class: border + + +This is essentially a visual representation of the animation's +:ref:`keyframes `: + +.. code-block:: JavaScript + + var iconKeyframeSet = [ + { transform: 'scale(1)', filter: 'grayscale(100%)' }, + { filter: 'grayscale(100%)', offset: 0.333 }, + { transform: 'scale(1.5)', offset: 0.666 }, + { transform: 'scale(1.5)', filter: 'grayscale(0%)' } + ]; + + +Application to the example +-------------------------- + +Applying all this to our example, we can see that: + + +- The animation involved two elements, ``span#note`` and ``img#icon``. Hovering over these selectors, we can see that those elements are, respectively, the browser name "Firefox Developer Edition" and the browser icon. +- The ``img#icon`` animation: + + - animated the `filter `_ and `transform `_ properties, to scale the icon and color it + - lasted 750ms, had an ``endDelay`` of 100ms + - used the compositor thread + - was given an `easing `_ value of ``ease-in``: you can see this by the concave shape of the green bar. + +- The ``span#note`` animation: + + - animated the `width `_ and `opacity `_ properties, to make the name gradually appear + - lasted 500ms, and had a ``delay`` of 150ms + - was given an `easing `_ value of ``ease-out``: you can see this by the convex shape of the green bar. + + +Animation playback +------------------ + +At the top of the animation inspector: + + +- there are buttons to play/pause and restart the animation +- there's a dropdown to change the animation playback rate +- the current time in the animation is displayed. + + +Finally, if you click inside the bar at the top of the timeline, you get a scrubber that you can drag left and right to move backwards and forwards through the animation, and pinpoint exactly what's happening when. + + +Further information about animation compositing +----------------------------------------------- + +If you open `animation-inspector-compositing.html `_ and click the red rectangle, a simple `opacity `_ animation will start. If you look at this in the Animation Inspector in Firefox 49+, you'll see that: + + +- The white lightning bolt icon now indicates whether all the animation properties have been optimized by running them through the compositor, where possible. +- The bar tooltip also includes this information, as a further reminder. You'll get a message of "All animation properties are optimized." +- The expanded animation information now includes a lightning bolt icon next to the properties whose animation has been optimized via the compositor. + + +.. image:: animation_swoosh_01.png + :class: border + +Let's now look at `animation-inspector-compositing-silly.html `_ — this is the same example, except that now once the red rectangle is clicked we animate both the `left `_ and `transform `_ (with a translation) properties at the same time as `opacity `_. It doesn't make much sense to try to animate a geometric property and a translation at the same time — the two effects won't be synchronized — so the ``transform`` property is deliberately not handed over to the compositor to handle. The Animation Inspector will tell you this — look at it now and you'll see that: + + +- The white lightning bolt icon in the bar has been replaced with a grey lightning bolt icon, to indicate that only some of the relevant properties are being optimized by the compositor. +- The bar tooltip also includes this information, as a further reminder. You'll get a message of "Some animation properties are optimized." +- Properties whose animation is **not** being optimized, but could be if you improved your code, are now given a dotted underline — see transform in the screenshot below. Hovering over this gives you a tooltip that explains why. In this case, the message is "Animations of 'transform' cannot be run on the compositor when geometric properties are animated on the same element at the same time." + + +.. image:: animation_not_optimized.png + :class: border + + +.. _page-inspector-how-to-work-with-animations-edit-keyframes: + +Edit @keyframes +*************** + +Any `@keyframes rules `_ associated with the currently selected element are displayed in the :ref:`Rules view ` and are editable: + +.. raw:: html + + +
+
+ + +.. _page-inspector-how-to-work-with-animations-edit-timing-functions: + +Edit timing functions +********************* + +When you `create a CSS animation `_ you can specify a `timing function `_: this determines the rate at which the animation progresses. One way to specify the timing function is with a cubic Bézier curve. + +Timing functions defined as cubic Bézier curves get an icon in the Rules view. If you click the icon you get a visual editor for the curve, enabling you to drag `P1 and P2 `_, and see the results in the page: + +.. raw:: html + + +
+
+ + +This feature uses open source code from `Lea Verou’s cubic-bezier.com `_. + +The cubic Bézier editor includes a number of presets, grouped under "Ease-in", "Ease-out", and "Ease-in-out": + +.. raw:: html + + +
+
+ + diff --git a/devtools/docs/user/page_inspector/index.rst b/devtools/docs/user/page_inspector/index.rst new file mode 100644 index 000000000000..c85583fa56d5 --- /dev/null +++ b/devtools/docs/user/page_inspector/index.rst @@ -0,0 +1,47 @@ +============== +Page Inspector +============== + +Use the Page Inspector to examine and modify the HTML and CSS of a page. + +You can examine pages loaded in the local copy of Firefox or in a remote target such as Firefox for Android. See :doc:`remote debugging <../remote_debugging/index>` to learn how to connect the developer tools to a remote target. + + +User Interface Tour +******************* + +To find your way around the Inspector, here's a :doc:`quick tour of the UI `. + +You can split the Rules view out into its own pane, separate from the other tabs on the CSS pane — this is called :doc:`3-pane mode <3-pane_mode/index>`. + + +How to +****** + +To find out what you can do with the Inspector, see the following how to guides: + +- :doc:`Open the Inspector ` +- :doc:`Examine and edit HTML ` +- :doc:`Examine and edit the box model ` +- :doc:`Inspect and select colors ` +- :doc:`Reposition elements in the page ` +- :doc:`Edit fonts ` +- :doc:`Visualize transforms ` +- :doc:`Select an element ` +- :doc:`Examine and edit CSS ` +- :doc:`Examine event listeners ` +- :doc:`Work with animations ` +- :doc:`Edit CSS filters ` +- :doc:`Edit CSS shapes ` +- :doc:`View background images ` +- :doc:`Use the Inspector from the Web Console ` +- :doc:`Examine CSS grid layouts ` +- :doc:`Examine CSS flexbox layouts ` +- :doc:`Use the Accessibility Inspector <../accessibility_inspector/index>` + + +Reference +********* + +- :ref:`Keyboard shortcuts ` +- :ref:`Settings ` diff --git a/devtools/docs/user/page_inspector/ui_tour/index.rst b/devtools/docs/user/page_inspector/ui_tour/index.rst new file mode 100644 index 000000000000..d40037ca9333 --- /dev/null +++ b/devtools/docs/user/page_inspector/ui_tour/index.rst @@ -0,0 +1,161 @@ +======= +UI Tour +======= + +This article is a quick tour of the main sections of the Page Inspector's user interface. + +It covers the three top-level components of the Inspector's UI: + +- the "Select element" button +- the HTML pane +- the CSS pane + + +.. image:: pageinspector.png + :alt: The all-new Inspector panel in Firefox 57. + +This guide is intentionally kept as short as possible. It links to various how to guides for the details of how to work with the Inspector. + + +.. _page_inspector_select_element_button: + +Select element button +********************* + +The Inspector gives you detailed information about the currently selected element. The Select element button is one way you can select an element for inspection: + +.. image:: select_element_button.png + :alt: This is the button in Firefox 57 Inspector you can use to select elements on a web page. + :class: center + +Note that it's actually part of the :ref:`main toolbox toolbar `, so it's immediately accessible from any tool, not just the Inspector. + +To learn how to select an element, see the guide to :doc:`selecting an element <../how_to/select_an_element/index>`. + + +.. _page_inspector_ui_tour_html_pane: + +HTML pane +********* + +The Inspector is split into two or three sections, depending on your settings. You can toggle the 3-pane view of the Inspector. The following image shows the 2-pane layout: + +.. image: inspector_2pane.png + :alt: These are the tasty new HTML and CSS panes in Firefox 57. + :class: border + + +In 2-pane mode, the Inspector includes the HTML Pane, and the CSS Pane, which can contain one of six tools: + +- Rules view +- Layout view +- Computed view +- Changes view +- Compatibility view (Firefox Developer Edition 77 and later) +- Fonts view +- Animations view + +The following image shows the 3-pane mode (available from Firefox 62 onwards) which moves the CSS Rules view into a separate pane in the center of the Inspector. The following image shows 3-pane mode: + +.. image:: inspector_tool.png + :class: border + +As you can see, the CSS pane has moved into the center of the Inspector. To learn more about the structure of the HTML pane, see the guide to :doc:`examining and editing HTML <../how_to/examine_and_edit_html/index>`. + + +.. _page_inspector_ui_tour_rules_view: + +Rules view +********** + +The Rules view lists all the rules that apply to the selected element, ordered from most-specific to least-specific. See above. + +.. image:: indpextor_rules.png + :alt: The rules view within the Inspector. + :class: border + +See :doc:`Examine and edit CSS <../how_to/examine_and_edit_css/index>` for more details. + + +Layout view +*********** + +The Layout view displays the box model of the page. If the page includes any sections using either the Flexbox display model or CSS Grids, this view shows the Flexbox or Grid settings used on the page. + +.. image: inspector_layout.png + :class: border + +To learn more about the Layout view, see :doc:`Examine and edit the box model <../how_to/examine_and_edit_the_box_model/index>`. Note that before Firefox 50, the box model view did not appear in the "Layout view" tab, but had its own tab. + + +Changes view +************ + +When you are editing in the Rules view, you can see the changes you have made in the Changes view. + +.. image:: track_changes.png + :class: border + +.. _page_inspector_ui_tour_computed_view: + +Computed view +************* + +The Computed view shows you the complete computed CSS for the selected element (The computed values are the same as what `getComputedStyle `_ would return): + +.. image:: inspector_computed.png + :alt: The Computed view within the Inspector + :class: border + +To learn more about the CSS declarations listed in this view, see :ref:`Examine computed CSS `. + + +.. _page_inspector_ui_tour_compatibility_view: + +Compatibility view +****************** + +Starting with Firefox Developer Edition version 77, the Compatibility view shows CSS compatibility issues, if any, for properties applied to the selected element, and for the current page as a whole. It shows icons for the browsers that *do* support the properties, and notes properties that are experimental or deprecated. + +.. image: compat_view.png + :alt: Screenshot of the Compatibility view + :class: center + + +- Click the name of the property to open the reference article for that property on *MDN Web Docs*. The "Browser compatibility" section of the article gives details of browser support for the property. + +- In the **All Issues** section, click the name of the element that uses the property to select that element in the inspector. If more than one element has a given property applied to it, click the triangle to show all the occurrences. + +- To configure the set of browsers you want the Compatibility view to check for, click **Settings** at the bottom of the panel. + +.. image:: compat_panel_settings.png + :alt: Screenshot of the Settings for the Compatibility view + + +Untick the checkbox for any browser you are not interested in. As new browser versions are released, the version numbers in this list will be updated. + + +Fonts view +********** + +The Fonts view shows all the fonts in the page along with editable samples. + +.. image:: inspector_fonts.png + :alt: The all-new Inspector panel in Firefox 57. + :class: border + +See :doc:`View fonts <../how_to/edit_fonts/index>` for more details. + + +.. _page_inspector_ui_tour_animations_view: + +Animations view +*************** + +The Animations view gives you details of any animations applied to the selected element, and a controller to pause them: + +.. image: animation_detail.png + :alt: This is the Animations pane in the Firefox 57 Inspector. + :class: border + +See :doc:`Work with animations <../how_to/work_with_animations/index>` for more details. diff --git a/devtools/docs/user/paint_flashing_tool/index.rst b/devtools/docs/user/paint_flashing_tool/index.rst new file mode 100644 index 000000000000..d9a497ab6a2d --- /dev/null +++ b/devtools/docs/user/paint_flashing_tool/index.rst @@ -0,0 +1,86 @@ +=================== +Paint Flashing Tool +=================== + +The paint flashing tool, when activated, highlights the part of a page that the browser needs to repaint in response to some input: for example, the user moving the mouse or scrolling. With the help of this tool you can figure out whether your website is causing the browser to repaint more than it needs to. Because repaints can be performance-intensive operations, eliminating unnecessary repaints can improve your website's responsiveness. + +Repaints and responsiveness +*************************** + +When the browser renders a web page it parses the HTML and CSS, determines how to lay it out, and then paints it to actually display the content on the screen. Whenever an event happens that might change a visible part of the web page then the browser must repaint some portion of the page. For example, a repaint will be needed if the user scrolls the page or moves the mouse pointer over an element with a `:hover `_ pseudo-class that changes the element's style. + +Repainting can be an expensive operation, so the browser tries to minimize the amount of repainting that it needs to do. It tries to work out which parts of the screen are "damaged" and repaint only those. The browser also splits its model of the page into layers that it expects will be updated independently of each other. Layers are painted independently and then composited, so a change in the appearance of one layer does not trigger a repaint in any other layers, and when only the relation of two layers changes (in an animation, for example) no repaints are required at all. + +The choices made by a web developer can hinder the browser here, causing it to trigger more repaints, and for more of the screen, than necessary. This can then cause a site to be slow responding to user input (also known as "janky"). That's where the paint flashing tool helps: by showing you the areas that the browser repaints in response to an event, you can see whether it is repainting more than it needs to. + +Using the paint flashing tool +***************************** + +Open the :doc:`Toolbox <../tools_toolbox/index>`, then click the icon labeled "Highlight painted area": + +.. image:: paint-flashing-open-from-toolbox.png + :class: border + +Then try using the page. After moving the mouse around and scrolling a bit, the above page looks like this: + +.. image:: paint-flashing-activated.png + :class: border + +- moving the mouse over links makes the browser repaint them, because they have a style applied using the `:hover `_ pseudo-class + +- scrolling makes the browser repaint the new part of the page coming into view at the bottom of the screen, and also the scrollbar at the top-right + +To deactivate paint flashing, click the "Highlight painted area" icon in the Toolbox again. + +Example: CSS transitions +************************ + +One area where implementation choices can affect repaint efficiency is in `CSS transitions `_. The example below shows two different ways to move an element using a CSS transition. The first way applies the transition to the element's `margin-left `_, while the second way moves the element using the `transform `_ property. + +.. code-block:: html + + +
+
Transition using margin-left
+
Transition using transform
+
+ + +.. code-block:: css + + #container { + border: 1px solid; + } + + .moving-box { + height: 20%; + width:20%; + margin: 2%; + padding: 2%; + background-color: blue; + color: white; + font-size: 24px; + } + + #moving-box-left-margin { + transition: margin-left 4s; + } + + #moving-box-transform { + transition: transform 4s; + } + + body:hover #moving-box-left-margin{ + margin-left: 74%; + } + + body:hover #moving-box-transform { + transform: translate(300%); + } + + +Now switch paint flashing on, and try it again. You should see that the ``margin-left`` version triggers a series of repaints as the element moves, while the ``transform`` version only causes repaints in the start and end positions. + +Why? Well, when you use ``transform``, the browser creates a separate layer for the element. So when the element is moved, all that's changed is the relation of the two layers to each other, which is handled in composition: neither layer needs a repaint. + +In this case, with a simple style, the extra repaints don't make much of a difference. But if the style were computationally expensive to paint, they might. It's difficult to know what optimizations the browser will make to minimize repaints, and they are subject to change from one version to the next. So testing your website with the paint flashing tool helps ensure that it's still performing optimally. diff --git a/devtools/docs/user/performance/allocations/index.rst b/devtools/docs/user/performance/allocations/index.rst new file mode 100644 index 000000000000..27b8295fc52e --- /dev/null +++ b/devtools/docs/user/performance/allocations/index.rst @@ -0,0 +1,90 @@ +=========== +Allocations +=========== + +The Allocations view in the Performance tool shows you which functions in your page are allocating the most memory over the course of the profile. + +For performance this is important mostly because allocating a lot of memory, or making a lot of allocations, can trigger :ref:`garbage collection `. This in turn can hurt the responsiveness of a page. + +The Allocations view is new in Firefox 46. + +To enable the Allocations view, you must check "Record Allocations" in the Performance tool settings, *before* recording a profile. Then :ref:`record a profile ` as usual, and you will see a new tab labeled "Allocations" in the toolbar: + + +.. raw:: html + + +
+
+ +Anatomy of the allocations view +******************************* + +The allocations view looks something like this: + +.. image:: allocations-view-1.png + :class: border + +The allocations view periodically samples allocations that are made over the recording. Each row represents a function in which at least one allocation-sample was taken during the recording. + +It includes the following columns: + + +- Self Count: the number of allocation-samples that were taken in this function (also shown as a percentage of the total) +- Self Bytes: the total number of bytes allocated in the allocation-samples in this function (also shown as a percentage of the total) + + +Rows are sorted by the "Self Bytes" column. + +So in the example above: + +- 8904 samples were taken in ``signalLater()``, which is 28.57% of the total number of samples taken +- those samples allocated 1102888 bytes, which is 30.01% of the total memory allocated in all samples + + +Next to each function name is a disclosure arrow. Click this to see the places this function was called from: + +.. image:: allocations-view-2.png + :class: center + +Here you can see that ``signalLater()`` was called from two places: ``removeInner()`` and ``setSelectionInner()``. In this way you can walk back up the call stack, and understand better the context for these allocations. + +Self Cost and Total Cost +------------------------ + +You'll see that there are separate sets of columns for "Self" and for "Total". "Self" records samples taken only in this function. "Total" records samples taken in this function or in functions called by this function. At the top level, these are always the same, since the view presents "leaf" functions at the top level (that is, it presents an inverted view of the call stack). But if you start walking back up the call stack, you'll see the difference: + +.. image:: allocations-view-2.png + :class: center + + +Here, 8904 samples were taken in ``signalLater()``. But ``signalLater()`` was called from two places: ``removeInner()`` and ``setSelectionInner()``. Both these functions have 0 in Self Count, meaning that no allocations were seen directly in these functions. However, ``removeInner()`` has 8901 in Total Count, while``setSelectionInner()`` has just 3 in Total Count. This is telling us that, of the 8904 allocations seen in ``signalLater()``, all but three came through the ``removeInner()`` branch. + +.. _performance-allocations-and-garbage-collection: + +Allocations and garbage collection +********************************** + +Of course, the memory allocated by a site is in itself useful information to know. But the main connection between the allocation profile of a site and its responsiveness is the cost of garbage collection (GC). + +With a garbage-collected language, like JavaScript, the runtime periodically needs to walk the heap looking for objects that are no longer :ref:`reachable `, and then freeing the memory they occupy. While GC events like this are executing, the JavaScript engine must be paused, so your program is suspended and will be completely unresponsive. + +To reduce the impact on responsiveness, `SpiderMonkey `_ (the JavaScript engine in Firefox) can perform GC in small increments, letting the program run in between. Sometimes, though, it needs to perform a full non-incremental collection, and the program has to wait for it to finish. + +GC events are shown as red markers in the :doc:`Waterfall <../waterfall/index>` view, and are a big red flag for responsiveness, sometimes running for hundreds of milliseconds: + +.. image:: allocations-view-long-gc.png + :class: center + +If you're seeing GC events in your site's performance profile, what can you do? SpiderMonkey uses a `complex set of heuristics `_ to decide when to do what sort of garbage collection. + +In general, though: *allocation pressure - allocating a lot of memory, or allocating memory at a high rate - makes SpiderMonkey more likely to run garbage collection, and more likely to run full, non-incremental garbage collection.* + +If a GC event was caused by allocation pressure, then the sidebar on the right of the marker in the Waterfall view contains a link labeled "Show allocation triggers". If you click this link, the devtools switches to the allocations view, and selects the region of time from the end of the last GC cycle to the start of the one you clicked on. This shows you all the allocations that collectively triggered this GC event. + +If you're seeing these problems, consider whether you can reduce the number or size of the allocations you're making here. For example: + + +- can you allocate memory lazily, when it is actually needed, instead of up front? +- if allocating memory in a loop, can you reuse a single allocation in every loop iteration? + diff --git a/devtools/docs/user/performance/call_tree/index.rst b/devtools/docs/user/performance/call_tree/index.rst new file mode 100644 index 000000000000..bcafd0320540 --- /dev/null +++ b/devtools/docs/user/performance/call_tree/index.rst @@ -0,0 +1,131 @@ +========= +Call Tree +========= + + +The Call Tree tells you which JavaScript functions the browser spent the most time in. By analyzing its results, you can find bottlenecks in your code - places where the browser is spending a disproportionately large amount of time. + +These bottlenecks are the places where any optimizations you can make will have the biggest impact. + + +The Call Tree is a sampling profiler. It periodically samples the state of the JavaScript engine and records the stack for the code executing at the time. Statistically, the number of samples taken in which we were executing a particular function corresponds to the amount of time the browser spent executing it. + +.. note:: + In this article, we'll use the output of a simple program as an example. If you want to get the program to experiment with your profile, you can find it `here `__. You can find the specific profile we discuss `here `__ - just import it to the performance tool to follow along. + + There's a short page describing the structure of this program `here `__. + + Note that we use the same program - the same profile, in fact - in the documentation page for the :doc:`Flame Chart <../flame_chart/index>`. + + +The screenshot below shows the output of a program that compares three sorting algorithms - bubble sort, selection sort, and quicksort. To do this, it generates some arrays filled with random integers and sorts them using each algorithm in turn. + +We've :ref:`zoomed ` into the part of the recording that shows a long JavaScript marker: + +.. image:: perf-call-tree.png + :class: center + +The Call Tree presents the results in a table. Each row represents a function in which at least one sample was taken, and the rows are ordered by the number of samples taken while in that function, highest to lowest. + +- *Samples* is the number of samples that were taken when we were executing this particular function, including its children (the other functions called by this particular function). + +- *Total Time* is that number translated into milliseconds, based on the total amount of time covered by the selected portion of the recording. These numbers should roughly be the same as the number of samples. + +- *Total Cost* is that number as a percentage of the total number of samples in the selected portion of the recording. + +- *Self Time* is calculated as the time spent in that particular function, excluding its children. This comes from the captured stacks where this function is the leafmost function. + +- *Self Cost* is calculated from *Self Time* as a percentage of the total number of samples in the selected portion of the recording. + +In the current version of the Call Tree, these are the most important columns. Functions with a relatively high *Self Cost* are good candidates for optimization, either because they take a long time to run, or because they are called very often. + +.. note:: + :ref:`The inverted call tree ` is a good way to focus on these *Self Cost* values. + + +This screenshot tells us something we probably already knew: Bubble sort is a very inefficient algorithm. We have about six times as many samples in bubble sort as in selection sort, and 13 times as many as in quicksort. + + +Walking up the call tree +************************ + +Next to each function name is a disclosure arrow: Click that, and you can see the path back up the call tree, from the function in which the sample was taken, to the root. For example, we can expand the entry for ``bubbleSort()``: + +.. image:: perf-call-tree-expanded-bubblesort.png + :class: center + +So we can see the call graph is like this: + +.. code-block:: JavaScript + + sortAll() + -> sort() + -> bubbleSort() + +Note also that *Self Cost* for ``sort()`` here is 1.45%, and note that this is the same as for the separate entry for ``sort()`` later in the list. This is telling us that some samples were taken in ``sort()`` itself, rather than in the functions it calls. + +Sometimes there's more than one path back from an entry to the top level. Let's expand the entry for ``swap()``: + +.. image:: perf-call-tree-expanded-sawp.png + :class: center + +There were 253 samples taken inside ``swap()``. But ``swap()`` was reached by two different paths: both ``bubbleSort()`` and ``selectionSort()`` use it. We can also see that 252 of the 253 samples in ``swap() ``were taken in the ``bubbleSort()`` branch, and only one in the ``selectionSort()`` branch. + +This result means that bubble sort is even less efficient than we had thought! It can shoulder the blame for another 252 samples, or almost another 10% of the total cost. + +With this kind of digging, we can figure out the whole call graph, with associated sample count: + +.. code-block:: JavaScript + + sortAll() // 8 + -> sort() // 37 + -> bubbleSort() // 1345 + -> swap() // 252 + -> selectionSort() // 190 + -> swap() // 1 + -> quickSort() // 103 + -> partition() // 12 + + +Platform data +************* + +You'll also see some rows labeled *Gecko*, *Input & Events*, and so on. These represent internal browser calls. + +This can be useful information too. If your site is making the browser work hard, this might not show up as samples recorded in your code, but it is still your problem. + +In our example, there are 679 samples assigned to *Gecko* - the second-largest group after ``bubbleSort()``. Let's expand that: + +.. image:: perf-call-tree-expanded-gecko.png + :class: center + +This result is telling us that 614 of those samples, or about 20% of the total cost, are coming from our ``sort()`` call. If we look at the code for ``sort()``, it should be fairly obvious that the high platform data cost is coming from repeated calls to ``console.log()``: + +.. code-block:: JavaScript + + function sort(unsorted) { + console.log(bubbleSort(unsorted)); + console.log(selectionSort(unsorted)); + console.log(quickSort(unsorted)); + } + +It would certainly be worthwhile considering more efficient ways of implementing this. + +One thing to be aware of here is that idle time is classified as *Gecko*, so parts of your profile where your JavaScript isn't running will contribute *Gecko* samples. These aren't relevant to the performance of your site. + +.. note:: + By default, the Call Tree doesn't split platform data out into separate functions, because they add a great deal of noise, and the details are not likely to be useful to people not working on Firefox. If you want to see the details, check "Show Gecko Platform Data" in the :ref:`Settings `. + + +.. _performance-call-tree-using_an_inverted_aka_bottom-up_call_tree: + +Using an inverted, aka Bottom-Up, Call Tree +******************************************* + +An inverted call tree reverses the order of all stacks, putting the leafmost function calls at the top. The direct consequence is that this is a view that focuses more on the function's *Self Time* information. This is a very useful view to find some hot spot in your code. + +To display this view, click the gear icon on the right-hand end of the performance tab and select **Invert Call Tree**. + +.. image:: performance_menu_invert_call_tree.png + :class: center + diff --git a/devtools/docs/user/performance/examples/index.rst b/devtools/docs/user/performance/examples/index.rst new file mode 100644 index 000000000000..71dd76c845cf --- /dev/null +++ b/devtools/docs/user/performance/examples/index.rst @@ -0,0 +1,7 @@ +======== +Examples +======== + +List of demo pages for performance scenarios and walkthroughs. + +- :doc:`Sorting algorithms comparison ` diff --git a/devtools/docs/user/performance/examples/sorting_algorithms_comparison/index.rst b/devtools/docs/user/performance/examples/sorting_algorithms_comparison/index.rst new file mode 100644 index 000000000000..e899710b2fbe --- /dev/null +++ b/devtools/docs/user/performance/examples/sorting_algorithms_comparison/index.rst @@ -0,0 +1,60 @@ +============================= +Sorting algorithms comparison +============================= + +This article describes a simple example program that we use in two of the Performance guides: the guide to the :doc:`Call Tree <../../call_tree/index>` and the guide to the :doc:`Flame Chart <../../flame_chart/index>`. + +This program compares the performance of three different sorting algorithms: + + +- bubble sort +- selection sort +- quicksort + + +It consists of the following functions: + +.. list-table:: + :widths: 30 70 + :header-rows: 0 + + * - :doc:`about:debugging ` + - Debug add-ons, content tabs, and workers running in the browser. + + * - **sortAll()** + - Top-level function. Iteratively (200 iterations) generates a randomized array and calls ``sort()``. + * - **sort()** + - Calls each of ``bubbleSort()``, ``selectionSort()``, ``quickSort()`` in turn and logs the result. + + * - **bubbleSort()** + - Implements a bubble sort, returning the sorted array. + + * - **selectionSort()** + - Implements a selection sort, returning the sorted array. + + * - **quickSort()** + - Implements quicksort, returning the sorted array. + + * - **swap()** + - Helper function for ``bubbleSort()`` and ``selectionSort()``. + + * - **partition()** + - Helper function for ``quickSort()``. + + +Its call graph looks like this: + +.. code-block:: JavaScript + + sortAll() // (generate random array, then call sort) x 200 + -> sort() // sort with each algorithm, log the result + -> bubbleSort() + -> swap() + -> selectionSort() + -> swap() + -> quickSort() + -> partition() + +The implementations of the sorting algorithms in the program are taken from https://github.com/nzakas/computer-science-in-javascript/ and are used under the MIT license. + +You can try out the example program `here `__ and clone the code `here `__ (be sure to check out the gh-pages branch). You can also `download the specific profile we discuss `__ - just import it to the Performance tool if you want to follow along. Of course, you can generate your own profile, too, but the numbers will be a little different. diff --git a/devtools/docs/user/performance/flame_chart/index.rst b/devtools/docs/user/performance/flame_chart/index.rst new file mode 100644 index 000000000000..5d40f7b3dcdd --- /dev/null +++ b/devtools/docs/user/performance/flame_chart/index.rst @@ -0,0 +1,100 @@ +=========== +Flame Chart +=========== + +The Flame Chart shows you the state of the JavaScript stack for your code at every millisecond during the performance profile. + +This gives you a way to know exactly which function was executing at any point during the recording, how long it ran for, and where it was called from. + +The Call Tree and the Flame Chart are both used to analyze your site's JavaScript, and they both use the same data: a sample of the JavaScript engine's stack, taken periodically during the recording. + +But while the Call Tree organizes this data to show you where your program is spending most time in aggregate across the recording, the Flame Chart uses it to show you when in the recording particular functions are executing. Essentially it shows you the state of the call stack at any given point during the recording. + +Here's a screenshot showing the Flame Chart for a section of a profile: + +.. image:: perf-flame-chart-overview.png + :class: center + + +First of all, you'll see that, in the :ref:`recording overview pane `, we've selected a small slice of the recording to view in the Flame Chart. The Flame Chart displays a lot of data, so to get readable results, it's usually necessary to zoom in. + +In the Flame Chart view itself, along the X-axis is time. The screenshot above covers the period from 1435ms to a little past 1465ms. Along the Y-axis are the functions on the call stack at that point in time, with the top-level at the top, and the leaf function at the bottom. Functions are color-coded to make them easier to distinguish. + +This gives you a way to know exactly which function was executing at any point during the recording, how long it ran for, and where it was called from. + + +Zooming and panning +******************* + +To work effectively with the Flame Chart, you'll need to be able to navigate it. There are two main controls you can use to navigate the Flame Chart: + +.. list-table:: + :widths: 50 50 + :header-rows: 0 + + * - **Zoom**: increase/decrease the selected portion of the complete profile that's displayed in the Flame Chart + - 1) Mouse wheel up/down in the Flame Chart. + 2) Trackpad 2 fingers up/down in the Flame Chart. + + * - **Pan**: move the selected portion of the complete profile left and right + + - 1) Click and drag the selected portion in the :ref:`recording overview pane `. + 2) Click and drag anywhere in the Flame Chart. + + +An example +********** + +To see how the Flame Chart can reveal the behavior of your program, we'll look at a simple example. We'll use the same example as in the :doc:`Call Tree <../call_tree/index>` page: a program that compares three different sorting algorithms. There's a :doc:`separate page <../examples/sorting_algorithms_comparison/index>` that gives an overview of this program's structure. + +We'll use the same profile file as that used in the Call Tree page. In the call tree page, we figured out that the program call graph in that profile, and the associated sample count, looked like this: + + +.. code-block:: JavaScript + + sortAll() // 8 + -> sort() // 37 + -> bubbleSort() // 1345 + -> swap() // 252 + -> selectionSort() // 190 + -> swap() // 1 + -> quickSort() // 103 + -> partition() // 12 + +First, we'll just select the whole section in which the program was active: + +.. image:: perf-flame-chart-zoomed-out.png + :class: center + +At the top, colored purple, is the ``sortAll()`` call, running throughout the program from start to finish. Underneath that, colored olive-green, are the calls it's making to ``sort()``. Underneath that, like the teeth of a comb, are all the calls being made to each sorting algorithm. + +Let's zoom in: + +.. image:: perf-flame-chart-zoom-1.png + :class: center + + +This slice is about 140 ms long, and shows us more details of the functions being called by ``sort()``. The ``sort()`` code is just this: + +.. code-block:: JavaScript + + function sort(unsorted) { + console.log(bubbleSort(unsorted)); + console.log(selectionSort(unsorted)); + console.log(quickSort(unsorted)); + } + + +The markers labeled "bubb..." and colored olive-green are presumably ``bubbleSort()``. The ones colored plain green are presumably the other sort functions. Even at a glance, we can see that the bubble sort blocks are much wider (of a longer duration) than the others. + +We can also see some functions being called from ``bubbleSort()``, colored purple. + +Let's zoom in one more time: + +.. image:: perf-flame-chart-zoom-2.png + :class: center + + +This slice is about 20ms long. We can see that the purple markers underneath ``bubbleSort()`` are the calls to ``swap()``. If you counted them all, the Call Tree view tells us that you'd see 253 of them. All the ones in this zoom are underneath ``bubbleSort()``, but according to the Call Tree view, the profile does contain one under ``selectionSort()``. + +We can also see that two of the green markers are for ``selectionSort()`` and ``quickSort()``, but we're also seeing calls to platform (Gecko) code in between our calls to the sorting functions. It seems very likely that this is from the ``console.log()`` calls in ``sort()``. diff --git a/devtools/docs/user/performance/frame_rate/index.rst b/devtools/docs/user/performance/frame_rate/index.rst new file mode 100644 index 000000000000..7dc5160c68c5 --- /dev/null +++ b/devtools/docs/user/performance/frame_rate/index.rst @@ -0,0 +1,65 @@ +========== +Frame rate +========== +Frame rate is a measure of awebsite's responsiveness. A low or inconsistent frame rate can make a site appear unresponsive or janky, making for a bad user experience. + +**A frame rate of 60fps is the target for smooth performance, giving you a time budget of 16.7ms for all the updates needed in response to some event.** + +The frame rate graph in the Performance tool shows you the frame rate over the course of a recording. It gives you a quick indication of where your site might be having problems, enabling you to use the other tools for a more in-depth analysis. + + +Frame rate and responsiveness +***************************** + +Frame rate is the rate at which a video device can produce images (or frames). It's most familiar from film and gaming, but is now widely used as a performance measure for websites and web apps. + +In web performance, a frame encapsulates the work the browser needs to do in order to update and repaint the screen. Frame rate is most obviously applicable to animations: if the frame rate is too low, an animation will have a jerky appearance, while a faster frame rate will be smoother. But frame rate is also useful as a general measure of a site's responsiveness as the user interacts with it. + +For example, if moving the mouse over some page element triggers some JavaScript that changes the element's appearance, and that triggers a reflow and a repaint, then all this work needs to be completed in that frame. If it takes too long for the browser to process the frame, then the browser will appear momentarily unresponsive (janky). + +Similarly, if scrolling through a page involves a lot of complex page updates and the browser can't keep up an acceptable frame rate, scrolling the page will appear sluggish or will occasionally freeze. + +In general, a high and consistent frame rate will make the user's interaction with the site more enjoyable and engaging. + +.. note:: + A frame rate of 60fps is reckoned to be the target for smooth performance, giving you a time budget of 16.7ms for all the updates that need to be made synchronously in response to some event. + + However, consistency is especially important: if you can't deliver 60fps, it's better to deliver lower frame rates more consistently, and avoid sudden dips in the frame rate which cause the site to freeze. + + +Frame rate graph +**************** + +The frame rate graph is found in the :ref:`Recording overview ` part of the Performance tool. It takes a timestamp when the browser finishes a frame, and uses this to keep track of the frame rate over the course of the recording. + +.. image:: perf-frame-rate.png + :class: center + +The x-axis is time over the profile period, and there are three annotations: the maximum frame rate, the average frame rate, and the lowest frame rate. + +Using the frame rate graph +************************** + +The great value of the frame rate graph is that, like the :doc:`Web Console <../../web_console/index>`, it gives you a quick indication of where your site might be having problems, enabling you to use the other tools for more in-depth analysis. For example, here's a screenshot of a performance profile: + +.. image:: perf-fr-waterfall.png + :class: center + +You can see that the average frame rate is reasonably healthy, but there are three spots where frame rate collapses for tens of milliseconds. This would certainly cause a noticeable stutter for any animations that were playing in the page. + +The frame rate graph is correlated with the :ref:`waterfall summary ` directly above it, and there we can see that the first two drops in the frame rate are correlated with orange bars, which denote time spent executing JavaScript. + +If we select one of these slices of the recording, the main :doc:`Waterfall view <../waterfall/index>` underneath it is zoomed into it, and we can see the function that's causing the problem: + +.. image:: perf-zoom.png + :class: center + +We have a JavaScript function from a click event that's blocking the main thread for 170 milliseconds. + +Which function, though? Switch to the :doc:`Flame Chart <../flame_chart/index>` to see the call stack at that point: + +.. image:: perf-fr-flame-chart.png + :class: center + + +The offending function is called ``doPointlessComputations()``, and it's defined in "main.js". To fix it, we might consider splitting it into pieces and running the pieces inside `requestAnimationFrame `_, or even running the entire function in a `worker `_. The :doc:`Intensive JavaScript <../scenarios/intensive_javascript/index>` article shows how you can use strategies like this to fix responsiveness problems caused by long-running synchronous JavaScript. diff --git a/devtools/docs/user/performance/how_to/index.rst b/devtools/docs/user/performance/how_to/index.rst new file mode 100644 index 000000000000..a9f34d5ec3c6 --- /dev/null +++ b/devtools/docs/user/performance/how_to/index.rst @@ -0,0 +1,85 @@ +====== +How to +====== + +Open the Performance tools +************************** + +To open the Performance tools: + +- press :kbd:`Shift` + :kbd:`F5` +- select "Performance" from the Web Developer submenu in the Firefox Menu (or Tools menu if you display the menu bar or are on OSX) +- select "Performance" from Tools button, in the Toolbar, if you have one: + +.. image:: devtools-button.png + :class: center + +.. _performance-how-to-record-a-profile: + +Record a profile +**************** + +To start a new recording, press the stopwatch icon in the Recordings pane. To stop, press it again: + +.. image:: perf-record.png + :class: center + + +You can also start and stop recording from the Web Console, using `console.profile() `_ and `console.profileEnd() `_. + +Save a profile +************** + +To save a profile, click the link labeled "Save" in the Recordings pane: + +.. image:: perf-save.png + :class: center + + +Load a profile +************** + +To load a profile, click "Import..." and choose the file: + +.. image:: perf-load.png + :class: center + + +Clear all loaded profiles +************************* + +To clear all loaded profiles, click "Clear". + +.. note:: + + If you do this, you'll lose any loaded profiles that you have not saved. + +.. image:: perf-clear.png + :class: center + + +Select a tool +************* + +To switch between the :doc:`Waterfall <../waterfall/index>`, :doc:`Call Tree <../call_tree/index>`, and :doc:`Flame Chart <../flame_chart/index>` tools, use the buttons in the toolbar: + +.. image:: perf-select.png + :class: center + + +Configure markers displayed +*************************** + +To control which markers are shown in the :doc:`Waterfall <../waterfall/index>`, use the button in the toolbar: + +.. image:: perf-markers.png + :class: center + + +Zoom in +******* + +To zoom into a slice of the recording, select that slice in the recording overview: + +.. image:: perf-zoom.png + :class: center diff --git a/devtools/docs/user/performance/index.rst b/devtools/docs/user/performance/index.rst new file mode 100644 index 000000000000..900e44d27e38 --- /dev/null +++ b/devtools/docs/user/performance/index.rst @@ -0,0 +1,50 @@ +=========== +Performance +=========== + +The Performance tool gives you insight into your site's general responsiveness, JavaScript and layout performance. With the Performance tool you create a recording, or profile, of your site over a period of time. The tool then shows you an :ref:`overview ` of the things the browser was doing to render your site over the profile, and a graph of the :doc:`frame rate ` over the profile. + +You get four sub-tools to examine aspects of the profile in more detail: + + +- the :doc:`Waterfall ` shows the different operations the browser was performing, such as executing layout, JavaScript, repaints, and garbage collection +- the :doc:`Call Tree ` shows the JavaScript functions in which the browser spent most of its time +- the :doc:`Flame Chart ` shows the JavaScript call stack over the course of the recording +- the :doc:`Allocations ` view shows the heap allocations made by your code over the course of the recording. This view only appears if you checked "Record Allocations" in the Performance tool settings. + +.. raw:: html + + +
+
+ +Getting started +*************** + +:doc:`UI Tour ` + To find your way around the Performance tool, here's a quick tour of the UI. + +:doc:`How to ` + Basic tasks: open the tool, create, save, load, and configure recordings + +Components of the Performance tool +********************************** + +:doc:`Frame rate ` + Understand your site's overall responsiveness. +:doc:`Call Tree ` + Find bottlenecks in your site's JavaScript. +:doc:`Allocations ` + See the allocations made by your code over the course of the recording. +:doc:`Waterfall ` + Understand the work the browser's doing as the user interacts with your site. +:doc:`Flame Chart ` + See which JavaScript functions are executing, and when, over the course of the recording. + +Scenarios +********* + +:doc:`Animating CSS properties ` + Uses the Waterfall to understand how the browser updates a page, and how animating different CSS properties can affect performance. +:doc:`Intensive JavaScript ` + Uses the frame rate and Waterfall tools to highlight performance problems caused by long-running JavaScript, and how using workers can help in this situation. diff --git a/devtools/docs/user/performance/scenarios/animating_css_properties/index.rst b/devtools/docs/user/performance/scenarios/animating_css_properties/index.rst new file mode 100644 index 000000000000..be11f731e64c --- /dev/null +++ b/devtools/docs/user/performance/scenarios/animating_css_properties/index.rst @@ -0,0 +1,182 @@ +======================== +Animating CSS properties +======================== +The performance cost of animating a CSS property can vary from one property to another, and animating expensive CSS properties can result in `jank `_ as the browser struggles to hit a smooth frame rate. + +The :doc:`Frame rate <../../frame_rate/index>` and :doc:`Waterfall <../../waterfall/index>` can give you insight into the work the browser's doing in a CSS animation, to help diagnose performance problems. + +With `CSS animations `_ you specify a number of `keyframes `_, each of which uses CSS to define the appearance of the element at a particular stage of the animation. The browser creates the animation as a transition from each keyframe to the next. + +Compared with animating elements using JavaScript, CSS animations can be easier to create. They can also give better performance, as they give the browser more control over when to render frames, and to drop frames if necessary. + +However, the performance cost of modifying a CSS property can vary from one property to another. Animating expensive CSS properties can result in `jank `_ as the browser struggles to hit a smooth frame rate. + + +.. _performance-scenarios-animating_css_properties-rendering-waterfall: + +The CSS rendering waterfall +*************************** + +The process the browser uses to update the page when a CSS property has changed can be described as a waterfall consisting of the following steps: + +.. image:: css-rendering-waterfall.png + :class: center + + +- **Recalculate Style**: every time a CSS property for an element changes, the browser must recalculate computed styles. +- **Layout**: next, the browser uses the computed styles to figure out the position and geometry for the elements. This operation is labeled "layout" but is also sometimes called "reflow". +- **Paint**: finally, the browser needs to repaint the elements to the screen. One last step is not shown in this sequence: the page may be split into layers, which are painted independently and then combined in a process called "Composition". + + +This sequence needs to fit into a single frame, since the screen isn't updated until it is complete. It's commonly accepted that 60 frames per second is the rate at which animations will appear smooth. For a rate of 60 frames per second, that gives the browser 16.7 milliseconds to execute the complete flow. + + +.. _performance-scenarios-animating_css_properties-css-property-cost: + +CSS property cost +***************** + +In the context of the rendering waterfall, some properties are more expensive than others: + +.. |br| raw:: html + +
+ +.. list-table:: + :widths: 60 20 20 + :header-rows: 1 + + * - Property type + - Cost + - Examples + + * - Properties that affect an element's *geometry* or *position* trigger a style recalculation, a layout and a repaint. + - .. image:: recalculate-style.png + .. image:: layout.png + .. image:: paint.png + - `left `_ |br| + `max-width `_ |br| + `border-width `_ |br| + `margin-left `_ |br| + `font-size `_ + + * - Properties that don't affect geometry or position, but are not rendered in their own layer, do not trigger a layout. + - .. image:: recalculate-style.png + .. image:: layout-faint.png + .. image:: paint.png + - `color `_ + + * - Properties that are rendered in their own layer don't even trigger a repaint, because the update is handled in composition. + - .. image:: recalculate-style.png + .. image:: layout-faint.png + .. image:: paint-faint.png + - `transform `_ |br| + `opacity `_ + +.. note:: + + The `CSS Triggers `_ website shows how much of the waterfall is triggered for each CSS property, with information for most CSS properties by browser engine. + + +An example: margin versus transform +*********************************** + +In this section we'll see how the :doc:`Waterfall ` can highlight the difference between animating using `margin `_ and animating using `transform `_. + +The intention of this scenario isn't to convince you that animating using ``margin`` is always a bad idea. It's to demonstrate how the tools can give you insight into the work the browser is doing to render your site, and how you can apply that insight to diagnose and fix performance problems. + +If you want to play along, the demo website is `here `_. It looks like this: + +.. image:: css-animations-demo.png + :class: center + +It has two controls: a button to start/stop the animation, and a radio group to choose to animate using ``margin``, or to animate using ``transform``. + +There are a number of elements, and we've added a `linear-gradient `_ background and a `box-shadow `_ to each element, because they are both relatively expensive effects to paint. + + +Animating using margin +---------------------- + +Leaving the "Use margin" option set, start the animation, open the Performance tool, and make a recording. You'll only need to record a few seconds. + +Open up the first recording. Exactly what you'll see depends a lot on your machine and system load, but it will be something like this: + +.. image:: margin-recording.png + :class: center + +This is showing three distinct views: (a) an overview of the Waterfall, (b) the frame rate, and (c) the timeline details. + +.. _performance-scenarios-animation-css-properties-margin-waterfall-overview: + +Waterfall overview +~~~~~~~~~~~~~~~~~~ + +.. image:: margin-timeline-overview.png + :class: center + +This is showing a compressed view of the :doc:`Waterfall <../../waterfall/index>`. The predominance of green is telling us that :ref:`we're spending a lot of time painting `. + +.. _performance-scenarios-animation-css-properties-margin-frame-rate: + +Frame rate +~~~~~~~~~~ + +.. image:: margin-frame-rate.png + :class: center + + +This is showing :doc:`frame rate <../../frame_rate/index>`. Average frame rate here is 46.67fps, well below the target of 60fps. Worse, though, is that the frame rate is very jagged, with lots of dips into the twenties and teens. It's unlikely you'll see a smooth animation here, especially when you add in user interaction. + +.. _performance-scenarios-animation-css-properties-margin-waterfall: + +Waterfall +~~~~~~~~~ + +The rest of the recording shows the Waterfall view. If you scroll through this, you'll see a pattern like this: + +.. image:: margin-timeline.png + :class: center + + +This is showing us the :ref:`rendering waterfall `. In each animation frame, we recalculate styles for every element, then perform a single layout, then a repaint. + +You can see that paint especially is hurting performance here. In the screenshot above we've highlighted a paint operation, and the box on the right tells us it took 13.11ms. With only 16.7ms in our total budget, it's not surprising we are missing a consistently high frame rate. + +You can experiment with this: try removing the box shadow :doc:`using the Page Inspector <../../../page_inspector/how_to/examine_and_edit_css/index>`, and see how that affects paint time. But next, we'll see how using `transform `_ instead of `margin `_ eliminates those expensive paints entirely. + + +Animating using transform +------------------------- + +Now switch the radio button in the web page to "Use transform", and make a new recording. It will look something like this: + +.. image:: transform-recording.png + :class: center + + +Waterfall overview +~~~~~~~~~~~~~~~~~~ + +.. image:: transform-timeline-overview.png + :class: center + +Compared with :ref:`the version that uses margin `, we're seeing a lot less green and a lot more pink, which :ref:`could be either layout or style recalculation `. + +Frame rate +~~~~~~~~~~ + +.. image:: transform-frame-rate.png + :class: center + +Compared with :ref:`the version that uses margin `, this is looking pretty good. We're averaging nearly 60fps, and apart from one dip near the start, we're getting a consistently high frame rate. + +Waterfall +~~~~~~~~~ + +The timeline view shows the reason for the improved frame rate. Compared with :ref:`the version that uses margin `, we're not spending any time in layout or (more importantly in this case) in paint: + +.. image:: transform-timeline.png + :class: center + +In this case, using ``transform`` significantly improved the site's performance, and the performance tools were able to show how and why it did. diff --git a/devtools/docs/user/performance/scenarios/index.rst b/devtools/docs/user/performance/scenarios/index.rst new file mode 100644 index 000000000000..a69dd11face3 --- /dev/null +++ b/devtools/docs/user/performance/scenarios/index.rst @@ -0,0 +1,5 @@ +========= +Scenarios +========= + +Performance scenarios diff --git a/devtools/docs/user/performance/scenarios/intensive_javascript/index.rst b/devtools/docs/user/performance/scenarios/intensive_javascript/index.rst new file mode 100644 index 000000000000..0b678b1cbc10 --- /dev/null +++ b/devtools/docs/user/performance/scenarios/intensive_javascript/index.rst @@ -0,0 +1,245 @@ +==================== +Intensive JavaScript +==================== + +By default the browser uses a single thread to run all the JavaScript in your page as well as to perform layout, reflows, and garbage collection. This means that long-running JavaScript functions can block the thread, leading to an unresponsive page and a bad user experience. + +You can use the :doc:`Frame rate <../../frame_rate/index>` and :doc:`Waterfall <../../waterfall/index>` tools to see when JavaScript is causing performance problems, and to single out the particular functions that need attention. + +In this article we'll take an example site whose long-running JavaScript causes responsiveness problems, and apply two different approaches to fixing them. The first is to split long-running functions into pieces and use `requestAnimationFrame `_ to schedule each piece, and the second is to run the whole function in a separate thread using a `web worker `_. + +If you want to play along you can find the demo website `here `_. + + +The demo website looks like this: + +.. image:: js-worker-demo.png + :class: center + +It has three controls: + +- a radio button group to control how to run the JavaScript: as a single blocking operation in the main thread, as a series of smaller operations in the main thread using ``requestAnimationFrame()``, or in another thread using a worker. +- a button to run the JavaScript, labeled "Do pointless computations!". +- a button to start and stop some CSS animations. This just gives the browser some background tasks to perform. + + +Leaving the radio button set to "Use blocking call in main thread", make a recording: + + +- press the "Start animations" button +- start recording a performance profile +- press "Do pointless computations!" two or three times +- stop recording the profile + +.. _performance-scenarios-intensive-javascript-js-blocking-overview: + +Exactly what you see will vary from one machine to another, but it will be something like this: + +.. image:: perf-js-blocking-overview.png + :class: center + +The top half of this is the :ref:`waterfall overview `. It gives us a compressed view of the :doc:`Waterfall <../../waterfall/index>`, which tells us what kinds of operations the browser is doing during the recording. :ref:`The pink says that we are mostly performing CSS calculations and possibly reflow `: this is the CSS animation that's running throughout the profile. Then there are three solid blocks of orange, representing JavaScript execution, one for each time we pressed the button. + +The bottom half, which is correlated with the timeline summary in time, shows :doc:`frame rate <../../frame_rate/index>`. We can see that frame rate is pretty healthy for most of the recording, but collapses completely whenever we press the button. + +We can select one of these periods and have a closer look at it in the main Waterfall view: + +.. image:: perf-js-blocking-waterfall.png + :class: center + +Here, when we pressed the button, the browser ran a JavaScript function, or series of functions, that blocked the main thread for 71.73ms, or more than four times our frame budget. + +Which function, though? By switching to the :doc:`Flame Chart <../../flame_chart/index>` view we can find out: + +.. image:: perf-js-blocking-flame-chart.png + :class: center + +This shows us the JS call stack at this point in the execution. At the top of the stack is a function called ``calculatePrimes()``, and we can see its filename and line number. Here's the code, together with its immediate caller: + +.. code-block:: JavaScript + + const iterations = 50; + const multiplier = 1000000000; + + function calculatePrimes(iterations, multiplier) { + var primes = []; + for (var i = 0; i < iterations; i++) { + var candidate = i * (multiplier * Math.random()); + var isPrime = true; + for (var c = 2; c <= Math.sqrt(candidate); ++c) { + if (candidate % c === 0) { + // not prime + isPrime = false; + break; + } + } + if (isPrime) { + primes.push(candidate); + } + } + return primes; + } + + function doPointlessComputationsWithBlocking() { + var primes = calculatePrimes(iterations, multiplier); + pointlessComputationsButton.disabled = false; + console.log(primes); + } + + +We're just running a (very inefficient) primality test 50 times, for some quite large numbers. + +Using requestAnimationFrame +*************************** + +In the first attempt at fixing this, we'll split up the function into a number of much smaller self-contained functions, and schedule each one using `requestAnimationFrame() `_. + +``requestAnimationFrame()`` tells the browser to run the given function in each frame, just before it performs a repaint. As long as each function is reasonably small, the browser should be able to keep inside its frame budget. + +It's pretty simple to split up ``calculatePrimes()``: we will just calculate primality for each number in a separate function: + +.. code-block:: javascript + + function doPointlessComputationsWithRequestAnimationFrame() { + + function testCandidate(index) { + // finishing condition + if (index == iterations) { + console.log(primes); + pointlessComputationsButton.disabled = false; + return; + } + // test this number + var candidate = index * (multiplier * Math.random()); + var isPrime = true; + for (var c = 2; c <= Math.sqrt(candidate); ++c) { + if (candidate % c === 0) { + // not prime + isPrime = false; + break; + } + } + if (isPrime) { + primes.push(candidate); + } + // schedule the next + var testFunction = testCandidate.bind(this, index + 1); + window.requestAnimationFrame(testFunction); + } + + var primes = []; + var testFunction = testCandidate.bind(this, 0); + window.requestAnimationFrame(testFunction); + } + +Let's test this version out: select the radio button labeled "Use requestAnimationFrame" and capture another profile. This time, the recording should look something like this: + +.. image:: perf-js-raf-overview.png + :class: center + + +This is exactly what we might have expected to see. Instead of :ref:`a single solid orange block `, each button-press shows up as a long sequence of very short orange blocks. The orange blocks appear one frame apart, and each one represents one of the functions called from ``requestAnimationFrame()``. Note that there are only two button-presses in this profile. + +The function calls are interleaved with the pink blocks from the CSS animation, and each function is short enough that the browser can handle it without the overall frame rate dropping. + +Using ``requestAnimationFrame`` worked to solve the responsiveness problem here, but there are a couple of potential problems with it: + + +- it can be difficult to split up a long-running function into separate self-contained functions. Even this very simple case produced more complex code. +- the split-up version takes much longer to run. In fact we can be quite precise about how long it takes: there are 50 iterations, and the browser is producing about 60 frames per second. So it will take almost a second to run all the computations, and that's visible in both the user experience and in the profile. + + +Using web workers +***************** + +In this version we'll try to fix the problem using a web worker. Web workers enable you to run JavaScript in a separate thread. The main thread and the worker thread can't call each other directly, but communicate using an asynchronous messaging API. + +The main thread code would look something like this: + +.. code-block:: javascript + + const iterations = 50; + const multiplier = 1000000000; + + var worker = new Worker("js/calculate.js"); + + function doPointlessComputationsInWorker() { + + function handleWorkerCompletion(message) { + if (message.data.command == "done") { + pointlessComputationsButton.disabled = false; + console.log(message.data.primes); + worker.removeEventListener("message", handleWorkerCompletion); + } + } + + worker.addEventListener("message", handleWorkerCompletion, false); + + worker.postMessage({ + "multiplier": multiplier, + "iterations": iterations + }); + } + +The main difference here, compared with the original, is that we need to: + + +- create a worker +- send it a message when we are ready to calculate +- listen for a message called "done", which indicates that the worker has finished. + + +Then we need a new file "calculate.js", that looks like this: + +.. code-block:: javascript + + self.addEventListener("message", go); + + function go(message) { + var iterations = message.data.iterations; + var multiplier = message.data.multiplier; + primes = calculatePrimes(iterations, multiplier); + + self.postMessage({ + "command":"done", + "primes": primes + }); + } + + function calculatePrimes(iterations, multiplier) { + var primes = []; + for (var i = 0; i < iterations; i++) { + var candidate = i * (multiplier * Math.random()); + var isPrime = true; + for (var c = 2; c <= Math.sqrt(candidate); ++c) { + if (candidate % c === 0) { + // not prime + isPrime = false; + break; + } + } + if (isPrime) { + primes.push(candidate); + } + } + return primes; + } + +In the worker, we have to listen for a message telling us to start, and send a "done" message back when we are done. The code that actually performs the computations is exactly the same as the original code. + +So how does this version perform? Switch the radio button to "Use a worker", and capture a new profile. You should see something like this: + +.. image:: perf-js-worker-overview.png + :class: center + + +In this profile we pushed the button three times. :ref:`Compared with the original `, each button-press is visible in the overview as two very short orange markers: + + +- the ``doPointlessComputationsInWorker()`` function that handles the click event and starts the worker's processing +- the ``handleWorkerCompletion()`` function that runs when the worker calls "done". + + +In between, the worker runs all the primality tests, and it doesn't seem to have any effect at all on the responsiveness of the main thread. This might seem unlikely, but because workers run in a separate thread, they can take advantage of multi-core processors, which a single-threaded web site can't. + +The main limitation of web workers is that DOM APIs are not available to code running in a worker. diff --git a/devtools/docs/user/performance/ui_tour/index.rst b/devtools/docs/user/performance/ui_tour/index.rst new file mode 100644 index 000000000000..54b97d42b7d5 --- /dev/null +++ b/devtools/docs/user/performance/ui_tour/index.rst @@ -0,0 +1,179 @@ +======= +UI Tour +======= + +The performance tool's UI consists of 4 main pieces: + +.. image:: perf-tool-pieces.png + :class: center + + +- :ref:`Toolbar ` +- :ref:`Recordings pane ` +- :ref:`Recording overview ` +- :ref:`Details pane ` + + - :ref:`Waterfall ` + - :ref:`Call Tree ` + - :ref:`Flame Chart ` + + +.. _performance-ui-tour-toolbar: + +Toolbar +******* + +The toolbar contains buttons to: + + +- start and stop a recording +- import a recording you previously saved +- clear the Recordings pane. *Note that if you do this, you lose any recordings you have not saved.* +- filter the :ref:`markers ` that are displayed in the Waterfall view +- switch the active tool in the :ref:`Details pane ` +- access the Settings popup + +.. image:: perf-toolbar.png + :class: center + + +.. _performance-ui-tour-recordings-pane: + +Recordings pane +*************** + +The recordings pane lists all the recordings you have loaded, including any you have made in this session and any you have imported. + +.. image:: perf-recordings-pane.png + :class: center + + +At any given time, one recording is selected, and that recording is displayed in the rest of the tool. To select a different recording, click its entry in the pane. To save the recording as a JSON file click "Save". + + +.. _performance-ui-tour-recording-overview: + +Recording overview +****************** + +This displays an overview of the entire recording, with the x-axis representing time. + +.. image:: perf-overview.png + :class: center + + +It contains two elements: an overview of the Waterfall and a frame rate graph. + + +.. _performance-ui-tour-waterfall-overview: + +Waterfall overview +------------------ + +This presents a compressed view of the :doc:`Waterfall <../waterfall/index>`: + +.. image:: perf-waterfall-overview.png + :class: center + + +Recorded operations are color-coded using :ref:`the same scheme as in the main Waterfall view `. + + +Frame rate graph +---------------- + +The frame rate gives you an overview of the browser's responsiveness during the recording: + +.. image:: perf-frame-rate.png + :class: center + + +See the separate article on :doc:`frame rate <../frame_rate/index>`. + + +Correlating events +------------------ + +Because these elements are synchronized, you can correlate events in one element with events in another. + +For example, in the screenshot below a long-running paint operation (:ref:`shown as a green bar ` in the waterfall overview) corresponds to a drop in the frame rate: + +.. image:: perf-overview-correlation.png + :class: center + + +.. _performance-ui-tour-zooming-in: + +Zooming in +---------- + +You can use the overview to select a slice of the recording to examine in more detail. Select a slice, and the main view will be updated to contain just the part selected. In the screenshot below we've selected that drop in the frame rate, and can see the long-running paint operation in more detail: + +.. image:: perf-zoomed.png + :class: center + + +.. _performance-ui-tour-details-pane: + + +Details pane +************ + +The Details pane shows whichever tool is currently selected. To switch to a different tool, use the buttons in the :ref:`Toolbar `. + + +.. _performance-ui-tour-waterfall: + +Waterfall +--------- + +The Waterfall presents a view of the work the browser is doing during the recording: executing JavaScript, updating the CSS, updating the page layout, and performing repaints. The x-axis represents time, and the recorded operations are laid out as a waterfall, reflecting the serial nature of the browser's execution. + +.. image:: perf-waterfall.png + :class: center + + +To learn much more about the Waterfall, see the separate :doc:`Waterfall <../waterfall/index>` page. + + +.. _performance-ui-tour-call-tree: + +Call Tree +--------- + +The Call Tree is a sampling profiler for JavaScript running in the page. It periodically samples the state of the JavaScript engine, and records the stack for the code executing at the time the sample was taken. Statistically, the number of samples taken in which we were executing a particular function corresponds to the amount of time the browser is spending executing it, so you can identify bottlenecks in your code. + +.. image:: perf-call-tree.png + :class: center + + +To learn much more about the Call Tree, see the separate :doc:`Call Tree <../call_tree/index>` page. + + +.. _performance-ui-tour-flame-chart: + +Flame Chart +----------- + +If the Call Tree tells you, statistically, which functions your site is spending most time executing across the whole recording, the Flame Chart tells you the call stack at any given point during the recording: + +.. image:: perf-flame-chart.png + :class: center + + +To learn much more about the Flame Chart, see the separate :doc:`Flame Chart <../flame_chart/index>` page. + + +Allocations +----------- + +The Allocations view is new in Firefox 46. + +The Allocations view is like the Call Tree view, but for allocations: it shows you which functions in your page are allocating the most memory over the course of the profile. + +.. image:: allocations-view-1.png + :class: center + +The Allocations view only appears if you checked "Record Allocations" in the Performance tool settings, before recording a profile + +To learn much more about the Allocations view, see the separate :doc:`Allocations <../allocations/index>` page. diff --git a/devtools/docs/user/performance/waterfall/index.rst b/devtools/docs/user/performance/waterfall/index.rst new file mode 100644 index 000000000000..1a85a968bbc4 --- /dev/null +++ b/devtools/docs/user/performance/waterfall/index.rst @@ -0,0 +1,395 @@ +========= +Waterfall +========= + +The Waterfall gives you insight into the sorts of things the browser is doing as it runs your site or app. It's based on the idea that the things a browser does when running a site can be divided into various types - running JavaScript, updating layout, and so on - and that at any given point in time, the browser is doing one of those things. + +So if you see a sign of a performance problem - a drop in the frame rate, for example - you can go to the Waterfall to see what the browser was doing at that point in the recording. + +.. image:: perf-waterfall.png + :class: center + +Along the X-axis is time. Recorded operations, called markers, are shown as horizontal bars, laid out in a waterfall to reflect the serial nature of the browser's execution. + +When a marker is selected you'll see more information about it in a sidebar on the right.This includes the marker's duration and some more information that's specific to the :ref:`marker type `. + + +.. _performance-waterfall-markers: + +Markers +******* + +The markers for operations are color-coded and labeled. The following operations are recorded: + +.. |br| raw:: html + +
+ +.. list-table:: + :widths: 40 20 40 + :header-rows: 1 + + * - Name and description + - Color + - Detailed Information + + * - **DOM Event** |br| |br| + JavaScript code that's executed in response to a DOM event. + - .. image:: orange.png + - **Event Type** + For example, "click" or "message". + **Event Phase** + For example, "Target" or "Capture". + + * - JavaScript functions executed in the page are labeled with the reason the function was called: |br| |br| + **Script Tag** |br| + **setInterval** |br| + **setTimeout** |br| + **requestAnimationFrame** |br| + **Promise Callback** |br| + **Promise Init** |br| + **Worker** |br| + **JavaScript URI** |br| + **Event Handler** |br| + - .. image:: orange.png + - **Stack** + Call stack, with links to functions. + + * - **Parse HTML** |br| |br| + Time spent parsing the page's HTML. + - .. image:: orange.png + - **Stack** + Call stack, with links to functions. + + * - **Parse XML** |br| |br| + Time spent parsing the page's XML. + - .. image:: orange.png + - **Stack** + Call stack, with links to functions. + + * - **Recalculate Style** |br| |br| + Calculating the computed styles that apply to page elements. + - .. image:: purple.png + - **Restyle Hint** |br| |br| + A string indicating what kind of restyling is needed. The hint may be any of: + + - Self + - Subtree + - LaterSiblings + - CSSTransitions + - CSSAnimations + - SVGAttrAnimations + - StyleAttribute + - StyleAttribute_Animations + - Force + - ForceDescendants + + * - **Layout** |br| |br| + Calculating the position and size of page elements. This operation is sometimes called "reflow". + - .. image:: purple.png + - + + * - **Paint** |br| |br| + Drawing pixels to the screen. + - .. image:: green.png + - + + * - **Garbage Collection** |br| |br| + :ref:`Garbage collection event `. Non-incremental GC events are labeled "(Non-incremental)". + - .. image:: red.png + - **Reason** + A string indicating the reason GC was performed. + |br| + **Non-incremental Reason** + If the GC event was non-incremental, the string indicates the reason non-incremental GC was performed. + + New in Firefox 46: if the GC event was caused by allocation pressure, a link appears, labeled "Show Allocation Triggers". Click the link to see the allocation profile leading up to this GC event. |br| |br| + + See :ref:`Allocations and Garbage Collection ` for more details. + + * - **Cycle Collection** |br| |br| + Reclaiming C++ reference-counted data structures. |br| |br| + Like garbage collection, but for C++ objects. See `Kyle Huey's blog post about cycle collection `_. + - .. image:: red.png + - **Type** + Always "Collect". + + * - **CC Graph Reduction** |br| |br| + Preparation/pre-optimization for Cycle Collection. + - .. image:: red.png + - **Type** + Always "ForgetSkippable". + + * - **Console** |br| |br| + The period between matching calls to ``console.time()`` and ``console.timeEnd()``. + - .. image:: gray.png + - **Timer name** + The argument passed to the ``console`` functions. + **Stack at start** + Call stack ``console.time()``, with links to functions. + **Stack at End** + (New in Firefox 41). Call stack at ``console.timeEnd()``. If this is inside a callback from a `Promise `_, this will also show the :ref:`Async stack `. + + * - **Timestamp** |br| |br| + A single call to `console.timeStamp() `_. + - .. image:: blue.png + - **Label** + The argument passed to ``timeStamp()``. + + * - **DOMContentLoaded** |br| |br| + The document's `DOMContentLoaded `_ event. + - .. image:: red.png + - + + * - **Load** |br| |br| + The document's `load `_ event. + - .. image:: blue.png + - + + * - **Worker event in main thread** |br| |br| + Shown when the main thread sends a message to a worker, or receives a message from a worker. + - .. image:: orange.png + - **Serialize data on the main thread** + The main thread is serializing a message to be sent to the worker. + **Deserialize data on the main thread** + The main thread is deserializing a message received from the worker. + + * - **Worker event in worker thread** + Shown when a worker receives a message from the main thread, or sends a message to the main thread. + - .. image:: orange2-hollow.png + - One of: |br| |br| + + **Serialize data in Worker** + The worker is serializing a message to be sent to the main thread. + + **Deserialize data in Worker** + The worker is deserializing a message received from the main thread. + + +The markers, and their colors, are the same in the Waterfall tool as in the :ref:`Waterfall overview `, making is easy to correlate from one to the other. + + +Filtering markers +----------------- + +You can control which markers are displayed using a button in the :ref:`Toolbar `: + +.. image:: perf-markers.png + :class: center + + +Waterfall patterns +****************** + +Exactly what you'll see in the Waterfall is very dependent on the kind of thing your site is doing: JavaScript-heavy sites will have a lot of orange, while visually dynamic sites will have a lot of purple and green. But there are common patterns which can alert you to possible performance problems. + + +Rendering waterfall +------------------- + +One pattern that you'll often see in the Waterfall view is something like this: + +.. image:: perf-timeline-waterfall.png + :class: center + +This is a visualization of the basic algorithm the browser uses to update the page in response to some event: + +1. **JavaScript Function Call**: some event - for example, a DOM event - causes some JavaScript in the page to run. The JavaScript changes some of the page's DOM or CSSOM. +2. **Recalculate Style**: if the browser thinks the computed styles for page elements have changed, it must then recalculate them. +3. **Layout**: next, the browser uses the computed styles to figure out the position and geometry for the elements. This operation is labeled "layout" but is also sometimes called "reflow". +4. **Paint**: finally, the browser needs to repaint the elements to the screen. One last step is not shown in this sequence: the page may be split into layers, which are painted independently and then combined in a process called "Composition". + +This sequence needs to fit into a single frame, since the screen isn't updated until it is complete. It's commonly accepted that 60 frames per second is the rate at which animations will appear smooth. For a rate of 60 frames per second, that gives the browser 16.7 milliseconds to execute the complete flow. + +Importantly for responsiveness, the browser doesn't always have to go through every step: + + +- `CSS animations `_ update the page without having to run any JavaScript. +- Not all CSS property changes cause a reflow. Changing properties that can alter an object's geometry and position, such as `width `_, `display `_, `font-size `_, or `top `_, will cause a reflow. However, changing properties that don't alter geometry or position, such as `color `_ or `opacity `_, will not. +- Not all CSS property changes cause a repaint. In particular, if you animate an element using the `transform `_ property, the browser will use a separate layer for the transformed element, and doesn't even have to repaint when the element is moved: the new position of the element is handled in composition. + + +The :doc:`Animating CSS properties <../scenarios/animating_css_properties/index>` article shows how animating different CSS properties can give different performance outcomes, and how the Waterfall can help signal that. + + +Blocking JavaScript +------------------- + +By default, a site's JavaScript is executed in the same thread that the browser uses for layout updates, repaints, DOM events, and so on. This means that long-running JavaScript functions can cause unresponsiveness (jank): animations may not be smooth, or the site might even freeze. + +Using the frame rate tool and the Waterfall together, it's easy to see when long-running JavaScript is causing responsiveness problems. In the screenshot below, we've zoomed in on a JS function that's caused a drop in the frame rate: + +.. image:: perf-js-blocking-waterfall.png + :class: center + + +The :doc:`Intensive JavaScript <../scenarios/intensive_javascript/index>` article shows how the Waterfall can highlight responsiveness problems caused by long JavaScript functions, and how you can use asynchronous methods to keep the main thread responsive. + + +Expensive paints +---------------- + +Some paint effects, such as `box-shadow `_, can be expensive, especially if you are applying them in a transition where the browser has to calculate them in every frame. If you're seeing drops in the frame rate, especially during graphically-intensive operations and transitions, check the Waterfall for long green markers. + + +.. _performance-waterfall-garbage_collection: + +Garbage collection +------------------ + +Red markers in the Waterfall represent garbage collection (GC) events, in which `SpiderMonkey `_ (the JavaScript engine in Firefox) walks the heap looking for memory that's no longer reachable and subsequently releasing it. GC is relevant to performance because while it's running the JavaScript engine must be paused, so your program is suspended and will be completely unresponsive. + +To help reduce the length of pauses, SpiderMonkey implements *incremental GC*: this means that it can perform garbage collection in fairly small increments, letting the program run in between. Sometimes, though, it needs to perform a full non-incremental collection, and the program has to wait for it to finish. + +In trying to avoid GC events, and especially non-incremental GC events, it's wise not to try to optimize for the specific implementation of the JavaScript engine. SpiderMonkey uses a complex set of heuristics to determine when GC is needed, and when non-incremental GC in particular is needed. In general, though: + + +- GC is needed when a lot of memory is being allocated +- non-incremental GC is usually needed when the memory allocation rate is high enough that SpiderMonkey may run out of memory during incremental GC + + +When the Waterfall records a GC marker it indicates: + + +- whether the GC was incremental or not +- the reason the GC was performed +- if the GC was non-incremental, the reason it was non-incremental +- starting in Firefox 46, if the GC event was caused by allocation pressure, a link appears, labeled "Show Allocation Triggers". Click the link to see the allocation profile leading up to this GC event. See :ref:`Allocations and Garbage Collection ` for more details. + + +Adding markers with the console API +*********************************** + +Two markers are directly controlled by `console API `_ calls: "Console" and "Timestamp". + + +Console markers +--------------- + +These enable you to mark a specific section of the recording. + +To make a console marker, call ``console.time()`` at the start of the section, and ``console.timeEnd()`` at the end. These functions take an argument which is used to name the section. + +For example, suppose we have code like this: + +.. code-block:: JavaScript + + var iterations = 70; + var multiplier = 1000000000; + + function calculatePrimes() { + + console.time("calculating..."); + + var primes = []; + for (var i = 0; i < iterations; i++) { + var candidate = i * (multiplier * Math.random()); + var isPrime = true; + for (var c = 2; c <= Math.sqrt(candidate); ++c) { + if (candidate % c === 0) { + // not prime + isPrime = false; + break; + } + } + if (isPrime) { + primes.push(candidate); + } + } + + console.timeEnd("calculating..."); + + return primes; + } + +The Waterfall's output will look something like this: + +.. image:: perf-console-time.png + :class: center + +The marker is labeled with the argument you passed to ``console.time()``, and when you select the marker, you can see the program stack in the right-hand sidebar. + + +.. _performance-waterfall-async-stack: + +Async stack +~~~~~~~~~~~ + +New in Firefox 41. + +Starting in Firefox 41, the right-hand sidebar will also show the stack at the end of the period: that is, at the point ``console.timeEnd()`` was called. If ``console.timeEnd()`` was called from the resolution of a `Promise `_, it will also display "(Async: Promise)", under which it will show the "async stack": that is, the call stack at the point the promise was made. + +For example, consider code like this: + +.. code-block:: JavaScript + + var timerButton = document.getElementById("timer"); + timerButton.addEventListener("click", handleClick, false); + + function handleClick() { + console.time("timer"); + runTimer(1000).then(timerFinished); + } + + function timerFinished() { + console.timeEnd("timer"); + console.log("ready!"); + } + + function runTimer(t) { + return new Promise(function(resolve) { + setTimeout(resolve, t); + }); + } + +The Waterfall will display a marker for the period between ``time()`` and ``timeEnd()``, and if you select it, you'll see the async stack in the sidebar: + +.. image:: async-stack.png + :class: center + + +Timestamp markers +----------------- + +Timestamps enable you to mark an instant in the recording. + +To make a timestamp marker, call `console.timeStamp() `_. You can pass an argument to label the timestamp. + +For example, suppose we adapt the code above to make a timestamp every 10 iterations of the loop, labeled with the iteration number: + +.. code-block:: JavaScript + + var iterations = 70; + var multiplier = 1000000000; + + function calculatePrimes() { + console.time("calculating..."); + + var primes = []; + for (var i = 0; i < iterations; i++) { + + if (i % 10 == 0) { + console.timeStamp(i.toString()); + } + + var candidate = i * (multiplier * Math.random()); + var isPrime = true; + for (var c = 2; c <= Math.sqrt(candidate); ++c) { + if (candidate % c === 0) { + // not prime + isPrime = false; + break; + } + } + if (isPrime) { + primes.push(candidate); + } + } + console.timeEnd("calculating..."); + return primes; + } + +In the Waterfall you'll now see something like this: + +.. image:: perf-timestamp.png + :class: center diff --git a/devtools/docs/user/performance__/javascript_flame_chart/index.rst b/devtools/docs/user/performance__/javascript_flame_chart/index.rst new file mode 100644 index 000000000000..f7b701bffff3 --- /dev/null +++ b/devtools/docs/user/performance__/javascript_flame_chart/index.rst @@ -0,0 +1,9 @@ +====================== +JavaScript flame chart +====================== + +Determining why CPUs are busy is a routine task for performance analysis, which often involves profiling stack traces. Profiling by sampling at a fixed rate is a coarse but effective way to see which code-paths are hot (busy on-CPU). It usually works by creating a timed interrupt that collects the current program counter, function address, or entire stack back trace, and translates these to something human readable when printing a summary report. + +Profiling data can be thousands of lines long, and difficult to comprehend. *Flame graphs* are a visualization for sampled stack traces, which allows hot code-paths to be identified quickly. See the `Flame Graphs `_ main page for uses of this visualization other than CPU profiling. + +Flame Graphs can work with any CPU profiler on any operating system. My examples here use Linux perf_events, DTrace, SystemTap, and ktap. See the `Updates `_ list for other profiler examples, and `github `_ for the flame graph software. diff --git a/devtools/docs/user/remote_debugging/chrome_desktop/index.rst b/devtools/docs/user/remote_debugging/chrome_desktop/index.rst new file mode 100644 index 000000000000..59f741e1b90b --- /dev/null +++ b/devtools/docs/user/remote_debugging/chrome_desktop/index.rst @@ -0,0 +1,9 @@ +================================= +Remotely debugging Chrome Desktop +================================= + +How to connect the :doc:`Firefox Developer Tools <../index>` to the `Google Chrome `_ browser running on the desktop. + +.. warning:: + + Not supported anymore diff --git a/devtools/docs/user/remote_debugging/debugging_firefox_desktop/index.rst b/devtools/docs/user/remote_debugging/debugging_firefox_desktop/index.rst new file mode 100644 index 000000000000..3038fd99f463 --- /dev/null +++ b/devtools/docs/user/remote_debugging/debugging_firefox_desktop/index.rst @@ -0,0 +1,48 @@ +========================= +Debugging Firefox Desktop +========================= + +.. warning:: + + Draft: this page is not complete + +This guide explains how you can use the Firefox Developer Tools to debug a different instance of desktop Firefox running on the same machine. In this guide, the instance of Firefox being debugged is called the *debuggee*, and the instance of Firefox doing the debugging is called the *debugger*. + +Enable remote debugging +*********************** + +First, you'll need to ensure that both debugger and debuggee have the "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" settings checked in the :ref:`Developer Tools Settings `. If you're using `Firefox Developer Edition `_, they are checked by default. + +.. image:: remote_debug_settings.png + :class: border + + +You only need to do this once: the setting values persist across restarts. + +Start the debugger server +************************* + +Next, you need to start the debugger server in the debuggee. + +Run the debuggee from the command line, passing it the ``--start-debugger-server`` option: + +.. code-block:: + + /path/to/firefox --start-debugger-server + +Passed with no arguments, ``--start-debugger-server`` makes the debugger server listen on port 6000. To use a different port, pass the desired port number: + +.. code-block:: + + /path/to/firefox --start-debugger-server 1234 + +Note: in Windows, the ``start-debugger-server`` call will only have one dash: + +.. code-block:: + + firefox.exe -start-debugger-server 1234 + +.. note:: + + By default, and for security reasons, the ``devtools.debugger.force-local`` option is set. If you want to debug a Firefox instance from an external machine, you can change this option, but only do this on a trusted network or set a strong firewall rule to lock down which machines can access it. + diff --git a/devtools/docs/user/remote_debugging/debugging_firefox_for_android_with_webide/index.rst b/devtools/docs/user/remote_debugging/debugging_firefox_for_android_with_webide/index.rst new file mode 100644 index 000000000000..f126780a8224 --- /dev/null +++ b/devtools/docs/user/remote_debugging/debugging_firefox_for_android_with_webide/index.rst @@ -0,0 +1,82 @@ +========================================= +Debugging Firefox for Android with WebIDE +========================================= + +This article describes how to connect the :doc:`Firefox Developer Tools <../../index>` to Firefox for Android from Firefox 36 onwards. + +It's been possible for a long time to connect the Firefox Developer Tools to Firefox for Android so you can debug your mobile website. Until now, though, this was a fairly complex and error-prone process. From Firefox 36 we've made the process much simpler: in particular, you don't need to deal directly with the `adb `_ tool at all. Now you connect using **WebIDE**, which takes care of setting up adb behind the scenes. + +.. note:: + For this to work, you need at least Firefox 36 on the desktop and Firefox 35 on the mobile device. If you need to use an earlier version, see the older instructions for :doc:`connecting the developer tools to Firefox for Android <../firefox_for_android/index>` + + +.. image:: remote-debugging-overview-fx36.png + :class: center + +This guide is 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 36 or higher running on it +- an Android device `capable of running Firefox for Android `_ with Firefox for Android 35 or higher running on it +- a USB cable to connect the two devices + + +ADB Helper +---------- + +Your desktop Firefox also needs to have the ADB Helper add-on, version 0.7.1 or higher. This should be installed for you automatically the first time you open WebIDE. To check the version, type ``about:addons`` into the browser's address bar and you should see ADB listed. + +If you don't have ADB Helper version 0.7.1 or higher, select "Manage Extra Components" from the "Projects" menu, and you'll see the "Extra Components" window, which will contain an entry for ADB Helper: + +.. image:: extra-components.png + :class: center + +Click "uninstall", then "install", and you should now have the latest version. + + +Setting up the Android device +----------------------------- + +First, enable USB debugging by following `steps 2 and 3 of this link only `_. + +Next, enable remote debugging in Firefox for Android. Open the browser, open its 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: + +.. image:: remote-debugging-device-enable.png + :class: center + +The browser might display a notification reminding you to set up port forwarding, which you can ignore. + + +Connecting +********** + +Connect the Android device to the desktop with the USB cable, open **WebIDE**, and open the **Runtimes menu**. You will see Firefox for Android listed as a debugging target under "USB DEVICES": + +.. image:: remote-debugging-android-runtime.png + :class: center + + +Select it. On the Android device, you'll now see a warning message: + +.. image:: incoming-warning.png + :class: center + + +Click OK. Now click the "Open App" menu in WebIDE. You'll see a list of all the tabs open on the device: + +.. image:: remote-debugging-android-open-tabs.png + :class: center + + +Select a tab to attach the developer tools to it: + +.. image:: remote-debugging-android-attached.png + :class: center + + +Now you should be able to use all the Firefox developer tools that support remote debugging. See the page on :doc:`remote debugging <../index>` for more details. diff --git a/devtools/docs/user/remote_debugging/firefox_for_android/index.rst b/devtools/docs/user/remote_debugging/firefox_for_android/index.rst new file mode 100644 index 000000000000..4ab3de609fdb --- /dev/null +++ b/devtools/docs/user/remote_debugging/firefox_for_android/index.rst @@ -0,0 +1,196 @@ +========================================== +Remotely debugging Firefox <36 for Android +========================================== + +.. note:: + This guide is for Firefox version 36 and earlier. To debug in Firefox 68 and later, follow the instructions on `about:debugging `_. + + For Firefox between 37 and 67, please use the :doc:`WebIDE <../debugging_firefox_for_android_with_webide/index>` guide. + + +This guide explains how to use :doc:`remote debugging <../index>` to inspect or debug code running in Firefox for Android over USB. + +.. image:: remote-debugging-overview.png + :class: center + + +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 +~~~~~~~~~~~~~~~~~~~~~ + +- `Enable USB debugging in phone settings `_. +- Attach the device to the desktop via USB. + + +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: + +.. code-block:: + + adb devices + +You should see some output like: + +.. code-block:: + + 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 the ``devtools.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 the ``devtools.debugger.remote-enabled`` preference, and press "Toggle". + +.. image:: remote-debugger-about-config-toggle.png + :class: center + + +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: + +.. image:: remote-debugging-device-enable.png + :class: center + + +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. :doc:`Open the Toolbox <../../tools_toolbox/index>`, click the "Settings" button in the :ref:`toolbar `, and check "Enable remote debugging" in the :ref:`Settings ` tab: + +.. image:: remote-debugger-toolbox-settings.png + :class: center + + +.. note:: + + 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...": + +.. image:: remote-debugging-connect-menuitem.png + :class: center + + +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 +-------------- + +For Firefox 34 or below, go to a command prompt, and type: + +.. code-block:: + + adb forward tcp:6000 tcp:6000 + +For later versions of Firefox, go to a command prompt, and type: + +.. code-block:: + + adb forward tcp:6000 localfilesystem:/data/data/org.mozilla.firefox/firefox-debugger-socket + + +(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: + +.. code-block:: + + 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: + + +.. image:: remote-debugging-desktop-connect.png + :class: center + +Unless you've changed the port numbers, choose 6000 and press the "Connect" button. + + +On the Android device +--------------------- + +Next you'll see a dialog in Firefox for Android asking you to confirm the connection: + +.. image:: remote-debugging-device-connect.png + :class: center + +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: + +.. image:: remote-debugging-desktop-select-target.png + :class: center + +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: + +.. image:: remote-debugging-console.png + :class: center + + +The Toolbox, and the tools it hosts, work in just the same way as they do when attached to local content. + +.. image:: remote-debugging-debugger.png + :class: center + diff --git a/devtools/docs/user/remote_debugging/index.rst b/devtools/docs/user/remote_debugging/index.rst new file mode 100644 index 000000000000..5a6a106c1348 --- /dev/null +++ b/devtools/docs/user/remote_debugging/index.rst @@ -0,0 +1,15 @@ +================ +Remote Debugging +================ + +You can use the :doc:`Firefox developer tools <../index>` on your desktop to debug Web sites and Web apps running in other browsers or runtimes. The other browser might be on the same device as the tools themselves or on a different device, such as a phone connected over USB. + +The detailed instructions for connecting the developer tools are specific to the runtime. + +You can connect the developer tools to Gecko-based runtimes like Firefox Desktop, Firefox for Android, and Thunderbird. + + +- :doc:`Firefox Desktop ` +- Firefox for Android :doc:`over USB <../about_colon_debugging/index>` +- :doc:`Thunderbird ` + diff --git a/devtools/docs/user/remote_debugging/thunderbird/index.rst b/devtools/docs/user/remote_debugging/thunderbird/index.rst new file mode 100644 index 000000000000..67d1677fcddd --- /dev/null +++ b/devtools/docs/user/remote_debugging/thunderbird/index.rst @@ -0,0 +1,54 @@ +============================== +Remotely debugging Thunderbird +============================== + +This guide explains how to use remote debugging to inspect or debug code running in Thunderbird. + +Various developer tools are supported by Thunderbird using the remote connection mechanism in Firefox. The currently supported toolset is the Web Console, Inspector, Debugger, Style Editor, Profiler and Network Monitor. Other Tools may become available in the future. + + +Setting up Thunderbird +********************** + +All that needs to be done in Thunderbird is enabling the debugger server. This can be done using ``Tools`` from the Menu Bar (alt + Tools) and selecting ``Allow Remote Debugging``. By default, a debugger server will be started on port 6000. If you would like to change this port, for example to debug multiple profiles, you must open the advanced config editor and change the preference ``devtools.debugger.remote-port``. + + +Setting up Firefox +****************** + +Firefox acts as the client and provides the user interface to control the developer tools for Thunderbird. It's best to use a Firefox and Thunderbird version with a matching major version number, but in some cases it will work even with differing versions. + +To set up Firefox, remote debugging is enabled by a setting in the Toolbox. :doc:`Open the Toolbox <../../tools_toolbox/index>`, click the "Settings" button in the :ref:`toolbar `, and check "Enable remote debugging" in the :ref:`Settings ` tab: + +.. image:: remote-debugger-toolbox-settings.png + :class: center + + +Now you can open the connection page in Firefox via the tools menu: + +.. image:: remote-debugging-connect-menuitem.png + :class: center + + +A page will open in the browser; you can add this to your bookmarks toolbar if you like. In case you didn't change the remote port, the fields will already be filled out correctly. Click on the Connect button to initiate the developer tools remote connection. + +.. image:: remote-debugging-desktop-connect.png + :class: center + + +Afterwards you will be presented with a list of remote tabs and processes. As Thunderbird's notion of tabs doesn't match Firefox, the remote tabs area shows all xul:browser elements in Thunderbird. This can be a content tab, or the message reader. In most cases you will want to select "Main Process" to debug the Thunderbird code itself. A new window opens containing a set of developer tools that can be used with your Thunderbird instance. + +.. image:: remote-debugging-desktop-select-target.png + :class: center + + +Using the Developer Tools +************************* + +Usage of the tools is mostly self explanatory. If you are having trouble with a certain tool, check the :doc:`Developer Tools documentation <../index>`. Due to a remote connection being used there might be some slight differences. Some tools might not be available, and it is also possible that performance is not comparable. For example, using the remote debugger tool takes quite some time to load because the files must be transferred over an internal network connection. + + +Troubleshooting +*************** + +If you encounter an error, the first thing you should check is if you are using matching version numbers. If you are using Thunderbird 24, you should also use Firefox 24 to connect. Next, it important to figure out if it is a problem with the Firefox Developer Tools or with the remote connection code in Thunderbird. To verify this, please try to reproduce the problem using only Firefox. For example, if you notice that you cannot set an attribute value in the Inspector tool, try changing an attribute in the Browser Debugger in Firefox. If you cannot reproduce it there, file a bug in the Thunderbird product, otherwise file a bug in Firefox/Developer Tools. diff --git a/devtools/docs/user/responsive_design_mode/index.rst b/devtools/docs/user/responsive_design_mode/index.rst new file mode 100644 index 000000000000..b8fc795006df --- /dev/null +++ b/devtools/docs/user/responsive_design_mode/index.rst @@ -0,0 +1,209 @@ +====================== +Responsive Design Mode +====================== + +`Responsive design `_ is the practice of designing a website so it looks and works properly on a range of different devices — particularly mobile phones and tablets as well as desktops and laptops. + +The most obvious factor here is screen size, but there are other factors as well, including the pixel density of the display and whether it supports touch. Responsive Design Mode gives you a simple way to simulate these factors, to test how your website will look and behave on different devices. + + +Toggling Responsive Design Mode +******************************* + +There are three ways to toggle Responsive Design Mode: + + +- From the Firefox menu: Select **Responsive Design Mode** from the **Web Developer** submenu in the Firefox Menu (or **Tools** menu if you display the menu bar or are on macOS). +- From the Developer Tools toolbox: Press the **Responsive Design Mode** button in the Toolbox's toolbar: +- From the keyboard: Press :kbd:`Ctrl` + :kbd:`Shift` + :kbd:`M` (or :kbd:`Cmd` + :kbd:`Opt` + :kbd:`M` on macOS). + + +Controlling Responsive Design Mode +********************************** + +With Responsive Design Mode enabled, the content area for web pages is set to the screen size for a mobile device. Initially, it's set to 320 x 480 pixels. + +.. note:: + + The device you select when in Responsive Design Mode and the orientation (portrait or landscape) is saved between sessions. + +.. image:: responsive_ui.png + :class: center + +Information for the selected device is centered over the display. From left to right, the display includes: + + +- *Name of the selected device* - A drop-down list that includes whatever devices you have selected from the Device Settings screen. +- *Screen size* - You can edit the width and height values to change the device size by editing a number directly or using the :kbd:`Up` and :kbd:`Down` keys to increase or decrease the value by 1 pixels on each keypress or hold and :kbd:`Shift` to change the value by 10. + + - The mouse wheel changes the size values by 1 pixel at a time + - You can also change the device's screen size by grabbing the bottom-right corner of the viewport and dragging it to the size you want. + + +- *Orientation (portrait or landscape)* - This setting persists between sessions +- *DPR (pixel ratio)* - Beginning with Firefox 68, the DPR is no longer editable; create a custom device in order to change the DPR +- *Throttling* - A drop-down list where you can select the connection throttling to apply, for example 2G, 3G, or LTE +- *Enable/Disable touch simulation* - Toggles whether or not Responsive Design Mode simulates touch events. While touch event simulation is enabled, mouse events are translated into `touch events `_; this includes (starting in Firefox 79) translating a mouse-drag event into a touch-drag event. (Note that when touch simulation is enabled, this toolbar icon is blue; when simulation is disabled, it is black. + + +On the right end of the screen, three buttons allow you to: + + +.. _responsive-design-mode-camera-button: + +- *Camera button* - take a screenshot + + - Screenshots are saved to Firefox's default download location. + - If you checked "Screenshot to clipboard" in the Developer Tools :doc:`Settings <../settings/index>` page, then the screenshot will be copied to the system clipboard. + +- *Settings button* - Opens the RDM settings menu +- *Close button* - closes RDM mode and returns to regular browsing + + +The Settings menu includes the following commands: + +.. image:: responsive_setting_menu.png + :class: center + +- *Left-align Viewport* - when checked moves the RDM viewport to the left side of the browser window +- *Show user agent* - when checked displays the user agent string +- The final two options define when the page is reloaded: + + - *Reload when touch simulation is toggled:* when this option is enabled, the page is reloaded whenever you toggle touch support. + - *Reload when user agent is changed:* when this option is enabled, the page is reloaded whenever the user agent is changed. + + +Reloading on these changes can be helpful because certain page behaviors would otherwise not be applied. For example, many pages check for touch support on load and only add event handlers if it is supported, or only enable certain features on certain browsers. + +However, if you are not interested in examining such features (maybe you are just checking the overall layout at different sizes), these reloads can waste time and possibly result in the loss of productive work, so it is useful to be able to control these reloads. + +Now when you change such settings for the first time, you are given a warning message that tells you these reloads are no longer automatic, and informed about how you can make them automatic. For example: + + +.. image:: page-reload-warning.png + :class: center + + +Developer Toolbox with RDM +************************** + +You can show or hide the Developer Tools toolbox independently of toggling Responsive Design Mode itself: + +.. image:: rdmdevtools.png + :class: center + +While Responsive Design Mode is enabled, you can continue browsing as you normally would in the resized content area. + + +Device selection +**************** + +Just above the viewport there is a label "no device selected"; click this to see a list of device names. Select a device, and Responsive Design Mode sets the following properties to match the selected device: + + +- Screen size +- Device pixel ratio (the ratio of device physical pixels to device-independent pixels) +- Touch event simulation + + +Additionally, Firefox sets the `User-Agent `_ HTTP request header to identify itself as the default browser on the selected device. For example, if you've selected an iPhone, then Firefox identifies itself as Safari. The `navigator.userAgent `_ property is set to the same value. + +.. raw:: html + + +
+
+ + +The devices listed in the drop-down are just a subset of the devices that can be selected. At the end of the drop-down, there is an item labeled **Edit list**. Select this to see a panel containing all the choices, which enables you to check the devices you want to see in the drop-down. The set of devices, and the values associated with each device, are taken from https://github.com/mozilla/simulated-devices. You can also define a custom device, as described below. + + +Creating custom devices +----------------------- + +You can create and save custom devices in Responsive Design Mode by clicking the **Add Custom Device** button. Each device can have its own: + + +- Name +- Size +- DevicePixelRatio +- User Agent String +- Touch Screen + + +Also, you can preview the properties of existing devices by hovering over the name in the device modal, where they display in a tooltip. + +.. raw:: html + + +
+
+ +Network throttling +****************** + +If you do all your development and testing using a very fast network connection, users may experience problems with your site if they are using a slower connection. In Responsive Design Mode, you can instruct the browser to emulate, very approximately, the characteristics of various different types of networks. + +The characteristics emulated are: + +- Download speed +- Upload speed +- Minimum latency + + +The table below lists the numbers associated with each network type, but please do not rely on this feature for exact performance measurements; it's intended to give an approximate idea of the user experience in different conditions. + +.. list-table:: + :widths: 25 25 25 25 + :header-rows: 1 + + * - Selection + - Download speed + - Upload speed + - Minimum latency (ms) + + * - GPRS + - 50 KB/s + - 20 KB/s + - 500 + + * - Regular 2G + - 250 KB/s + - 50 KB/s + - 300 + + * - Good 2G + - 450 KB/s + - 150 KB/s + - 150 + + * - Regular 3G + - 750 KB/s + - 250 KB/s + - 100 + + * - Good 3G + - 1.5 MB/s + - 750 KB/s + - 40 + + * - Regular 4G/LTE + - 4 MB/s + - 3 MB/s + - 20 + + * - DSL + - 2 MB/s + - 1 MB/s + - 5 + + * - Wi-Fi + - 30 MB/s + - 15 MB/s + - 2 + +To select a network, click the list box that's initially labeled "No throttling": + +.. image:: rdm_throttling.png + :class: center + diff --git a/devtools/docs/user/rulers/index.rst b/devtools/docs/user/rulers/index.rst new file mode 100644 index 000000000000..4f4408cb18a4 --- /dev/null +++ b/devtools/docs/user/rulers/index.rst @@ -0,0 +1,28 @@ +====== +Rulers +====== + +You can overlay horizontal and vertical rulers on a web page: + +.. image:: viewport_rulers.png + :class: center + +The units are in pixels. + +The dimensions of the viewport are displayed near the top-right corner of the viewport. + +To be able to toggle rulers for a page, you first need to enable the button by going to the settings page for the Developer Tools and checking "Toggle rulers for the page" under Available Toolbox Buttons. + +.. image:: settings_available_buttons.png + :class: center + +Once enabled, the "Toggle rulers for the page" button appears at the top right of the Toolbox, in the same place as the Settings/Options button. + +.. image:: ruler_toggle_button.png + :class: center + + +Behavior to keep in mind when using rulers: + +- The rulers command must be reapplied in **new tabs** and after **each page refresh.** +- The command isn't permanent. diff --git a/devtools/docs/user/settings/index.rst b/devtools/docs/user/settings/index.rst new file mode 100644 index 000000000000..45c1454d959a --- /dev/null +++ b/devtools/docs/user/settings/index.rst @@ -0,0 +1,223 @@ +======== +Settings +======== + +Opening Settings +**************** + +Beginning with Firefox 62, the icon to open Developer Tools settings has been moved into a menu accessed by clicking/touching ... (the ellipsis) on the right of the tab. + +.. image:: devtools_layoutmenu.png + :class: center + +The menu includes settings to control the location of the Developer Tools. You can choose between the default setting at the bottom of the windows, or move the tools to the left or right side of the screen. These settings are particularly useful if you have a widescreen monitor. You can also choose to open the tools in a separate window. + +**Show split console** adds a section at the bottom of the tools showing the console. It makes visible the command line and one or two lines of the console output. + +.. image:: split_console.png + :class: center + +The rest of the settings are on the Developer Tools Settings Pane. To see the settings, open any of the Developer Tools, and then: + + +- click the "Settings" command in the menu: + + .. image:: devtools_menu.png + :class: border + +- or press :kbd:`F1` to toggle between the active tool and the Settings pane + + +The Settings pane looks something like this: + +.. image:: dev_tools_settings.png + :alt: Depicts the Toolbox options + :class: center + + +Categories +********** + +Default Firefox Developer Tools +------------------------------- + +This group of checkboxes determines which tools are enabled in the toolbox. New tools are often included in Firefox but not enabled by default. + + +Available Toolbox Buttons +------------------------- + +This group of checkboxes determines which tools get :ref:`an icon in the Toolbox's toolbar `. + +As of Firefox 62, if the option to "Select an iframe as the currently targeted document" is checked, the icon will appear in the toolbar while the Settings tab is displayed, even if the current page doesn't include any iframes. + +Note that in Firefox 52 we removed the checkbox to toggle the :ref:`"Select element" button `. The "Select element" button is now always shown. + + +.. _settings-themes: + +Themes +****** + +This enables you to choose one of two themes. + +- There's a light theme, which is the default: + + .. image:: theme-light.png + :alt: Light theme for DevTools + :class: border + +- A dark theme (the default on `Firefox Developer Edition `_): + + .. image:: theme-dark.png + :alt: Dark theme for DevTools + :class: border + + +.. _settings-common-preferences: + +Common preferences +------------------ + +Settings that apply to more than one tool. There's just one of these: + +*Enable persistent logs* + A setting to control whether or not the Web Console and Network Monitor clear their output when you navigate to a new page. + +.. note:: + + If Common Preferences is not included in the Settings, Web Console logs can be persisted by using the 'about:config' url in browser address bar, searching for: 'devtools.webconsole.persistlog' then toggling this value to true + + +.. _settings-inspector: + +Inspector +--------- + +*Show browser styles* + A setting to control whether styles applied by the browser (`user-agent styles `_) should be displayed in the Inspector's :doc:`Rules view <../page_inspector/how_to/examine_and_edit_css/index>`. Note that this setting is independent of the "Browser styles" checkbox in the Inspector's :ref:`Computed view `. + +*Truncate DOM attributes* + By default, the Inspector truncates DOM attributes that are more than 120 characters long. Uncheck this box to prevent this behavior. This setting works by toggling the about:config preference ``devtools.markup.collapseAttributes``. To change the threshold at which attributes are truncated, you can edit the about:config preference ``devtools.markup.collapseAttributeLength``. + +*Default color unit* + A setting to control how colors are represented in the inspector: + + - Hex + - HSL(A) + - RGB(A) + - color name + - As authored. + + +*Enable layout panel* + Enable the experimental layout panel. This setting only exists in Firefox Nightly. + + +.. _settings-web-console: + +Web Console +----------- + +*Enable timestamps* + Controls whether the Web Console displays timestamps. The Web Console defaults to hiding timestamps. + +*Enable new console frontend* + Switch to the experimental new console. This setting only exists in Firefox Nightly. + + +.. _settings-debugger: + +Debugger +-------- + +*Enable Source Maps* + Enable :doc:`source map support <../debugger/how_to/use_a_source_map/index>` in the debugger. + +*Enable new debugger frontend* + Enable the new debugger. This setting only exists in Firefox Nightly. + + + +.. _settings-style-editor: + +Style Editor +------------ + +*Show original sources* + When a CSS preprocessor supporting source maps is used, this enables the Style Editor to display the original, preprocessor, sources rather than the generated CSS. :ref:`Learn more about Style Editor support for CSS source maps `. With this setting checked, the :ref:`Page Inspector Rules view will also provide links to the original sources `. + +*Autocomplete CSS* + Enable the Style Editor to offer autocomplete suggestions. + + +Screenshot Behavior +------------------- + +*Screenshot to clipboard* + When you click the icon for the :doc:`Screenshot tool <../taking_screenshots/index>`, copy the screenshot image to the clipboard (the image will still be saved to your Downloads directory). New in Firefox 53. + +*Play camera shutter sound* + When you click the icon for the :doc:`Screenshot tool <../taking_screenshots/index>`, play a shutter sound. New in Firefox 53. + + + +.. _settings-editor-preferences: + +Editor Preferences +****************** + +Preferences for the `CodeMirror `_ source editor, which is included in Firefox and used by several developer tools, including the :doc:`Style Editor <../style_editor/index>`. + +*Detect indentation* + Auto-indent new lines based on the current indentation. + +*Autoclose brackets* + Determines whether typing an opening character like ``[`` or ``{`` will cause the editor to insert the matching closing character ``]`` or ``}`` for you. + +*Indent using spaces* + When checked, indentation will be performed using spaces, when off, the editor will use tabs instead. + +*Tab size* + The frequency of tab stops in the editor. Select 2, 4, or 8. + +*Keybindings* + Choose the default CodeMirror keybindings or keybindings from one of several popular editors: + + - Vim + - Emacs + - Sublime Text + + +.. _settings_advanced_settings: + +Advanced settings +***************** + +*Show Gecko platform data* + A setting to control whether or not profiles should include Gecko platform symbols. + +*Disable HTTP Cache* + Disable the browser HTTP cache to simulate first-load performance in all tabs that have the Toolbox open. This setting persists, meaning that if it is set, caching will be disabled whenever you reopen the devtools. Caching is re-enabled when the devtools are closed. Note that service workers are not affected by this option. + +.. note:: + + Note that this option was called "Disable Cache" in Firefox versions previous to 49, but it was renamed to make it clearer that this affects the HTTP cache, and not `Service Workers `_/the `Cache API `_.
+ +*Disable JavaScript* + Reload the current tab with JavaScript disabled. + +*Enable Service Workers over HTTP* + Enable Service Worker registrations from insecure websites. + +*Enable browser chrome and add-on debugging toolboxes* + Enable you to use developer tools in the context of the browser itself, and not only web content. + +*Enable remote debugging* + Enable the developer tools to :doc:`debug remote Firefox instances <../remote_debugging/d>`. + +*Enable worker debugging* + Enable a panel within the debugger to debug workers. + + Note: This option got removed from the UI in Firefox 56, because this version ships with a :doc:`new Debugger UI <../debugger/index>`, but it can still be enabled for the old UI by setting the preference ``devtools.debugger.workers`` to ``true``. + diff --git a/devtools/docs/user/shader_editor/index.rst b/devtools/docs/user/shader_editor/index.rst new file mode 100644 index 000000000000..3a4310480f78 --- /dev/null +++ b/devtools/docs/user/shader_editor/index.rst @@ -0,0 +1,71 @@ +============= +Shader Editor +============= + +.. warning:: + + This tool has been deprecated and will soon be removed from Firefox. For details, see :doc:`Deprecated tools <../index>`. + +The Shader Editor enables you to see and edit the vertex and fragment shaders used by `WebGL `_. + +.. raw:: html + + +
+
+ +WebGL is a `JavaScript `_ API for rendering interactive 3D graphics and 2D graphics in the browser without using plugins. With WebGL you provide 2 programs called **shaders** which are called at the appropriate stages of the `OpenGL rendering pipeline `_: a `vertex shader `_, which computes the clip space coordinates of each vertex to be drawn, and a `fragment shader `_, which determines the color for each pixel to be drawn. + + +These shaders are written in **OpenGL Shading Language**, or `GLSL `_. In WebGL they can be included in a page in several ways: as text hardcoded in JavaScript strings, as separate files included using `