summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/unregister-immediately-helpers.js
blob: 91a30de5b777f9d52fed6ef724bd51e6049af3f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';

// Returns a promise for a network response that contains the Clear-Site-Data:
// "storage" header.
function clear_site_data() {
  return fetch('resources/blank.html?pipe=header(Clear-Site-Data,"storage")');
}

async function assert_no_registrations_exist() {
  const registrations = await navigator.serviceWorker.getRegistrations();
  assert_equals(registrations.length, 0);
}

async function add_controlled_iframe(test, url) {
  const frame = await with_iframe(url);
  test.add_cleanup(() => { frame.remove(); });
  assert_not_equals(frame.contentWindow.navigator.serviceWorker.controller, null);
  return frame;
}