[w3c/ServiceWorker] A strange behavior about iframe nested service worker clients (Issue #1637)

**Prepare**

1. `git clone git@github.com:fytriht/sw-iframe-devtools-bug-reproduce.git` ([the repo](https://github.com/fytriht/sw-iframe-devtools-bug-reproduce))
2. `npm insall`
3. `npm run serve`

now we got two pages
- _page container_ at http://localhost:51000
- _page inner_ at http://localhost:51001

**Step to reproduce**

1. open a chrome incognito browser tab
2. **open DevTools** (this is important)
3. load _page container_ at http://localhost:51000
5. a log is shown in the console, and there is sw.mjs context, which are expected.
<img width="400" alt="image" src="https://user-images.githubusercontent.com/20026577/160525519-675ac0df-ad6c-4e9d-ad88-e2708d4517d1.png">

6. however, now reload the page (F5)
7. there are no logs and sw context

<img width="400" alt="mage" src="https://user-images.githubusercontent.com/20026577/160525686-9fc17d6d-08cd-46f3-a29b-2d4b6c2df355.png">

it looks like that there is no service worker at all, which makes debugging difficult and confusing.

Note:
1. If page loaded without DevTools opened, everything works fine.
2. If _page inner_ is not nested iframe, everything works fine too.
    1. To reproduce: use the same steps above, except that directly open _page inner_ at http://localhost:51001

**To make it more stranger, consider this:**

1. reload _page container_ multiple times
2. no logs in console
3. open _page inner_ in another tab
5. multiple logs in _page inner_'s console (expects only 1)

<img width="872" alt="image" src="https://user-images.githubusercontent.com/20026577/160527312-f9eb2996-cb31-4bae-9ae1-e6c709b64105.png">

https://user-images.githubusercontent.com/20026577/160531158-d73e5857-019c-422a-9222-ea8e02f339f1.mp4

----

Not sure if this the right place to open issue, if not, please let me know. Thanks!



-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1637
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/issues/1637@github.com>

Received on Tuesday, 29 March 2022 04:20:53 UTC