Re: [w3c/ServiceWorker] Inconsistencies due to when clients are created (#870)

There's a lot of confusion around `targetId`, and reading back I've made some confusing statements too. Let me try and clarify:

* `clientId` - the client that initiated the request.
* `reservedClientId` - the client that the response may create. Undefined if the response may never result in a new client (subresources).
* `targetClientId` - the client that would become unloaded if the response creates a client. Undefined if the response is not replacing an existing client.

In https://github.com/w3c/ServiceWorker/issues/870#issuecomment-208498912 I suggested that `targetClientId` may sometimes be the same as `reservedClientId`. I think this is a mistake, and probably the cause of a lot of confusion in this thread - sorry! `targetClientId` will never be the same as `reservedClientId`.

# Subresrouce

`page1.html`:

```html
<script src="script.js"></script>
```

For the request for `script.js`:

* `clientId` - the client for `page1.html`
* `reservedClientId` - undefined as this is a subresource request
* `targetClientId` - undefined as this is a subresource request

# Simple navigation

`page1.html`

```html
<a href="page2.html">Hello</a>
```

When the link is clicked without modifiers, the request for `page2.html`:

* `clientId` - the client for `page1.html`
* `reservedClientId` - the client that will be used to display `page2.html`
* `targetClientId` - the same ID as `clientId`, as page2 replaces page1

# New window navigation

`page1.html`

```html
<a href="page2.html" target="_blank">Hello</a>
```

When the link is clicked without modifiers, the request for `page2.html`:

* `clientId` - the client for `page1.html`
* `reservedClientId` - the new client that will be used to display `page2.html`
* `targetClientId` - undefined, as page2 is not replacing anything

# Other window navigation

`page1.html`

```html
<iframe name="foo" src="page2.html">
<a href="page3.html" target="foo">Hello</a>
```

When the link is clicked without modifiers, the request for `page3.html`:

* `clientId` - the client for `page1.html`
* `reservedClientId` - the new client that will be used to display `page3.html`
* `targetClientId` - the client for `page2.html`

# Worker

`page1.html`

```html
<script>new Worker('script.js');</script>
```

The request for `script.js`:

* `clientId` - the client for `page1.html`
* `reservedClientId` - the new client that will be used to execute the worker
* `targetClientId` - undefined, nothing is being replaced


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

Received on Thursday, 8 September 2016 10:38:15 UTC