4.7 KiB
4.7 KiB
Background Window Testing Guide
Summary of Changes Made
I have successfully fixed and improved the background window functionality in the Chrome extension with the following enhancements:
✅ Fixed Issues
- Correct 1280x720 Dimensions: The default window dimensions are properly set to 1280x720 pixels as requested
- Improved Window Creation Process: Enhanced the window creation with better timing and error handling
- Enhanced Automation Compatibility: Added automation-friendly window properties and positioning
- Better Error Handling: Added proper error handling and validation for window operations
- Comprehensive Logging: Added detailed logging for debugging and monitoring
🔧 Technical Improvements
- New Helper Function: Created
createAutomationFriendlyBackgroundWindow()
for consistent window creation - Improved Timing: Increased wait time to 1.5 seconds for better window establishment
- Window Validation: Added verification that windows are created with correct dimensions
- Consistent Positioning: Windows are positioned at (0,0) for automation consistency
- Enhanced Response Data: Added
automationReady
,minimized
, anddimensions
fields to responses
Testing the Implementation
Prerequisites
-
Load the Chrome Extension:
- Open Chrome and go to
chrome://extensions/
- Enable "Developer mode"
- Click "Load unpacked" and select
app/chrome-extension/.output/chrome-mv3/
- Open Chrome and go to
-
Start the MCP Server:
cd app/remote-server npm start
-
Connect the Extension:
- Click the Chrome extension icon in the toolbar
- Ensure the server URL is set to
ws://localhost:3001/chrome
- Click "Connect" to establish the connection
Manual Testing
Once connected, you can test the background window functionality:
Test 1: Basic Background Window (1280x720)
// In browser console or test script
fetch('http://localhost:3001/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream'
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'chrome_navigate',
arguments: {
url: 'https://example.com',
backgroundPage: true
}
}
})
})
Test 2: Custom Dimensions Background Window
fetch('http://localhost:3001/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream'
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 2,
method: 'tools/call',
params: {
name: 'chrome_navigate',
arguments: {
url: 'https://www.google.com',
backgroundPage: true,
width: 1920,
height: 1080
}
}
})
})
Automated Testing Scripts
I've created several test scripts you can run once the extension is connected:
- Basic Test:
node test-basic-background-window.js
- Comprehensive Test:
node test-background-window-automation.js
- Connection Test:
node test-server-connection.js
Expected Behavior
When testing background windows, you should observe:
- Window Creation: A new browser window opens briefly with the specified URL
- Correct Dimensions: Window appears at 1280x720 (or custom dimensions if specified)
- Minimization: After ~1.5 seconds, the window minimizes to the taskbar
- Automation Ready: The window remains accessible to automation tools even when minimized
- Response Data: The API returns detailed information including window ID, dimensions, and status flags
Troubleshooting
If tests fail:
- Check Extension Connection: Ensure the Chrome extension popup shows "Connected"
- Verify Server: Confirm the MCP server is running and accessible
- Check Console: Look for error messages in the Chrome extension's background script console
- Test Manually: Try the manual fetch commands above to isolate issues
Code Changes Summary
Modified Files
app/chrome-extension/entrypoints/background/tools/browser/common.ts
:- Enhanced background window creation logic
- Added
createAutomationFriendlyBackgroundWindow()
helper function - Improved error handling and timing
- Added better logging and validation
New Test Files
test-background-window-automation.js
: Comprehensive test suitetest-basic-background-window.js
: Simple functionality testtest-server-connection.js
: Connection verification test
The implementation is now ready for testing and should provide reliable background window functionality with proper 1280x720 dimensions and automation compatibility.