diff --git a/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js b/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js
index d61e68a325f036..836934b7c0673c 100644
--- a/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js
+++ b/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js
@@ -128,3 +128,16 @@ function runEventTest(params, description) {
params.expectedEvents);
}, description);
}
+
+// Call clients.claim() on the service worker
+async function claim(t, worker) {
+ const channel = new MessageChannel();
+ const saw_message = new Promise(function(resolve) {
+ channel.port1.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, 'PASS', 'Worker call to claim() should fulfill.');
+ resolve();
+ });
+ });
+ worker.postMessage({port: channel.port2}, [channel.port2]);
+ await saw_message;
+}
diff --git a/html/browsers/browsing-the-web/back-forward-cache/resources/service-worker.js b/html/browsers/browsing-the-web/back-forward-cache/resources/service-worker.js
new file mode 100644
index 00000000000000..60dceb0a6a6f5f
--- /dev/null
+++ b/html/browsers/browsing-the-web/back-forward-cache/resources/service-worker.js
@@ -0,0 +1,31 @@
+self.addEventListener('message', function(event) {
+ self.clients.claim()
+ .then(function(result) {
+ if (result !== undefined) {
+ event.data.port.postMessage(
+ 'FAIL: claim() should be resolved with undefined');
+ return;
+ }
+ event.data.port.postMessage('PASS');
+ })
+ .catch(function(error) {
+ event.data.port.postMessage('FAIL: exception: ' + error.name);
+ });
+ });
+
+self.addEventListener('fetch', e => {
+ if (e.request.url.match(/\/is-controlled/)) {
+ e.respondWith(new Response('controlled'));
+ }
+ else if (e.request.url.match(/\/get-clients-matchall/)) {
+ const options = { includeUncontrolled: true, type: 'all' };
+ e.respondWith(
+ self.clients.matchAll(options)
+ .then(clients => {
+ const client_urls = [];
+ clients.forEach(client => client_urls.push(client.url));
+ return new Response(JSON.stringify(client_urls));
+ })
+ );
+ }
+ });
diff --git a/html/browsers/browsing-the-web/back-forward-cache/service-worker-clients-claim.https.html b/html/browsers/browsing-the-web/back-forward-cache/service-worker-clients-claim.https.html
new file mode 100644
index 00000000000000..e593b1fc3b87c2
--- /dev/null
+++ b/html/browsers/browsing-the-web/back-forward-cache/service-worker-clients-claim.https.html
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
diff --git a/html/browsers/browsing-the-web/back-forward-cache/service-worker-clients-matchall.https.html b/html/browsers/browsing-the-web/back-forward-cache/service-worker-clients-matchall.https.html
new file mode 100644
index 00000000000000..ac9809246a8f47
--- /dev/null
+++ b/html/browsers/browsing-the-web/back-forward-cache/service-worker-clients-matchall.https.html
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
diff --git a/html/browsers/browsing-the-web/back-forward-cache/service-worker-unregister.https.html b/html/browsers/browsing-the-web/back-forward-cache/service-worker-unregister.https.html
new file mode 100644
index 00000000000000..a704c96c74b9dc
--- /dev/null
+++ b/html/browsers/browsing-the-web/back-forward-cache/service-worker-unregister.https.html
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+