How to use registerAndActivateServiceWorker method in wpt

Best JavaScript code snippet using wpt

utils.js

Source:utils.js Github

copy

Full Screen

1'use strict';2// Depends on /service-workers/service-worker/resources/test-helpers.sub.js3async function registerAndActivateServiceWorker(test) {4 const script = 'resources/sw.js';5 const scope = 'resources/scope' + location.pathname;6 let serviceWorkerRegistration =7 await service_worker_unregister_and_register(test, script, scope);8 add_completion_callback(() => {9 serviceWorkerRegistration.unregister();10 });11 await wait_for_state(test, serviceWorkerRegistration.installing, 'activated');12 return serviceWorkerRegistration;13}14function backgroundFetchTest(func, description) {15 promise_test(async t => {16 const serviceWorkerRegistration = await registerAndActivateServiceWorker(t);17 return func(t, serviceWorkerRegistration.backgroundFetch);18 }, description);19}20let _nextBackgroundFetchTag = 0;21function uniqueTag() {22 return 'tag' + _nextBackgroundFetchTag++;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful