background-fetch.idl (3197B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: Background Fetch (https://wicg.github.io/background-fetch/) 5 6 partial interface ServiceWorkerGlobalScope { 7 attribute EventHandler onbackgroundfetchsuccess; 8 attribute EventHandler onbackgroundfetchfail; 9 attribute EventHandler onbackgroundfetchabort; 10 attribute EventHandler onbackgroundfetchclick; 11 }; 12 13 partial interface ServiceWorkerRegistration { 14 readonly attribute BackgroundFetchManager backgroundFetch; 15 }; 16 17 [Exposed=(Window,Worker)] 18 interface BackgroundFetchManager { 19 Promise<BackgroundFetchRegistration> fetch(DOMString id, (RequestInfo or sequence<RequestInfo>) requests, optional BackgroundFetchOptions options = {}); 20 Promise<BackgroundFetchRegistration?> get(DOMString id); 21 Promise<sequence<DOMString>> getIds(); 22 }; 23 24 dictionary BackgroundFetchUIOptions { 25 sequence<ImageResource> icons; 26 DOMString title; 27 }; 28 29 dictionary BackgroundFetchOptions : BackgroundFetchUIOptions { 30 unsigned long long downloadTotal = 0; 31 }; 32 33 [Exposed=(Window,Worker)] 34 interface BackgroundFetchRegistration : EventTarget { 35 readonly attribute DOMString id; 36 readonly attribute unsigned long long uploadTotal; 37 readonly attribute unsigned long long uploaded; 38 readonly attribute unsigned long long downloadTotal; 39 readonly attribute unsigned long long downloaded; 40 readonly attribute BackgroundFetchResult result; 41 readonly attribute BackgroundFetchFailureReason failureReason; 42 readonly attribute boolean recordsAvailable; 43 44 attribute EventHandler onprogress; 45 46 Promise<boolean> abort(); 47 Promise<BackgroundFetchRecord> match(RequestInfo request, optional CacheQueryOptions options = {}); 48 Promise<sequence<BackgroundFetchRecord>> matchAll(optional RequestInfo request, optional CacheQueryOptions options = {}); 49 }; 50 51 enum BackgroundFetchResult { "", "success", "failure" }; 52 53 enum BackgroundFetchFailureReason { 54 // The background fetch has not completed yet, or was successful. 55 "", 56 // The operation was aborted by the user, or abort() was called. 57 "aborted", 58 // A response had a not-ok-status. 59 "bad-status", 60 // A fetch failed for other reasons, e.g. CORS, MIX, an invalid partial response, 61 // or a general network failure for a fetch that cannot be retried. 62 "fetch-error", 63 // Storage quota was reached during the operation. 64 "quota-exceeded", 65 // The provided downloadTotal was exceeded. 66 "download-total-exceeded" 67 }; 68 69 [Exposed=(Window,Worker)] 70 interface BackgroundFetchRecord { 71 readonly attribute Request request; 72 readonly attribute Promise<Response> responseReady; 73 }; 74 75 [Exposed=ServiceWorker] 76 interface BackgroundFetchEvent : ExtendableEvent { 77 constructor(DOMString type, BackgroundFetchEventInit init); 78 readonly attribute BackgroundFetchRegistration registration; 79 }; 80 81 dictionary BackgroundFetchEventInit : ExtendableEventInit { 82 required BackgroundFetchRegistration registration; 83 }; 84 85 [Exposed=ServiceWorker] 86 interface BackgroundFetchUpdateUIEvent : BackgroundFetchEvent { 87 constructor(DOMString type, BackgroundFetchEventInit init); 88 Promise<undefined> updateUI(optional BackgroundFetchUIOptions options = {}); 89 };