summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/test_navigator.html
blob: aaac04e92603bcf12c74173d4ddfd58068395014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
  <title>Bug 930348 - test stub Navigator ServiceWorker utilities.</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<script class="testbody" type="text/javascript">

  function checkEnabled() {
    ok(navigator.serviceWorker, "navigator.serviceWorker should exist when ServiceWorkers are enabled.");
    ok(typeof navigator.serviceWorker.register === "function", "navigator.serviceWorker.register() should be a function.");
    ok(typeof navigator.serviceWorker.getRegistration === "function", "navigator.serviceWorker.getAll() should be a function.");
    ok(typeof navigator.serviceWorker.getRegistrations === "function", "navigator.serviceWorker.getAll() should be a function.");
    ok(navigator.serviceWorker.ready instanceof Promise, "navigator.serviceWorker.ready should be a Promise.");
    ok(navigator.serviceWorker.controller === null, "There should be no controller worker for an uncontrolled document.");
  }

  SimpleTest.waitForExplicitFinish();

  SpecialPowers.pushPrefEnv({"set": [
    ["dom.serviceWorkers.exemptFromPerDomainMax", true],
    ["dom.serviceWorkers.enabled", true],
    ["dom.serviceWorkers.testing.enabled", true]
  ]}, function() {
    checkEnabled();
    SimpleTest.finish();
  });
</script>
</pre>
</body>
</html>