Purpose of this document
To document the scope and known caveats of Service Worker in Chrome M40.
Publicly shared
API caveats
See this document for the Service Worker Cache APIs’s Scope and Caveats.
Development caveats
Implementation caveats
Known caveats
[Exposed=(Window,ServiceWorker)]
interface ServiceWorker : Worker {
readonly attribute ScalarValueString scriptURL;
readonly attribute ServiceWorkerState state;
// event
attribute EventHandler onstatechange;
// terminate() method inherited from Worker should not be accessible.
};
enum ServiceWorkerState {
"installing",
"installed",
"activating",
"activated",
"redundant"
};
[Exposed=Window]
interface ServiceWorkerContainer : EventTarget {
[Unforgeable] readonly attribute ServiceWorker? controller;
readonly attribute Promise<ServiceWorkerRegistration> ready;
Promise<ServiceWorkerRegistration> register(ScalarValueString scriptURL, optional
RegistrationOptions options);
Promise<ServiceWorkerRegistration> getRegistration(optional ScalarValueString documentURL = "");
};
dictionary RegistrationOptionList {
ScalarValueString scope = "/";
};
[Exposed=Window]
interface ServiceWorkerRegistration : EventTarget {
[Unforgeable] readonly attribute ServiceWorker? installing;
[Unforgeable] readonly attribute ServiceWorker? waiting;
[Unforgeable] readonly attribute ServiceWorker? active;
readonly attribute ScalarValueString scope;
Promise<any> unregister();
// event
attribute EventHandler onupdatefound;
};
[Global=(Worker,ServiceWorker), Exposed=ServiceWorker]
interface ServiceWorkerGlobalScope : WorkerGlobalScope {
// A container for a list of window objects, identifiable by ID, that
// correspond to windows (or workers) that are "controlled" by this SW
readonly attribute ServiceWorkerClients clients;
[Unforgeable] readonly attribute ScalarValueString scope;
// fetch(input, init) method is defined in Fetch
Promise<Response> fetch(RequestInfo input, optional RequestInit init);
attribute EventHandler oninstall;
attribute EventHandler onactivate;
attribute EventHandler onfetch;
attribute EventHandler onmessage;
// The event.source of these MessageEvents are instances of Client
// close() method inherited from WorkerGlobalScope should not be accessible.
};
[Exposed=ServiceWorker]
interface ServiceWorkerClient {
readonly attribute unsigned long id; // id obsolete, do not rely on it (crbug.com/407944)
void postMessage(any message, optional sequence<Transferable> transfer);
};
[Exposed=ServiceWorker]
interface ServiceWorkerClients {
// The objects returned will be new instances every time
Promise<sequence<ServiceWorkerClient>?> getAll(optional ServiceWorkerClientQueryOptions options);
};
dictionary ServiceWorkerClientQueryOptions {
boolean includeUncontrolled;
};
[NoInterfaceObject, Exposed=(ServiceWorker)]
interface Body {
Promise<ArrayBuffer> arrayBuffer();
Promise<Blob> blob();
Promise<JSON> json();
Promise<ScalarValueString> text();
};
typedef (ArrayBuffer or ArrayBufferView or Blob or FormData or ScalarValueString) BodyInit;
typedef (Request or ScalarValueString) RequestInfo;��[Constructor(RequestInfo input, optional RequestInit init), Exposed=(ServiceWorker)]�interface Request {� readonly attribute ByteString method;� readonly attribute ScalarValueString url;� readonly attribute Headers headers;� readonly attribute DOMString referrer;� readonly attribute RequestMode mode;� readonly attribute RequestCredentials credentials;
Request clone();�};
Request implements Body;
dictionary RequestInit {� ByteString method;� HeadersInit headers;� BodyInit body;� RequestMode mode;� RequestCredentials credentials;�};�
�enum RequestMode { "same-origin", "no-cors", "cors" };�enum RequestCredentials { "omit", "same-origin", "include" };
[Constructor(optional BodyInit body, optional ResponseInit init), Exposed=(ServiceWorker)]�interface Response {� readonly attribute ResponseType type;� readonly attribute ScalarValueString url;� readonly attribute unsigned short status;� readonly attribute ByteString statusText;� readonly attribute Headers headers;�
Response clone();
};
Response implements Body;
dictionary ResponseInit {� unsigned short status = 200;� ByteString statusText = "OK";� HeadersInit headers;�};�
enum ResponseType { "basic", "cors", "default", "error", "opaque" };
[Constructor(optional HeadersInit init), Exposed=(ServiceWorker)]
interface Headers {
void append(ByteString name, ByteString value);
void delete(ByteString name);
ByteString? get(ByteString name);
sequence<ByteString> getAll(ByteString name);
boolean has(ByteString name);
void set(ByteString name, ByteString value);
};
typedef (Headers or sequence<sequence<ByteString>> or OpenEndedDictionary<ByteString>) HeadersInit;