<!DOCTYPE html>
<script>
// See ServiceWorkerBrowserTest ImportsBustMemcache.
// Content-Shell data persists so unregister first to clear old data.
// Register, unregister, then reregister. The browsertest examines the
// state of the scriptcache to ensure the script and import are cached.

var scope = 'imports_bust_memcache_scope/';
var script = 'worker_with_one_import.js';

navigator.serviceWorker.unregister(scope)
.then(function(_) {
  console.log('initial unregistration done');
  return navigator.serviceWorker.register(script, {scope: scope});
})
.then(function(_) {
   console.log('initial registration done');
   return navigator.serviceWorker.unregister(scope);
})
.then(function(_) {
  console.log('unregistration done');
  return navigator.serviceWorker.register(script, {scope: scope});
})
.then(function(_) {
  console.log('second registration done');
  document.title = 'OK';  // Titlewatcher looks for this.
})
.catch(function(e) {
  document.title = 'FAILED';
});
</script>

<!DOCTYPE html>
<script>
// See ServiceWorkerBrowserTest ImportsBustMemcache.
// Content-Shell data persists so unregister first to clear old data.
// Register, unregister, then reregister. The browsertest examines the
// state of the scriptcache to ensure the script and import are cached.

var scope = 'imports_bust_memcache_scope/';
var script = 'worker_with_one_import.js';

navigator.serviceWorker.getRegistration(scope)
.then(function(registration) {
  if (registration)
    return registration.unregister();
})
.then(function(_) {
  console.log('initial unregistration done');
  return navigator.serviceWorker.register(script, {scope: scope});
})
.then(function(registration) {
   console.log('initial registration done');
   return registration.unregister();
})
.then(function(_) {
  console.log('unregistration done');
  return navigator.serviceWorker.register(script, {scope: scope});
})
.then(function(_) {
  console.log('second registration done');
  document.title = 'OK';  // Titlewatcher looks for this.
})
.catch(function(e) {
  document.title = 'FAILED';
});
</script>

Migrate browsertest to use ServiceWorkerRegistration.unregister()
Migrate browsertest to use ServiceWorkerRegistration.unregister()

ServiceWorkerContainer.unregister() is going away. This patch
updates ServiceWorkerBrowserTest.ImportsBustMemcache to use
ServiceWorkerRegistration.unregister() function.

BUG=404064

Review URL: https://codereview.chromium.org/579183002

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#295664}
