Source code

Revision control

Other Tools

1
<!DOCTYPE HTML>
2
<html>
3
<head>
4
<meta charset="UTF-8">
5
<title>Service worker controlled</title>
6
</head>
7
<body>
8
<script type="text/javascript">
9
10
"use strict";
11
12
let registration;
13
14
const registerServiceWorker = async function() {
15
try {
16
registration = await navigator.serviceWorker.register("controlled-sw.js");
17
dump("Controlled service worker registered\n");
18
} catch (e) {
19
dump("Controlled service worker not registered: " + e + "\n");
20
}
21
};
22
23
// Helper called from helper-serviceworker.js to unregister the service worker.
24
window.getRegistration = function() {
25
return registration;
26
};
27
28
// Called from browser_aboutdebugging_serviceworker_status.js
29
window.installServiceWorker = function() {
30
registration.installing.postMessage("install-service-worker");
31
};
32
33
// Register the service worker.
34
registerServiceWorker();
35
36
</script>
37
</body>
38
</html>