idlharness.https.any.js (1471B)
1 // META: global=window,worker 2 // META: script=/resources/WebIDLParser.js 3 // META: script=/resources/idlharness.js 4 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js 5 // META: timeout=long 6 7 // https://w3c.github.io/push-api/ 8 9 idl_test( 10 ['push-api'], 11 ['service-workers', 'hr-time', 'html', 'dom', 'permissions'], 12 async (idl_array, t) => { 13 const isServiceWorker = 'ServiceWorkerGlobalScope' in self 14 && self instanceof ServiceWorkerGlobalScope; 15 if (isServiceWorker) { 16 idl_array.add_objects({ 17 ServiceWorkerGlobalScope: ['self'], 18 PushEvent: ['new PushEvent("type")'], 19 PushSubscriptionChangeEvent: [ 20 'new PushSubscriptionChangeEvent("pushsubscriptionchange")' 21 ], 22 }) 23 } 24 if (GLOBAL.isWindow() || isServiceWorker) { 25 idl_array.add_objects({ 26 // self.registration set for window below, and registration is already 27 // part of ServiceWorkerGlobalScope. 28 ServiceWorkerRegistration: ['registration'], 29 PushManager: ['registration.pushManager'], 30 }); 31 } 32 33 if (GLOBAL.isWindow()) { 34 const scope = '/service-workers/service-worker/resources/'; 35 const worker = `${scope}empty-worker.js`; 36 return service_worker_unregister_and_register(t, worker, scope) 37 .then(registration => { 38 self.registration = registration; 39 t.add_cleanup(function () { registration.unregister(); }); 40 }); 41 } 42 } 43 );