Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE_INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Status values:
| 06 | `module-06-cloud-run` | Next | Research candidate | Cloud Run deployment evidence | Network, Performance, Security | Cloud Run | Medium | TBD | Serverless deployment proof | Needs manual review |
| 07 | `module-07-appengine-push-tasks` | Implemented / evidence pending | Official Google codelab / baseline implemented | App Engine Push Task Queues baseline before Module 08 Cloud Tasks | Network, Console, Cloud Logging | App Engine, Task Queue push queues | Medium | `gae-flask-module-1/mod7-gaetasks-baseline/README-module-07.md` + `docs/modules/module-07-appengine-push-tasks/` | Push Task Queue baseline with local tests; deploy/evidence deferred | Requires gated deploy/evidence PR |
| 08 | `module-08-cloud-tasks-plan` | Later | Official Google codelab / research planning | Cloud Tasks migration plan | Network, Console, Cloud Logging | App Engine, Cloud Tasks | Medium | `docs/modules/module-08-cloud-tasks-plan/` | Cloud Tasks migration planning package | Needs manual review |
| 09 | `module-09-pwa-service-worker` | Later | Research candidate | Offline-capable demo | Application, Network | Optional hosting | Medium | TBD | PWA evidence | Needs manual review |
| 09 | `module-09-pwa-service-worker` | Done | Research candidate | Offline-capable demo | Application, Network | Optional hosting | Medium | `docs/modules/module-09-pwa-service-worker/` | PWA evidence | Needs manual review |
| 10 | `module-10-security-panel` | Done | Research candidate | HTTPS, mixed content, cookie/security review | Security, Application, Network | Optional hosting | Medium | `docs/modules/module-10-security-panel/` | Security review practice | Allowed public-safe documentation/checklist pattern |
| 11 | `module-11-accessibility-audit` | Done | Research candidate | A11y checklist and fixes | Lighthouse, Elements, Accessibility | None | Low | `docs/modules/module-11-accessibility-audit/` | Accessibility proof | Allowed public-safe documentation/checklist pattern |
| 12 | `module-12-devtools-sources-debugging` | Done | Research candidate | JS debugging scenario | Sources, Console | None | Low | `docs/modules/module-12-sources-debugging/` | Debugging portfolio scenario | Allowed public-safe documentation/checklist pattern |
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This repository is not just a collection of learning notes. It is designed as a
| Module 03 | Done | Cloud NDB to Cloud Datastore migration | Network, Console, Application, Security |
| Module 04 | Done | App Engine to Cloud Run with Docker | Network, Console, Application, Security |
| Module 05 | Done | Cloud Run migration using Cloud Buildpacks | Network, Console, Application, Security |
| Module 09 | Done | PWA / Service Worker offline caching | Application, Network |
| Module 10 | Done | HTTPS, mixed content, cookie/security review | Security, Application, Network |
| Module 11 | Done | Accessibility checklist and fixes | Lighthouse, Elements, Accessibility |
| Module 12 | Done | JS debugging scenario (sources/debugging) | Sources, Console |
Expand Down
67 changes: 67 additions & 0 deletions docs/modules/module-09-pwa-service-worker/MODULE_09A_PWA_PLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Module 09-A — PWA / Service Worker Plan

## Purpose

This document outlines the planning phase for **Module 09 — PWA / Service Worker**.

The goal of this module is to learn how to audit, configure, and verify Progressive Web App (PWA) components—specifically Service Workers, caching strategies, offline loading, and Web App Manifests—using **Chrome DevTools** (Application and Network panels) in a safe local-first workflow.

---

## 1. Scope & Objectives

This module runs completely locally using loopback interfaces to simulate secure contexts required for Service Worker operations.

### Learning Goals
* **Service Worker Registration**: Understand how to register, inspect, and trace the lifecycle (installing, waiting, active) of a local service worker.
* **Offline Caching Mechanics**: Implement basic caching strategies (Cache-First or Stale-While-Revalidate) for core static assets.
* **DevTools Application Panel Auditing**: Learn to inspect the Service Workers section, read parsed parameters in the Manifest section, and check assets stored in Cache Storage.
* **Offline Simulation**: Verify that the application functions when the network state is set to "Offline" in Chrome DevTools.
* **Safety & Resource Guardrails**: Prevent cloud resource overhead and ensure no credentials or user data are exposed.

---

## 2. Planned Demo Scenario

