| name | playground-website-debugging |
| description | Debug the WordPress Playground website by running the dev server from source and interacting with it via Playwright MCP. Use when investigating UI bugs, testing website features, checking for JavaScript errors, debugging hanging requests, or verifying WordPress behavior in the browser-based Playground. |
Playground Dev Server Debugging with Playwright MCP
Debug the WordPress Playground website by running the dev server from source and interacting with it via Playwright MCP.
Requires: Node.js, Playwright MCP server
Quick Start
nvm use
lsof -ti:5400 -ti:5263 -ti:6400 | xargs kill 2>/dev/null; sleep 1
npm run dev > /tmp/playground-dev.log 2>&1 &
until curl -s -o /dev/null http://127.0.0.1:5400/website-server/ 2>/dev/null; do
sleep 2
done
echo "Ready!"
Then use Playwright MCP to interact:
browser_navigate ā http://127.0.0.1:5400/website-server/
browser_snapshot ā inspect the page structure
browser_take_screenshot ā visual state
Architecture: The Iframe Boundary
The Playground website has a three-layer structure that's critical to understand:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Parent page (Playground chrome / React app) ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā URL bar ā Save ā Settings ā Site Mgr ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā⤠ā
ā ā ā ā
ā ā <iframe class="playground-viewport"> ā ā
ā ā Loads remote.html ā ā
ā ā (Service Worker, Web Worker, PHP runtime) ā ā
ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā ā
ā ā ā <iframe id="wp"> ā ā ā
ā ā ā WordPress runs here ā ā ā
ā ā ā (wp-admin, front-end, editor, etc.) ā ā ā
ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā ā
ā ā ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Parent page contains: URL bar, Save button, Saved Playgrounds, Site Manager, Settings gear.
Outer iframe (playground-viewport) loads remote.html, which registers the Service Worker, spawns a Web Worker for the PHP runtime, and exposes the Playground API via Comlink.
Inner iframe (#wp, nested inside the outer iframe) contains the actual WordPress site ā dashboard, posts, pages, plugins, themes, block editor, front-end.
Playwright's browser_snapshot traverses both iframes automatically, so you'll see all three layers in one snapshot. When clicking elements inside WordPress, Playwright handles the iframe targeting.
Important: WordPress admin CSS positions sidebar submenu items off-screen (e.g. top: -12387px) until their parent menu is hovered. These elements appear in browser_snapshot but browser_click will fail with "element is outside of the viewport." Two workarounds:
- Hover parent first (preferred ā mimics real user behavior):
async (page) => {
const frame = page.frameLocator('iframe').first().frameLocator('iframe').first();
await frame.locator('#menu-tools').hover();
await frame.locator('a[href="site-health.php"]').click();
};
- JS click (bypasses Playwright's visibility checks):
async (page) => {
const frame = page.frameLocator('iframe').first().frameLocator('iframe').first();
await frame.locator('a[href="site-health.php"]').evaluate((el) => el.click());
};
PHP-WASM Request Pipeline
Understanding how HTTP requests flow through Playground is critical for debugging performance and hanging issues:
Browser request (navigation, AJAX, etc.)
ā
Service Worker intercepts fetch event
ā
broadcastMessageExpectReply() ā broadcasts to all window clients
ā
remote.html window receives message (filtered by scope) ā proxies to Web Worker
ā
PHPProcessManager.acquirePHPInstance() ā Semaphore (max 2 instances, 30s timeout)
ā
PHP-WASM executes the PHP script
ā
If PHP calls wp_remote_get(): Wp_Http_Fetch ā post_message_to_js() ā JS fetch()
ā
fetch() for loopback URLs ā goes BACK through Service Worker ā needs another PHP instance!
Timeout mismatch: The Service Worker times out waiting for a response after 25s (DEFAULT_RESPONSE_TIMEOUT), but the PHP semaphore waits up to 30s. If PHP is stuck, the Service Worker returns ERR_FAILED while the process manager is still waiting ā useful to know when diagnosing hanging requests.
Dev Server Details
| Setting | Value |
|---|
| Command | npm run dev (runs nx dev playground-website) |
| Main URL | http://127.0.0.1:5400/website-server/ |
| Ready signal | HTTP 200 from http://127.0.0.1:5400/website-server/ |
| Auto-login | Yes (logged in as admin by default) |
| HMR | Enabled ā code changes hot-reload |
Note: npm run dev also starts a PHP CORS proxy (php -S 127.0.0.1:5263). If system PHP isn't installed, that subprocess fails ā the website still loads but features relying on the CORS proxy (e.g., fetching external resources) won't work.
Workflow
1. Start the Dev Server
npm run dev
2. Navigate and Inspect
browser_navigate ā http://127.0.0.1:5400/website-server/
browser_snapshot ā see full page tree including iframe content
browser_take_screenshot ā capture visual state
3. Navigate Within WordPress
To visit WordPress pages (e.g., wp-admin), use the Playground URL bar:
browser_click ā click the URL bar textbox (labeled "URL to visit in the WordPress site")
browser_type ā type "/wp-admin/"
browser_press_key ā press "Enter"
browser_snapshot ā verify the page loaded
4. Debug Common Scenarios
Check for JavaScript errors:
browser_console_messages (level: "error") ā see JS errors and warnings
Check for stuck/failed network requests:
browser_network_requests (includeStatic: false) ā see all XHR/fetch requests and their status
Requests showing no status code are still pending. Requests with [FAILED] net::ERR_FAILED typically indicate a service worker timeout (25s) ā a sign of PHP-WASM deadlock (see "PHP-WASM Request Pipeline" above).
Time a navigation:
async (page) => {
const frame = page.frameLocator('iframe').first().frameLocator('iframe').first();
const start = Date.now();
await frame.locator('a[href="site-health.php"]').evaluate((el) => el.click());
await frame.getByRole('heading', { name: 'Site Health', level: 1 }).waitFor({ timeout: 60000 });
return `Navigation took ${Date.now() - start}ms`;
};
Inspect the block editor:
browser_click ā URL bar
browser_type ā /wp-admin/post-new.php
browser_press_key ā Enter
browser_snapshot ā see block editor structure inside iframe
Test plugin/theme UI:
browser_click ā URL bar
browser_type ā /wp-admin/plugins.php
browser_press_key ā Enter
browser_snapshot ā verify plugin list
Screenshot a specific state:
browser_take_screenshot ā capture current visual state for comparison
5. Stop the Server
Kill the npm run dev process (Ctrl+C in the terminal, or lsof -ti:5400 | xargs kill).