From d36576e709cc59cd8f7514fe0fd20ec3c00e2496 Mon Sep 17 00:00:00 2001 From: Luke Bjerring Date: Mon, 9 Apr 2018 21:37:01 +0000 Subject: [PATCH] Bug 1452643 [wpt PR 9886] - Updated ServiceWorker IDL file, a=testonly Automatic update from web-platform-testsUpdated ServiceWorker IDL file (#9886) * Updated ServiceWorker IDL file wpt-commits: 51b2242a8a064a83f1a993036a3f29848b933991 wpt-pr: 9886 wpt-commits: 51b2242a8a064a83f1a993036a3f29848b933991 wpt-pr: 9886 --- testing/web-platform/meta/MANIFEST.json | 15 +- .../tests/interfaces/ServiceWorker.idl | 220 ++++++++++++++++++ .../interfaces-window.https.html | 56 +++-- .../resources/interfaces-idls.js | 121 ---------- .../resources/interfaces-worker.sub.js | 40 ++-- 5 files changed, 294 insertions(+), 158 deletions(-) create mode 100644 testing/web-platform/tests/interfaces/ServiceWorker.idl diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 3a44b32a7367..5a7be80110cc 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -286095,6 +286095,11 @@ {} ] ], + "interfaces/ServiceWorker.idl": [ + [ + {} + ] + ], "interfaces/WebCryptoAPI.idl": [ [ {} @@ -574108,6 +574113,10 @@ "389275a34cb76282af66797b3cd06b72a3b9ddbe", "support" ], + "interfaces/ServiceWorker.idl": [ + "7884feabcb4c9d0a447cccfa2359e3c45eef5455", + "support" + ], "interfaces/WebCryptoAPI.idl": [ "1fa169a6badb1c21608f1e1a68075939e913603f", "support" @@ -594753,7 +594762,7 @@ "testharness" ], "service-workers/service-worker/interfaces-window.https.html": [ - "c596bb509623d00646cd8c1420394f7de8ff742d", + "5c604b248656dae755f0b4107c6ab4f19f3e5c08", "testharness" ], "service-workers/service-worker/invalid-blobtype.https.html": [ @@ -595585,11 +595594,11 @@ "support" ], "service-workers/service-worker/resources/interfaces-idls.js": [ - "c14274bca020d4dfe3df95e0fd36eedae403f99d", + "2d3ae3bdd1be17a2871aa3af2009daaacf43d3db", "support" ], "service-workers/service-worker/resources/interfaces-worker.sub.js": [ - "229dd043c0e98e9f70f54277bba7c4c3db6d000d", + "1e30c1df9970486b5dea379f2430a871d5f270ed", "support" ], "service-workers/service-worker/resources/invalid-blobtype-iframe.https.html": [ diff --git a/testing/web-platform/tests/interfaces/ServiceWorker.idl b/testing/web-platform/tests/interfaces/ServiceWorker.idl new file mode 100644 index 000000000000..e9899cc04129 --- /dev/null +++ b/testing/web-platform/tests/interfaces/ServiceWorker.idl @@ -0,0 +1,220 @@ +// GENERATED CONTENT - DO NOT EDIT +// Content of this file was automatically extracted from the Service Workers spec. +// See https://w3c.github.io/ServiceWorker/ + +[SecureContext, Exposed=(Window,Worker)] +interface ServiceWorker : EventTarget { + readonly attribute USVString scriptURL; + readonly attribute ServiceWorkerState state; + void postMessage(any message, optional sequence transfer = []); + + // event + attribute EventHandler onstatechange; +}; +ServiceWorker includes AbstractWorker; + +enum ServiceWorkerState { + "installing", + "installed", + "activating", + "activated", + "redundant" +}; + +[SecureContext, Exposed=(Window,Worker)] +interface ServiceWorkerRegistration : EventTarget { + readonly attribute ServiceWorker? installing; + readonly attribute ServiceWorker? waiting; + readonly attribute ServiceWorker? active; + [SameObject] readonly attribute NavigationPreloadManager navigationPreload; + + readonly attribute USVString scope; + readonly attribute ServiceWorkerUpdateViaCache updateViaCache; + + [NewObject] Promise update(); + [NewObject] Promise unregister(); + + // event + attribute EventHandler onupdatefound; +}; + +enum ServiceWorkerUpdateViaCache { + "imports", + "all", + "none" +}; + +partial interface Navigator { + [SecureContext, SameObject] readonly attribute ServiceWorkerContainer serviceWorker; +}; + +partial interface WorkerNavigator { + [SecureContext, SameObject] readonly attribute ServiceWorkerContainer serviceWorker; +}; + +[SecureContext, Exposed=(Window,Worker)] +interface ServiceWorkerContainer : EventTarget { + readonly attribute ServiceWorker? controller; + readonly attribute Promise ready; + + [NewObject] Promise register(USVString scriptURL, optional RegistrationOptions options); + + [NewObject] Promise getRegistration(optional USVString clientURL = ""); + [NewObject] Promise> getRegistrations(); + + void startMessages(); + + // events + attribute EventHandler oncontrollerchange; + attribute EventHandler onmessage; // event.source of message events is ServiceWorker object + attribute EventHandler onmessageerror; +}; + +dictionary RegistrationOptions { + USVString scope; + WorkerType type = "classic"; + ServiceWorkerUpdateViaCache updateViaCache = "imports"; +}; + +[SecureContext, Exposed=(Window,Worker)] +interface NavigationPreloadManager { + Promise enable(); + Promise disable(); + Promise setHeaderValue(ByteString value); + Promise getState(); +}; + +dictionary NavigationPreloadState { + boolean enabled = false; + ByteString headerValue; +}; + +[Global=(Worker,ServiceWorker), Exposed=ServiceWorker] +interface ServiceWorkerGlobalScope : WorkerGlobalScope { + [SameObject] readonly attribute Clients clients; + [SameObject] readonly attribute ServiceWorkerRegistration registration; + + [NewObject] Promise skipWaiting(); + + attribute EventHandler oninstall; + attribute EventHandler onactivate; + attribute EventHandler onfetch; + + // event + attribute EventHandler onmessage; // event.source of the message events is Client object + attribute EventHandler onmessageerror; +}; + +[Exposed=ServiceWorker] +interface Client { + readonly attribute USVString url; + readonly attribute DOMString id; + readonly attribute ClientType type; + void postMessage(any message, optional sequence transfer = []); +}; + +[Exposed=ServiceWorker] +interface WindowClient : Client { + readonly attribute VisibilityState visibilityState; + readonly attribute boolean focused; + [SameObject] readonly attribute FrozenArray ancestorOrigins; + [NewObject] Promise focus(); + [NewObject] Promise navigate(USVString url); +}; + +[Exposed=ServiceWorker] +interface Clients { + // The objects returned will be new instances every time + [NewObject] Promise get(DOMString id); + [NewObject] Promise> matchAll(optional ClientQueryOptions options); + [NewObject] Promise openWindow(USVString url); + [NewObject] Promise claim(); +}; + +dictionary ClientQueryOptions { + boolean includeUncontrolled = false; + ClientType type = "window"; +}; + +enum ClientType { + "window", + "worker", + "sharedworker", + "all" +}; + +[Constructor(DOMString type, optional ExtendableEventInit eventInitDict), Exposed=ServiceWorker] +interface ExtendableEvent : Event { + void waitUntil(Promise f); +}; + +dictionary ExtendableEventInit : EventInit { + // Defined for the forward compatibility across the derived events +}; + +[Constructor(DOMString type, FetchEventInit eventInitDict), Exposed=ServiceWorker] +interface FetchEvent : ExtendableEvent { + [SameObject] readonly attribute Request request; + readonly attribute Promise preloadResponse; + readonly attribute DOMString clientId; + readonly attribute DOMString resultingClientId; + readonly attribute DOMString targetClientId; + + void respondWith(Promise r); +}; + +dictionary FetchEventInit : ExtendableEventInit { + required Request request; + required Promise preloadResponse; + DOMString clientId = ""; + DOMString resultingClientId = ""; + DOMString targetClientId = ""; +}; + +[Constructor(DOMString type, optional ExtendableMessageEventInit eventInitDict), Exposed=ServiceWorker] +interface ExtendableMessageEvent : ExtendableEvent { + readonly attribute any data; + readonly attribute USVString origin; + readonly attribute DOMString lastEventId; + [SameObject] readonly attribute (Client or ServiceWorker or MessagePort)? source; + readonly attribute FrozenArray ports; +}; + +dictionary ExtendableMessageEventInit : ExtendableEventInit { + any data = null; + USVString origin = ""; + DOMString lastEventId = ""; + (Client or ServiceWorker or MessagePort)? source = null; + sequence ports = []; +}; + +partial interface WindowOrWorkerGlobalScope { + [SecureContext, SameObject] readonly attribute CacheStorage caches; +}; + +[SecureContext, Exposed=(Window,Worker)] +interface Cache { + [NewObject] Promise match(RequestInfo request, optional CacheQueryOptions options); + [NewObject] Promise> matchAll(optional RequestInfo request, optional CacheQueryOptions options); + [NewObject] Promise add(RequestInfo request); + [NewObject] Promise addAll(sequence requests); + [NewObject] Promise put(RequestInfo request, Response response); + [NewObject] Promise delete(RequestInfo request, optional CacheQueryOptions options); + [NewObject] Promise> keys(optional RequestInfo request, optional CacheQueryOptions options); +}; + +dictionary CacheQueryOptions { + boolean ignoreSearch = false; + boolean ignoreMethod = false; + boolean ignoreVary = false; + DOMString cacheName; +}; + +[SecureContext, Exposed=(Window,Worker)] +interface CacheStorage { + [NewObject] Promise match(RequestInfo request, optional CacheQueryOptions options); + [NewObject] Promise has(DOMString cacheName); + [NewObject] Promise open(DOMString cacheName); + [NewObject] Promise delete(DOMString cacheName); + [NewObject] Promise> keys(); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/interfaces-window.https.html b/testing/web-platform/tests/service-workers/service-worker/interfaces-window.https.html index 7097df061606..307472444d63 100644 --- a/testing/web-platform/tests/service-workers/service-worker/interfaces-window.https.html +++ b/testing/web-platform/tests/service-workers/service-worker/interfaces-window.https.html @@ -9,29 +9,43 @@ diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-idls.js b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-idls.js index 9f5c5ed9675a..3db45c643462 100644 --- a/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-idls.js +++ b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-idls.js @@ -12,124 +12,3 @@ interface AbstractWorker { attribute EventHandler onerror; }; `; -idls.tested = ` -[Global=(Worker,ServiceWorker), Exposed=ServiceWorker] -interface ServiceWorkerGlobalScope : WorkerGlobalScope { - [SameObject] readonly attribute Clients clients; - [SameObject] readonly attribute ServiceWorkerRegistration registration; - - [NewObject] Promise skipWaiting(); - - attribute EventHandler oninstall; - attribute EventHandler onactivate; - attribute EventHandler onfetch; - - // event - attribute EventHandler onmessage; // event.source of the message events is Client object - attribute EventHandler onmessageerror; -}; - -[Exposed=ServiceWorker] -interface Client { - readonly attribute USVString url; - readonly attribute DOMString id; - readonly attribute ClientType type; - readonly attribute boolean reserved; - void postMessage(any message, optional sequence transfer = []); -}; - -[Exposed=ServiceWorker] -interface WindowClient : Client { - readonly attribute VisibilityState visibilityState; - readonly attribute boolean focused; - [SameObject] readonly attribute FrozenArray ancestorOrigins; - [NewObject] Promise focus(); - [NewObject] Promise navigate(USVString url); -}; - -[Exposed=ServiceWorker] -interface Clients { - // The objects returned will be new instances every time - [NewObject] Promise get(DOMString id); - [NewObject] Promise> matchAll(optional ClientQueryOptions options); - [NewObject] Promise openWindow(USVString url); - [NewObject] Promise claim(); -}; - -[SecureContext, Exposed=(Window,Worker)] -interface ServiceWorker : EventTarget { - readonly attribute USVString scriptURL; - readonly attribute ServiceWorkerState state; - void postMessage(any message, optional sequence transfer = []); - - // event - attribute EventHandler onstatechange; -}; -ServiceWorker implements AbstractWorker; - -enum ServiceWorkerState { - "installing", - "installed", - "activating", - "activated", - "redundant" -}; - -enum ServiceWorkerUpdateViaCache { - "imports", - "all", - "none" -}; - -[SecureContext, Exposed=(Window,Worker)] -interface ServiceWorkerRegistration : EventTarget { - readonly attribute ServiceWorker? installing; - readonly attribute ServiceWorker? waiting; - readonly attribute ServiceWorker? active; - [SameObject] readonly attribute NavigationPreloadManager navigationPreload; - - readonly attribute USVString scope; - readonly attribute ServiceWorkerUpdateViaCache updateViaCache; - - [NewObject] Promise update(); - [NewObject] Promise unregister(); - - // event - attribute EventHandler onupdatefound; -}; - -[Constructor(), Exposed=(Window,Worker)] -interface EventTarget { - void addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options); - void removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options); - boolean dispatchEvent(Event event); -}; - -[SecureContext, Exposed=(Window,Worker)] -interface NavigationPreloadManager { - Promise enable(); - Promise disable(); - Promise setHeaderValue(ByteString value); - Promise getState(); -}; - -[SecureContext, Exposed=(Window,Worker)] -interface Cache { - [NewObject] Promise match(RequestInfo request, optional CacheQueryOptions options); - [NewObject] Promise> matchAll(optional RequestInfo request, optional CacheQueryOptions options); - [NewObject] Promise add(RequestInfo request); - [NewObject] Promise addAll(sequence requests); - [NewObject] Promise put(RequestInfo request, Response response); - [NewObject] Promise delete(RequestInfo request, optional CacheQueryOptions options); - [NewObject] Promise> keys(optional RequestInfo request, optional CacheQueryOptions options); -}; - -[SecureContext, Exposed=(Window,Worker)] -interface CacheStorage { - [NewObject] Promise match(RequestInfo request, optional CacheQueryOptions options); - [NewObject] Promise has(DOMString cacheName); - [NewObject] Promise open(DOMString cacheName); - [NewObject] Promise delete(DOMString cacheName); - [NewObject] Promise> keys(); -}; -`; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js index 7bdf10162155..e8147f73fca6 100644 --- a/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js +++ b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js @@ -5,10 +5,26 @@ importScripts('worker-testharness.js'); importScripts('/resources/WebIDLParser.js'); importScripts('/resources/idlharness.js'); -var idlArray = new IdlArray(); -idlArray.add_untested_idls(idls.untested); -idlArray.add_idls(idls.tested); -idlArray.add_objects({ +promise_test(async (t) => { + var idlArray = new IdlArray(); + let serviceWorkerIdl = await fetch('/interfaces/ServiceWorker.idl').then(r => r.text()); + + idlArray.add_untested_idls(idls.untested); + idlArray.add_idls(serviceWorkerIdl, { only: [ + 'ServiceWorkerGlobalScope', + 'Client', + 'WindowClient', + 'Clients', + 'ServiceWorker', + 'ServiceWorkerState', + 'ServiceWorkerUpdateViaCache', + 'ServiceWorkerRegistration', + 'EventTarget', + 'NavigationPreloadManager', + 'Cache', + 'CacheStorage', + ]}); + idlArray.add_objects({ ServiceWorkerGlobalScope: ['self'], Clients: ['self.clients'], ServiceWorkerRegistration: ['self.registration'], @@ -17,16 +33,14 @@ idlArray.add_objects({ // Client: ['self.clientInstance'], // WindowClient: ['self.windowClientInstance'] }); + return create_temporary_cache(t) + .then(function(cache) { + self.cacheInstance = cache; -promise_test(function(t) { - return create_temporary_cache(t) - .then(function(cache) { - self.cacheInstance = cache; - - idlArray.add_objects({ Cache: ['self.cacheInstance'] }); - idlArray.test(); - }); - }, 'test setup (cache creation)'); + idlArray.add_objects({ Cache: ['self.cacheInstance'] }); + idlArray.test(); + }); +}, 'test setup (cache creation)'); test(function() { var req = new Request('http://{{host}}/',