A safe local demo will be created under `experiments/module-09-pwa-demo/`:

| File | Purpose |
|---|---|
| `index.html` | Simple HTML page featuring synthetic interaction and PWA registration logic. |
| `styles.css` | Simple Vanilla CSS styling to verify cached asset application. |
| `app.js` | Main client-side script that registers the service worker. |
| `sw.js` | The Service Worker containing installation, caching, and fetch-intercept logic. |
| `manifest.json` | Web App Manifest file defining app branding, start URL, and display options. |
| `README.md` | Run and inspection instructions. |

---

## 3. Chrome DevTools Verification Plan

Verification will be conducted using the following DevTools sections:

### Application Panel
* **Manifest Section**: Check that `manifest.json` is detected, parses without syntax warnings, and displays branding/icon metadata.
* **Service Workers Section**: Verify status is `active and running`. Test the "Update on reload" and "Bypass for network" controls.
* **Cache Storage**: Confirm that `v1` (or local cache name) is populated with cached URLs (`/`, `/styles.css`, `/app.js`, `/manifest.json`).

### Network Panel
* **Fetch Source**: Reload the page with DevTools open and check that the Size column shows `(from ServiceWorker)` for static assets.
* **Offline Toggle**: Set the network throttling selector to **Offline**, reload the page, and verify the application still renders with cached assets.

### Console Panel
* **Logs**: Verify clean logs regarding Service Worker registration success and cache storage hits. Confirm no unexpected script errors.

---

## 4. Safety and Boundary Confirmation

* **No Cloud Deployment**: Executed on a local HTTP loopback port (e.g. `8096`).
* **No Secrets/Credentials**: No external API keys, service accounts, or `.env` files are needed.
* **No PHI/Health Data**: Zero patient data or medical exports will be handled.

---

## 5. Next Step

* **Next Step**: Proceed to `Module 09-B` to create the **Safe Local PWA Demo** files in `experiments/module-09-pwa-demo/`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Module 09-B — Safe Local PWA Caching Demo

## Purpose

This step adds a safe local-only Progressive Web App (PWA) static demo for Chrome DevTools Service Worker and Cache Storage inspection practice.

---

## Files Added

| File | Purpose |
|---|---|
| `experiments/module-09-pwa-demo/index.html` | PWA demo page with status element and trigger button. |
| `experiments/module-09-pwa-demo/styles.css` | Styling verified to load from cache when offline. |
| `experiments/module-09-pwa-demo/app.js` | Client-side script managing sw registration and status updates. |
| `experiments/module-09-pwa-demo/sw.js` | Service Worker code implementing install/activate and fetch intercept. |
| `experiments/module-09-pwa-demo/manifest.json` | Web App Manifest providing metadata (names, start URL, background/theme colors). |
| `experiments/module-09-pwa-demo/README.md` | Start command and detailed auditing steps. |

---

## Run Locally

Since Service Workers require a secure origin (HTTPS or localhost/127.0.0.1 loopbacks), serve the demo folder locally:

```powershell
cd C:\Users\YeniKullanici\chrome-devtools-cloud-migration-lab\experiments\module-09-pwa-demo
python -m http.server 8096
```

Then navigate to:
```text
http://127.0.0.1:8096/
```

---

## What the Demo Does

* **Registers a Service Worker**: Registers `sw.js` immediately upon loading.
* **Pre-caches Static Assets**: During the Service Worker install phase, it opens a Cache Storage bucket named `pwa-cache-v1` and downloads the files listed in the `ASSETS` array.
* **Intercepts Fetch Requests**: Intercepts requests for resources. If a resource is present in the cache, it serves it immediately without hitting the network.
* **Updates Connection Status**: Listens to the browser's `online`/`offline` state and updates the UI accordingly.
* **Keeps Actions Local**: Interactive buttons and forms use event handlers that do not call external APIs.

---

## DevTools Inspection Targets

### 1. Application Panel -> Manifest
* Check that `manifest.json` parses successfully and displays branding details and data URI-based icon previews.

### 2. Application Panel -> Service Workers
* Verify that `sw.js` is active and running.
* Check the **Update on reload** checkbox to force fresh SW updates.

### 3. Application Panel -> Cache Storage
* Expand the `pwa-cache-v1` bucket to view the cached keys (`index.html`, `styles.css`, `app.js`, `manifest.json`, and `/`).

