> Have you tried
> "background": { "service_worker": "/js/test.js" } ? With the slash in the front?
Yes, thanks! In chrome://serviceworker-internals/ I have checked the checkbox to pause JavaScript execution on service workers.
With the background script URL set to /js/background.js, I see this in the log box:
Console: {"lineNumber":0,"message":"The path of the provided scope ('/') is not under the max scope allowed ('/js/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.","message_level":3,"sourceIdentifier":8,"sourceURL":""}
Error: {"columnNumber":-1,"lineNumber":-1,"message":"Failed to register a ServiceWorker for scope ('chrome-extension://icmcfccjipehgnldlcaokbnjdlmalffm/') with script ('chrome-extension://icmcfccjipehgnldlcaokbnjdlmalffm/js/background.js'): The path of the provided scope ('/') is not under the max scope allowed ('/js/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.","sourceURL":""}
With the background script URL set to js/background.js, the log box is empty.
Along the way I've developed a workflow that will actually allow me to get to a console inside my background file, which gives me hope for the future:
- Open chrome://serviceworker-internals/
- Reload the extension
- Switch back to serviceworker-internals
- Find your service worker (should be on top)
- Click Inspect
- The resulting window's console seems to be the internals of your service worker
FEATURE REQUEST: could we please have a direct link to this view via an Inspect link in the extension's card in chrome://extensions, just as if we were opening up the old-school background page?
--Kent