Update the background-fetch IDL file + test (#11937)
diff --git a/background-fetch/idlharness.any.js b/background-fetch/idlharness.any.js
new file mode 100644
index 0000000..ad20477
--- /dev/null
+++ b/background-fetch/idlharness.any.js
@@ -0,0 +1,25 @@
+// META: global=window,worker
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+
+'use strict';
+
+// https://wicg.github.io/background-fetch/
+
+idl_test(
+ ['background-fetch'],
+ ['service-workers', 'dedicated-workers', 'dom'],
+ idl_array => {
+ const isServiceWorker = location.pathname.includes('.serviceworker.');
+ if (isServiceWorker) {
+ idl_array.add_objects({
+ ServiceWorkerGlobalScope: ['self'],
+ ServiceWorkerRegistration: ['registration'],
+ BackgroundFetchManager: ['registration.backgroundFetch'],
+ BackgroundFetchEvent: ['new BackgroundFetchEvent("type")'],
+ BackgroundFetchUpdateEvent: ['new BackgroundFetchUpdateEvent("type")'],
+ });
+ }
+ },
+ 'background-fetch interfaces'
+);
diff --git a/background-fetch/interfaces.https.any.js b/background-fetch/interfaces.https.any.js
deleted file mode 100644
index b95b856..0000000
--- a/background-fetch/interfaces.https.any.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// META: script=/resources/WebIDLParser.js
-// META: script=/resources/idlharness.js
-
-'use strict';
-
-// https://wicg.github.io/background-fetch/
-
-promise_test(async () => {
- const srcs = [
- 'background-fetch',
- 'dedicated-workers',
- 'service-workers',
- 'dom'
- ];
- const [idls, worker, serviceWorker, dom] = await Promise.all(
- srcs.map(i => fetch(`/interfaces/${i}.idl`).then(r => r.text())));
-
- var idlArray = new IdlArray();
- idlArray.add_idls(idls);
- idlArray.add_dependency_idls(serviceWorker);
- idlArray.add_dependency_idls(worker);
- idlArray.add_dependency_idls(dom);
- idlArray.test();
-}, 'background-fetch interfaces');
diff --git a/interfaces/background-fetch.idl b/interfaces/background-fetch.idl
index 68509fc..fc3ed8d 100644
--- a/interfaces/background-fetch.idl
+++ b/interfaces/background-fetch.idl
@@ -18,7 +18,7 @@
interface BackgroundFetchManager {
Promise<BackgroundFetchRegistration> fetch(DOMString id, (RequestInfo or sequence<RequestInfo>) requests, optional BackgroundFetchOptions options);
Promise<BackgroundFetchRegistration?> get(DOMString id);
- Promise<FrozenArray<DOMString>> getIds();
+ Promise<sequence<DOMString>> getIds();
// TODO: in future this should become an async iterator for BackgroundFetchRegistration objects
};
@@ -51,14 +51,10 @@
};
[Exposed=(Window,Worker)]
-interface BackgroundFetchFetch {
- readonly attribute Request request;
-};
-
-[Exposed=(Window,Worker)]
interface BackgroundFetchActiveFetches {
- Promise<BackgroundFetchActiveFetch> match(RequestInfo request);
- Promise<FrozenArray<BackgroundFetchActiveFetch>> values();
+ Promise<BackgroundFetchActiveFetch> match(RequestInfo request, optional CacheQueryOptions options);
+ Promise<sequence<BackgroundFetchActiveFetch>> matchAll(RequestInfo request, optional CacheQueryOptions options);
+ Promise<sequence<BackgroundFetchActiveFetch>> values();
};
[Exposed=(Window,Worker)]
@@ -67,6 +63,11 @@
// In future this will include a fetch observer
};
+[Exposed=(Window,Worker)]
+interface BackgroundFetchFetch {
+ readonly attribute Request request;
+};
+
[Constructor(DOMString type, BackgroundFetchEventInit init), Exposed=ServiceWorker]
interface BackgroundFetchEvent : ExtendableEvent {
readonly attribute DOMString id;
@@ -87,8 +88,9 @@
[Exposed=ServiceWorker]
interface BackgroundFetchSettledFetches {
- Promise<BackgroundFetchSettledFetch> match(RequestInfo request);
- Promise<FrozenArray<BackgroundFetchSettledFetch>> values();
+ Promise<BackgroundFetchSettledFetch> match(RequestInfo request, optional CacheQueryOptions options);
+ Promise<sequence<BackgroundFetchSettledFetch>> matchAll(RequestInfo request, optional CacheQueryOptions options);
+ Promise<sequence<BackgroundFetchSettledFetch>> values();
};
[Exposed=ServiceWorker]