### 4. Network Panel -> Offline Emulation
* Change throttling to **Offline** and reload the page. Verify the page still loads correctly from the Service Worker cache.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Module 09-C — Initial PWA / Service Worker Baseline Evidence

## Purpose

This document records the baseline (unmitigated) Chrome DevTools observations for the local web demo *before* any Service Worker or Web App Manifest features are registered or activated.

---

## Environment

| Item | Value |
|---|---|
| Demo path | `experiments/module-09-pwa-demo/` |
| Local command | `python -m http.server 8096` |
| Local URL | `http://127.0.0.1:8096/` |
| Scope | Baseline unmitigated state observation |

---

## 1. Initial Service Worker Check

We inspected the **Application Panel** -> **Service Workers** section before page load:

* **Observation**: No active Service Worker is registered for the origin `http://127.0.0.1:8096/`.
* **Console Logs**: The browser console shows no Service Worker registration messages.

---

## 2. Initial Cache Storage Check

We inspected the **Application Panel** -> **Cache Storage** section:

* **Observation**: The Cache Storage tree is empty. No cache buckets exist.
* **Interpretation**: Without a service worker cache hook, static assets are never stored in the browser's persistent cache.

---

## 3. Offline Test Failure (Vulnerability Verification)

To verify the vulnerability, we configured the Chrome DevTools **Network Panel** throttling state to **Offline** and reloaded the page:

* **Result**:
- The page failed to load.
- The browser rendered the standard **"No Internet" (ERR_INTERNET_DISCONNECTED)** screen.
- No CSS styles or JavaScript files were accessible.
* **Interpretation**: This confirms **FIND-01 (Offline Denied Service)**. The baseline website is entirely dependent on an active network connection and has no resilience.

---

## 4. Web App Manifest Check

We checked the **Application Panel** -> **Manifest** section:

* **Observation**: No web app manifest file was linked in the header of the page.
* **DevTools warning**: DevTools reported that no manifest could be fetched, meaning the application is not installable on home screens.

---

## Safety & Compliance Verification

* **Zero Cloud Usage**: Conducted entirely locally.
* **Zero Secrets**: No keys or credentials were used or tracked.
* **Zero PHI**: No patient-level details were imported.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Module 09-D — Offline Caching Remediation Plan

## Purpose

This document translates the audit findings from the baseline static server inspection into a structured remediation plan to enable Progressive Web App (PWA) installability, offline accessibility, and resilient static caching.

---

## 1. Audit Findings Summary

Prior to implementing PWA features, a basic static website served via a default HTTP server suffers from the following resilience and performance exposures:

| Finding ID | Exposure | Description | DevTools Evidence Source | Risk Level |
|---|---|---|---|---|
| **FIND-01** | **Offline Denied Service** | If the network drops or the server is unavailable, page requests fail with a browser-side "No Internet" screen. | Network Panel (Offline throttle) | High (Usability) |
| **FIND-02** | **Lack of App Installability** | The web application cannot be added to a mobile home screen or launch as a standalone window. | Application Panel (Manifest) | Medium |
| **FIND-03** | **Network-Dependent Rendering** | Static assets like styles and scripts must be retrieved from the network on every load, risking layout shifts and slow load times. | Network Panel / Waterfall | Medium |

---

## 2. Remediation Plan

To mitigate these findings, we will implement client-side caching and branding controls using Service Workers and a Web App Manifest.

### Remediation Details

#### **Remediation for FIND-01 (Offline Access via Service Worker)**
* **Solution**: Register a Service Worker (`sw.js`) during page load. The Service Worker will listen to the `fetch` event and intercept all asset requests.
* **Fallback Strategy**: If a resource is matched in the Cache Storage, serve it immediately. If not, fetch it from the network, cache it dynamically, and return it.

#### **Remediation for FIND-02 (Installability via Manifest)**
* **Solution**: Implement a standardized `manifest.json` file. Link it inside the `<head>` of the HTML.
* **Manifest Directives**:
- `short_name` / `name` for home screen labeling.
- `start_url` set to `./index.html`.
- `display: standalone` to strip browser frames.
- SVG data URI icons to represent branding without bloating repo assets.

#### **Remediation for FIND-03 (Static Caching in Install Lifecycle)**
* **Solution**: Cache essential assets during the Service Worker's `install` event.
* **Asset List**: Cache `/`, `index.html`, `styles.css`, `app.js`, and `manifest.json` immediately so they are available offline.

---

## 3. Implementation Strategy (For Step 09-E)

