summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/serviceworkers/register_https.html
blob: d14d8c380873461441fc9a1b9eabec07af48f768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<script>
function ok(condition, message) {
  parent.postMessage({type: "ok", status: condition, msg: message}, "*");
}

function done() {
  parent.postMessage({type: "done"}, "*");
}

ok(location.protocol == "https:", "We should be loaded from HTTPS");

navigator.serviceWorker.register("empty.js", {scope: "register-https"})
  .then(reg => {
    ok(false, "Registration should fail");
    done();
  }).catch(err => {
    ok(err.name === "SecurityError", "Registration should fail with SecurityError");
    done();
  });
</script>