<!DOCTYPE html>
<script src="../include.js"></script>
<script>
asyncTest(done => {
setTimeout(() => {
// We need to do this spoofing later in the event loop so that we don't end up
// telling the test runner the wrong URL in page_did_finish_loading.
// FIXME: We need to use an actual https:// domain here in order to
// actually fetch() our js file.
spoofCurrentURL("https://example.com/service-worker-register.html");
let swPromise = navigator.serviceWorker.register("service-worker.js");
swPromise
.then(registration => {
println(`ServiceWorker registration successful with scope: ${registration.scope}`);
done();
})
.catch(err => {
println(`ServiceWorker registration failed: ${err}`);
done();
});
}, 0);
});
</script>