gecko-dev/dom/serviceworkers/test/register_https.html
Yaron Tausky 7d9fd70298 Bug 1455078: Implement [SecureContext] for ServiceWorkerContainer r=asuth
The spec mandates that ServiceWorkerContainer only be visible in a secure context,
yet currently it is (almost) always visible, but rejects calls to register() in
non-secure contexts. This commit moves the context check to a [Func] function, thus
implementing the behavior exactly as specified.

This commit uses the same mechanism used by [SecureContext] bindings instead of the
current ad hoc implementation.

Differential Revision: https://phabricator.services.mozilla.com/D2950

--HG--
extra : moz-landing-system : lando
2018-08-22 15:22:40 +00:00

15 lines
385 B
HTML

<!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");
ok(!("serviceWorker" in navigator), "ServiceWorkerContainer not availalble in insecure context");
done();
</script>