In Step 09-E, we:
1. Create `experiments/module-09-pwa-demo/sw.js` containing the lifecycle and fetch logic.
2. Link `manifest.json` and `styles.css` inside `index.html`.
3. Add PWA registration in `app.js`.

---

## 4. Safety & Compliance Boundary

* **No Cloud Hosting**: All testing and verification remain strictly local on loopback port `8096`.
* **No Secret Storage**: The manifest and service worker do not hold API keys, credentials, or session cookies.
* **No PHI**: Demos deal purely with connection status and mock interactions. No patient data is accessed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Module 09-F — PWA / Service Worker Validation Evidence

## Purpose

This document records the post-remediation validation evidence for the Module 9 Progressive Web App (PWA) demo. Following the plan in [MODULE_09D_PWA_REMEDIATION_PLAN.md](file:///C:/Users/YeniKullanici/chrome-devtools-cloud-migration-lab/docs/modules/module-09-pwa-service-worker/MODULE_09D_PWA_REMEDIATION_PLAN.md), we verify that registering the Service Worker and Web App Manifest successfully mitigates the offline accessibility issues.

---

## Environment

| Item | Value |
|---|---|
| Demo path | `experiments/module-09-pwa-demo/` |
| Local command | `python -m http.server 8096` |
| Local URL | `http://127.0.0.1:8096/` |
| Scope | Post-remediation browser-side validation |

---

## 1. Service Worker Lifecycle Verification

After registering the Service Worker, we verified its status in Chrome DevTools **Application Panel** -> **Service Workers**:

* **Console Registration Logs**:
```text
[info] Service Worker registered successfully with scope: http://127.0.0.1:8096/
```
* **Lifecycle State**: The Service Worker `sw.js` is active and running:
- Status: `active and running`
- Scope: `http://127.0.0.1:8096/`
- Controls: "Update on reload" was enabled to ease live editing.

---

## 2. Cache Storage Verification

We audited the browser's Cache Storage via JS evaluation:

```javascript
caches.open('pwa-cache-v1')
.then(cache => cache.keys())
.then(keys => keys.map(k => k.url))
```

### Script Output
```json
[
"http://127.0.0.1:8096/index.html",
"http://127.0.0.1:8096/styles.css",
"http://127.0.0.1:8096/app.js",
"http://127.0.0.1:8096/manifest.json",
"http://127.0.0.1:8096/"
]
```

* **Observation**: All essential static files are successfully cached in the `pwa-cache-v1` storage bucket.

---

## 3. Offline Navigation Resiliency

To verify that the offline failure (**FIND-01**) has been fully resolved, we emulated **Offline** conditions in the **Network Panel** and reloaded the page:

* **Emulated state**: `Offline`
* **UI Network Status Element**: The page detected the offline state and successfully updated:
- Text: `Offline`
- Class: `status-indicator status-offline` (renders red status tag)
* **Offline Rendering**: The page reloaded and rendered instantly.
* **Network Tab Source**: Static assets (`styles.css`, `app.js`, `manifest.json`, and `/`) showed fetch size `(from ServiceWorker)`.

### Server Traffic Verification during Offline Load
The static server log (`task-966.log`) shows that during the offline load, no network requests reached the Python backend server for the page content, styles, or scripts:

```text
::ffff:127.0.0.1 - - [17/Jun/2026 19:40:28] "GET /sw.js HTTP/1.1" 304 -
```
*Note: The browser makes a default background check for `sw.js` updates when network-connected, but all page presentation resources were served locally from the cache.*

---

## 4. Web App Manifest Audit

We inspected the Web App Manifest in **Application Panel** -> **Manifest**:

* **Manifest File**: `manifest.json` linked and parsed without warnings.
* **Identity**:
- Name: `Module 9 PWA Offline Cache Demo`
- Short Name: `PWA Demo`
* **Presentation**:
- Display: `standalone`
- Theme Color: `#0288d1`
- SVG data URI icons render and scale correctly.

---

## Safety & Compliance Verification

* **Zero Cloud Usage**: Serviced completely on local loopback.
* **Zero Secrets**: No API keys or session identifiers stored or logged.
* **Zero PHI**: Mock connection UI only; no patient data accessed.

## Conclusion

The post-remediation evidence shows that the PWA offline caching has been successfully verified. The application is resilient to network failures, serves assets from cache, and registers a valid installable Web App Manifest within our safe local sandbox.
Loading
Loading