<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
</head>
<body>
<script>
promise_test(async (test) => {
    const registration = await navigator.serviceWorker.register("module-dedicatedworker-worker.js", { scope : 'resources' });
    activeWorker = registration.active;
    if (activeWorker)
        return;

    activeWorker = registration.installing;
    await new Promise(resolve => {
        activeWorker.addEventListener('statechange', () => {
            if (activeWorker.state === "activated")
                resolve();
        });
    });
}, "Register service worker");

promise_test(async (test) => {
    worker = new Worker('resources/controlled-module-worker.js', { type: 'module' });
    const event = await new Promise(resolve => worker.onmessage = resolve);
    assert_equals(event.data, "PASS");
}, "Verify dedicated module worker load went well");
</script>
</body>
</html>
