1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html 8 * 9 */ 10 11[Func="ServiceWorkerContainer::IsEnabled", 12 Exposed=Window] 13interface ServiceWorkerContainer : EventTarget { 14 // FIXME(nsm): 15 // https://github.com/slightlyoff/ServiceWorker/issues/198 16 // and discussion at https://etherpad.mozilla.org/serviceworker07apr 17 [Unforgeable] readonly attribute ServiceWorker? controller; 18 19 [Throws] 20 readonly attribute Promise<ServiceWorkerRegistration> ready; 21 22 [NewObject] 23 Promise<ServiceWorkerRegistration> register(USVString scriptURL, 24 optional RegistrationOptions options); 25 26 [NewObject] 27 Promise<any> getRegistration(optional USVString documentURL = ""); 28 29 [NewObject] 30 Promise<sequence<ServiceWorkerRegistration>> getRegistrations(); 31 32 attribute EventHandler oncontrollerchange; 33 attribute EventHandler onerror; 34 attribute EventHandler onmessage; 35}; 36 37// Testing only. 38partial interface ServiceWorkerContainer { 39 [Throws,Pref="dom.serviceWorkers.testing.enabled"] 40 DOMString getScopeForUrl(DOMString url); 41}; 42 43dictionary RegistrationOptions { 44 USVString scope; 45 ServiceWorkerUpdateViaCache updateViaCache = "imports"; 46}; 47