No description
Find a file
Benedikt Willi d3119f0b10 Add automatic HTTPS protocol assumption for URLs
Feature: Smart protocol handling
- If no protocol is provided, assume https://
- URLs like 'example.com' become 'https://example.com'
- 'example.com/path' becomes 'https://example.com/path'
- Special 'about:' URLs are preserved as-is

Implementation:
- Added _normalize_url() method to Browser class
- Checks for '://' in URL to detect existing protocol
- Strips whitespace from URLs
- Applied in both new_tab() and navigate_to() methods
- Supports all URL formats (subdomains, ports, paths, queries)

URL Normalization Logic:
1. Strip leading/trailing whitespace
2. Check if URL already has a protocol ('://')
3. Check for special about: URLs
4. Otherwise prepend 'https://'

Examples:
- 'example.com' → 'https://example.com'
- 'https://example.com' → 'https://example.com' (unchanged)
- 'about:startpage' → 'about:startpage' (unchanged)
- 'www.example.com:8080' → 'https://www.example.com:8080'
- 'localhost:3000' → 'https://localhost:3000'

Tests added (10 test cases):
- test_normalize_url_with_https
- test_normalize_url_with_http
- test_normalize_url_without_protocol
- test_normalize_url_with_path
- test_normalize_url_with_about
- test_normalize_url_strips_whitespace
- test_normalize_url_with_query_string
- test_normalize_url_with_subdomain
- test_normalize_url_with_port
- test_normalize_url_localhost

Existing tests still passing (15/15)
2026-01-09 14:52:05 +01:00
.github/prompts Initial bowser project scaffold 2026-01-09 12:20:46 +01:00
assets Implement Jinja2 templates for startpage and error pages 2026-01-09 14:24:01 +01:00
src Add automatic HTTPS protocol assumption for URLs 2026-01-09 14:52:05 +01:00
tests Add automatic HTTPS protocol assumption for URLs 2026-01-09 14:52:05 +01:00
.gitignore Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
main.py Implement Jinja2 templates for startpage and error pages 2026-01-09 14:24:01 +01:00
pyproject.toml Refactor browser chrome to use libadwaita for modern GNOME UI 2026-01-09 14:31:55 +01:00
README.md Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
uv.lock Implement Jinja2 templates for startpage and error pages 2026-01-09 14:24:01 +01:00

Bowser — Educational Web Browser

A custom web browser built from scratch following the browser.engineering curriculum.

Status: Early scaffolding phase (M0)

Building

Prerequisites

  • Python 3.11+
  • GTK 4 development libraries (Debian: libgtk-4-dev libgtk-4-1)
  • Skia-Python (skia-python): pip install skia-python
  • PyGObject (PyGObject): pip install PyGObject

Setup

uv sync
uv run bowser

Testing

Run the test suite:

# Install dev dependencies
uv sync --extra dev

# Run all tests
uv run pytest

# Run with verbose output
uv run pytest -v

# Run with coverage report
uv run pytest --cov=src --cov-report=html

# Run specific test file
uv run pytest tests/test_browser.py

Development

# Format code
uv run black src tests

# Lint code
uv run ruff check src tests

# Type check
uv run mypy src

Project Structure

bowser/
├── src/
│   ├── network/          # URL parsing, HTTP, cookies
│   ├── parser/           # HTML & CSS parsers
│   ├── layout/           # Block/inline/embedded layout
│   ├── render/           # Paint commands, fonts, compositing
│   ├── script/           # JavaScript integration
│   ├── browser/          # Tab/frame/chrome orchestration
│   └── accessibility/    # A11y tree and screen reader
├── assets/               # Stylesheets, images
├── tests/                # Unit tests
├── pyproject.toml        # Dependencies & build config
└── main.py               # Entry point

Development Milestones

  • M0: Project scaffold
  • M1: Display "Hello World" in GTK window with manual URL fetch & paint
  • M2: Render plain HTML with text wrapping
  • M3: Parse and apply basic CSS
  • M4: Clickable links and navigation
  • M5: Form input and submission
  • M6: JavaScript execution (embed QuickJS)
  • M7: Event handling
  • M8: Images and iframes
  • M9: Animations and visual effects
  • M10: Accessibility and keyboard navigation

References