idlharness.https.any.js (1442B)
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 'use strict'; 8 9 // https://w3c.github.io/payment-handler/ 10 11 idl_test( 12 ['payment-handler'], 13 ['service-workers', 'html', 'dom'], 14 async (idl_array, t) => { 15 const isWindow = self.GLOBAL.isWindow(); 16 const isServiceWorker = 'ServiceWorkerGlobalScope' in self; 17 const hasRegistration = isServiceWorker || isWindow; 18 19 if (hasRegistration) { 20 idl_array.add_objects({ 21 ServiceWorkerRegistration: ['registration'], 22 PaymentManager: ['paymentManager'], 23 }); 24 } 25 if (isServiceWorker) { 26 idl_array.add_objects({ 27 ServiceWorkerGlobalScope: ['self'], 28 CanMakePaymentEvent: ['new CanMakePaymentEvent("type")'], 29 PaymentRequestEvent: ['new PaymentRequestEvent("type")'], 30 }) 31 } 32 33 if (isWindow) { 34 const scope = '/service-workers/service-worker/resources/'; 35 const reg = await service_worker_unregister_and_register( 36 t, '/service-workers/service-worker/resources/empty-worker.js', scope); 37 self.registration = reg; 38 await wait_for_state(t, reg.installing, "activated"); 39 add_completion_callback(() => reg.unregister()); 40 } 41 if (hasRegistration) { 42 self.paymentManager = self.registration.paymentManager; 43 } 44 } 45 );