Following the announcement of Web Push in Firefox 44, we’re now delivering the capability to develop and debug service workers and push notifications code with DevTools using Firefox Developer Edition 47.
Here’s a screencast that demonstrates the features described in this post:
Or if you prefer text, keep reading!
Service workers do not behave exactly as normal web workers, and their lifecycle is different, so we can’t show them alongside normal scripts in the Debugger tab of DevTools.
Instead, we’ve added a new dashboard that will collect all registered service workers and shared workers, amongst other debuggable items such as Add-ons.
Therefore, our debugging adventure starts by going to
about:debugging in a new tab, and clicking on the Workers tab on the left.
Alternatively, you can access this dashboard by going to the Tools ⇨ Web Developer ⇨ Service Workers menu, or by clicking on the toolbar menu, then Developer, and finally Service Workers.
Dashboard instant updates
The first time we access the dashboard “nothing yet” will be displayed under the Service Workers and Shared Workers sections. These sections will be updated automatically as workers get registered. The displayed buttons will change accordingly, showing Push and Debug if the worker is running, or just a Start button if the worker is registered, but inactive.
Try it! Open
about:debugging in one window, and navigate to this simple service worker demo in another window. The service worker will be registered and displayed under the Service Workers section. No need for you to reload the dashboard!
Debugging service workers
To debug a service worker, the worker must already be running. Click on the associated Debug button, or Start the worker if it’s not running yet (as long as it has been registered, and thus is in the
This will pop up a new window with the code of the service worker. Here you can do all the usual debugging you would expect: setting breakpoints, step-by-step execution, inspecting variables, etc.
Read more @ Mozilla Hacks