Questa traduzione è incompleta. Collabora alla traduzione di questo articolo dall’originale in lingua inglese.

La pagina about:debugging page  fornisce un singolo posto da cui è possibile associare gli Strumenti per gli sviluppatori di Firefox a un numero di target di debug. Al momento supporta tre tipi principali di destinazioni: componenti aggiuntivi, schede e lavoratori non ristabiliti.

Aprire about:debugging page

Ci sono diversi modi per aprire about:debugging:

  • digitare  "about:debugging" nella barra degli URL di Firefox.
  • Nuovo in Firefox 47: in Strumenti > Web Developer menu, cliccare "Service Workers".
  • Nuovo in Firefox 47: fai clic sull'icona della chiave (), che si trova nella barra degli strumenti principale o sotto il menu a tendina (), quindi seleziona "Service Workers".

Quando about:debugging si apre, sul lato sinistro vedrai una barra laterale che consente di passare tra le due viste principali: una per gli add-on e uno per i workers.

Add-ons

La sezione dei componenti aggiuntivi di about:debugging supporta solo le restartless add-ons, incluse le basic bootstrapped extensions, Add-on SDK add-ons, e WebExtensions.

Questa pagina consente di fare due cose:

  • Caricare un add-on temporaneamente dal disco
  • Connettere Add-on Debugger a qualsiasi restartless add-ons

Collegamento della  Add-on Debugger

Si noti che al momento è consigliabile utilizzare la Toolbox del browser, non il debugger aggiuntivo, per il debug di WebExtensions. Vedi  Debugging WebExtensions per tutti i dettagli.

La pagina Add-ons  in about:debugging elenca tutti gli aggiornamenti restartless attualmente installati (si noti che questo elenco può includere componenti aggiuntivi che sono stati preinstallati con il tuo Firefox). Accanto a ciascuna voce è un pulsante etichettato "Debug".

Se il pulsante "Debug" è disattivato, seleziona la casella "Attiva debug di add-on".

Se fai clic su "Debug", vedrai una finestra di dialogo che ti chiede di accettare una connessione in entrata. Clicca "OK" e Add-on Debugger inizierà in una finestra separata. Notare che a volte la finestra di debugger è nascosta dalla finestra principale di Firefox .

Vedere la pagina su Add-on Debugger per tutte le cose che puoi fare con questo strumento.

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

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.

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.

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, categorised as follows:

You can connect the developer tools to each worker, and send push notifications to service workers.

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.

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:

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:

Click the link to unregister the service worker.

Sending push events to service workers

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.

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.

Tag del documento e collaboratori

 Hanno collaborato alla realizzazione di questa pagina: chiccobs
 Ultima modifica di: chiccobs,