Skip to content

Commit 3030854

Browse files
committed
Add browser configuration test endpoint and update README
- Introduced a new GET endpoint `/v1/test` to display current browser configuration values in an HTML format. - Enhanced the README with detailed usage instructions, response format, and various test command examples for different scenarios, including mobile and high-quality desktop tests.
1 parent 0f0d625 commit 3030854

File tree

2 files changed

+580
-0
lines changed

2 files changed

+580
-0
lines changed

README.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,42 @@ curl http://localhost:3000/v1/health
6060
}
6161
```
6262

63+
### Test Configuration
64+
65+
**GET** `/v1/test`
66+
67+
Display current browser configuration values. This endpoint returns an HTML page showing what the browser currently has set, using inline JavaScript to detect and display all browser capabilities and settings. Perfect for taking screenshots to verify browser state.
68+
69+
#### Usage
70+
71+
```bash
72+
curl http://localhost:3000/v1/test
73+
```
74+
75+
#### Response Format
76+
77+
The test endpoint returns an HTML page with a comprehensive visual display of current browser configuration values. The page includes:
78+
79+
- **Viewport & Display**: Screen dimensions, device pixel ratio
80+
- **Theme & Appearance**: Color scheme detection
81+
- **Localization**: Language, timezone settings
82+
- **Device & Hardware**: Touch support, mobile detection
83+
- **User Agent**: Current user agent string
84+
- **Geolocation**: GPS coordinates and accuracy (if available)
85+
- **Permissions**: Browser permission states
86+
- **Page Information**: URL, title, ready state
87+
88+
The HTML page automatically adapts to the browser's theme preference (light/dark) and uses inline JavaScript to display real-time browser values.
89+
90+
#### Use Cases
91+
92+
- **Browser State Inspection**: See what the browser currently has configured
93+
- **Visual Verification**: Take screenshots to verify browser capabilities
94+
- **Debugging**: Visual inspection of browser configuration issues
95+
- **Documentation**: Generate visual examples of browser behavior
96+
- **Screenshot Testing**: Perfect for testing the screenshot API itself
97+
- **Development**: Quick way to check browser state during development
98+
6399
### Screenshots
64100

65101
**POST** `/v1/screenshots`
@@ -299,6 +335,188 @@ curl -X POST http://localhost:3000/v1/screenshots \
299335
}'
300336
```
301337

