Re: [ServiceWorker] How are unloaded tabs represented? (#626)

How about:

```js
clients.matchAll({
  includeEvicted: true
})
```

`includeEvicted` will include `EvictedWindowClient`s - clients that have been evicted from memory, but can be restored

```
[Exposed=ServiceWorker]
interface Client {
  readonly attribute USVString url;
  readonly attribute FrameType frameType;
  readonly attribute DOMString id;
};

[Exposed=ServiceWorker]
interface ActiveClient : Client {
  void postMessage(any message, optional sequence<Transferable> transfer);
};

[Exposed=ServiceWorker]
interface WindowClient : ActiveClient {
  readonly attribute VisibilityState visibilityState;
  readonly attribute boolean focused;
  Promise<WindowClient> focus();
};

[Exposed=ServiceWorker]
interface EvictedWindowClient : Client {
  Promise<WindowClient> focus();
};

enum FrameType {
  "auxiliary",
  "top-level",
  "nested",
  "none"
};
```

`EvictedWindowClient` have the `url`, `frameType` and `id` that they had prior to eviction. It does not have `postMessage`.

`evictedWindowClient.focus()` restores the tab (however the UA does that), then focuses the window, then resolves. Note that it resolves with a `WindowClient`, which will allow postmessaging.

`EvictedWindowClient`s do not prevent a ServiceWorker from moving from `waiting` to `active`. On restoring a `EvictedWindowClient`, if it was evicted while under the control of a SW that's no longer active, or it was `.claim()`ed while evicted, it should do a full reload rather than any cleverer restoration.

Thoughts?

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/626#issuecomment-95207076

Received on Wednesday, 22 April 2015 14:30:25 UTC