blob: 86a7e1f499035cff750ecb6aa8140eecbb333891 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<title>Tests for importScripts: MIME types</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
/**
* Test that a Service Worker's importScript() only accepts valid MIME types.
*/
let serviceWorker = null;
promise_test(async t => {
const scope = 'resources/import-scripts-mime-types';
const registration = await service_worker_unregister_and_register(t,
'resources/import-scripts-mime-types-worker.js', scope);
add_completion_callback(() => { registration.unregister(); });
await wait_for_state(t, registration.installing, 'activated');
// TODO(b/234788479) Implement waiting for update worker state tasks in
// Install algorithm, otherwise the worker is activated too early
if (registration.active) {
serviceWorker = registration.active;
} else if (registration.waiting) {
serviceWorker = registration.waiting;
} else {
serviceWorker = registration.installing;
}
}, 'Global setup');
promise_test(async t => {
await fetch_tests_from_worker(serviceWorker);
}, 'Fetch importScripts tests from service worker')
</script>
</body>