Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /service-workers/service-worker/controller-on-disconnect.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Service Worker: Controller on load</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
promise_test(function(t) {
var url = 'resources/empty-worker.js';
var scope = 'resources/blank.html';
var registration;
var controller;
var frame;
return service_worker_unregister_and_register(t, url, scope)
.then(function(swr) {
t.add_cleanup(function() {
return service_worker_unregister(t, scope);
});
registration = swr;
return wait_for_state(t, registration.installing, 'activated');
})
.then(function() {
return with_iframe(scope)
})
.then(function(f) {
frame = f;
var w = frame.contentWindow;
var swc = w.navigator.serviceWorker;
assert_true(swc.controller instanceof w.ServiceWorker,
'controller should be a ServiceWorker object');
frame.remove();
assert_equals(swc.controller, null,
'disconnected frame should not be controlled');
});
}, 'controller is cleared on disconnected window');
</script>
</body>