Web Inspector
All extension contexts have Web Inspector enabled by default.Inspecting background workers
Enable Develop menu
In Safari or Nook, enable the Develop menu:
- Safari: Preferences β Advanced β Show Develop menu
- The Develop menu appears in the menu bar
Find background page
- Open Develop β Web Extension Background Pages
- Select your extensionβs background worker
- Web Inspector opens showing console, sources, network, etc.
Inspecting popups
For extension action popups:- Right-click on the extension toolbar icon
- Select Inspect Extension Popup
- Web Inspector opens for the popup context
Popup must be open for inspection. The popup stays open while Inspector is attached.
Inspecting content scripts
Content scripts run in web page contexts:- Navigate to the page where content scripts inject
- Right-click page β Inspect Element
- In Console, switch context dropdown to your extensionβs isolated world
Extension console
Nook includes a dedicated popup console for real-time debugging:console.log(), console.error(), and console.warn() calls and displays them in a native window.
Console features
- Live logging: See console output in real-time
- JavaScript execution: Run arbitrary JS in popup context
- API availability check: Automatically logs available extension APIs on load
Auto-injected probe
Background health probes
Nook automatically runs diagnostic probes after loading background workers.Automatic health checks
Probes run at +3 seconds and +8 seconds after background load:Viewing health probes
Health probe output appears in Xcode console with[EXT-HEALTH] prefix:
Capability probe
The health probe checks these APIs:Background worker URL (webkit-extension://β¦)
"browser" or "chrome" depending on which is availablebrowser.runtime API availableExtensionβs runtime ID
browser.storage availablebrowser.tabs availablebrowser.scripting availablebrowser.runtime.lastError if present (indicates failure)Extension state diagnostics
For active content script debugging, Nook providesdiagnoseExtensionState().
Triggering diagnostics
Diagnostics run automatically when tabs load (useful for content script injection issues):Diagnostic output
Logs appear in Xcode console with extension context details:Whatβs checked
Extension context diagnostics
Extension context diagnostics
For each loaded extension:
- Context count: Number of loaded
WKWebExtensionContextinstances - WebView controller: Whether tabβs webview has extension controller attached
- Background presence:
hasBackgroundContentandhasInjectedContentflags - Base URL: Extension resource base path
- URL access: Permission status for current page URL
- Granted permissions: Current permission set
- Match patterns: Granted host match patterns
- Background listeners: Whether
onMessage/onConnecthave registered handlers
Page-level diagnostics
Page-level diagnostics
Evaluates in page context to detect:
- Style injection: Number of extension-injected stylesheets (e.g., Dark Reader styles)
- Total styles: All
<style>elements in page - Script count: Number of
<script>elements
Common debugging scenarios
Background worker not starting
Check Xcode console
Look for
[EXT-HEALTH] logs. If "runtime": false, the background worker failed to initialize.Inspect background page
Open Develop β Web Extension Background Pages and check Console for errors.
Content scripts not injecting
Messaging failures
Check background listeners
Diagnostics show whether listeners are registered:If
Diagnostic output
false, background isnβt listening. Add:background.js
Storage not persisting
Check profile isolation
Remember storage is per-profile. Switching profiles creates new storage context.
Logging best practices
Structured logging
Use consistent log prefixes for easy filtering:background.js
Conditional debugging
Use a debug flag:background.js
Error tracking
Log errors with context:background.js
Memory debugging
Nook logs memory-related events withπ [MEMDEBUG] prefix:
- Extension context leaks
- WebView retention issues
- Anchor observer token cleanup
Extension resource testing
List all installed extensions programmatically:Next steps
Getting started
Create your first extension
API reference
Explore available APIs