338+
#### Comprehensive Test Command
339+
340+
Here's a complete test command that showcases all available parameters:
341+
342+
```bash
343+
curl -X POST http://localhost:3000/v1/screenshots \
344+
-H "Content-Type: application/json" \
345+
-d '{
346+
"url": "https://example.com",
347+
"viewport": {
348+
"width": 1920,
349+
"height": 1080
350+
},
351+
"format": "jpeg",
352+
"quality": 95,
353+
"fullPage": true,
354+
"theme": "dark",
355+
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
356+
"locale": "en-US",
357+
"timezoneId": "America/New_York",
358+
"geolocation": {
359+
"latitude": 40.7128,
360+
"longitude": -74.0060,
361+
"accuracy": 100
362+
},
363+
"permissions": [
364+
"geolocation",
365+
"notifications",
366+
"camera",
367+
"microphone",
368+
"clipboard-read",
369+
"clipboard-write"
370+
],
371+
"headers": {
372+
"Authorization": "Bearer test-token-12345",
373+
"X-Custom-Header": "test-value",
374+
"X-Request-ID": "screenshot-test-001"
375+
},
376+
"waitUntil": "networkidle",
377+
"timeout": 60000,
378+
"sleep": 5000,
379+
"deviceScaleFactor": 2,
380+
"hasTouch": true,
381+
"isMobile": false
382+
}' \
383+
--output "comprehensive-test-screenshot.jpg"
384+
```
385+
386+
#### Mobile Device Test Command
387+
388+
```bash
389+
curl -X POST http://localhost:3000/v1/screenshots \
390+
-H "Content-Type: application/json" \
391+
-d '{
392+
"url": "https://example.com",
393+
"viewport": {
394+
"width": 375,
395+
"height": 667
396+
},
397+
"format": "png",
398+
"quality": 90,
399+
"fullPage": true,
400+
"theme": "light",
401+
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1",
402+
"locale": "en-US",
403+
"timezoneId": "America/Los_Angeles",
404+
"geolocation": {
405+
"latitude": 37.7749,
406+
"longitude": -122.4194,
407+
"accuracy": 50
408+
},
409+
"permissions": [
410+
"geolocation",
411+
"camera",
412+
"microphone",
413+
"notifications"
414+
],
415+
"headers": {
416+
"X-Mobile-App": "true",
417+
"X-Device-Type": "mobile"
418+
},
419+
"waitUntil": "domcontentloaded",
420+
"timeout": 30000,
421+
"sleep": 3000,
422+
"deviceScaleFactor": 3,
423+
"hasTouch": true,
424+
"isMobile": true
425+
}' \
426+
--output "mobile-test-screenshot.png"
427+
```
428+
429+
#### High-Quality Desktop Test Command
430+
431+
```bash
432+
curl -X POST http://localhost:3000/v1/screenshots \
433+
-H "Content-Type: application/json" \
434+
-d '{
435+
"url": "https://example.com",
436+
"viewport": {
437+
"width": 2560,
438+
"height": 1440
439+
},
440+
"format": "jpeg",
441+
"quality": 100,
442+
"fullPage": true,
443+
"theme": "dark",
444+
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
445+
"locale": "en-US",
446+
"timezoneId": "Europe/London",
447+
"geolocation": {
448+
"latitude": 51.5074,
449+
"longitude": -0.1278,
450+
"accuracy": 20
451+
},
452+
"permissions": [
453+
"geolocation",
454+
"notifications",
455+
"camera",
456+
"microphone",
457+
"clipboard-read",
458+
"clipboard-write",
459+
"payment-handler",
460+
"usb",
461+
"bluetooth"
462+
],
463+
"headers": {
464+
"Authorization": "Bearer premium-token",
465+
"X-Premium-User": "true",
466+
"X-Request-Source": "screenshot-api"
467+
},
468+
"waitUntil": "networkidle",
469+
"timeout": 90000,
470+
"sleep": 8000,
471+
"deviceScaleFactor": 2,
472+
"hasTouch": false,
473+
"isMobile": false
474+
}' \
475+
--output "high-quality-desktop-screenshot.jpg"
476+
```
477+
478+
#### Clipped Screenshot Test Command
479+
480+
```bash
481+
curl -X POST http://localhost:3000/v1/screenshots \
482+
-H "Content-Type: application/json" \
483+
-d '{
484+
"url": "https://example.com",
485+
"viewport": {
486+
"width": 1920,
487+
"height": 1080
488+
},
489+
"format": "png",
490+
"quality": 90,
491+
"fullPage": false,
492+
"clip": {
493+
"x": 100,
494+
"y": 100,
495+
"width": 800,
496+
"height": 600
497+
},
498+
"theme": "light",
499+
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0",
500+
"locale": "en-GB",
501+
"timezoneId": "Europe/Berlin",
502+
"permissions": [
503+
"geolocation",
504+
"notifications"
505+
],
506+
"headers": {
507+
"X-Test-Mode": "clipped-screenshot",
508+
"X-Region": "europe"
509+
},
510+
"waitUntil": "load",
511+
"timeout": 45000,
512+
"sleep": 2000,
513+
"deviceScaleFactor": 1.5,
514+
"hasTouch": false,
515+
"isMobile": false
516+
}' \
517+
--output "clipped-screenshot.png"
518+
```
519+
302520
### Common Use Cases
303521

304522
- **E-commerce**: Test pricing displays in different timezones

0 commit comments

Comments
 (0)