<!DOCTYPE HTML>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('Test module rejects scripts with incorrect mime types.');

// Module will be executed asynchronously.
window.jsTestIsAsync = true;
</script>
<script>
let unscriptyMimeTypes = [
    'application/json',
    'application/octet-stream',
    'application/xml',
    'image/png',
    'text/html',
    'text/plain',
    'text/vbs',
    'text/vbscript',
    'text/xml',
];

debug('Module is not executed yet.');

let current = Promise.resolve();
for (let mimeType of unscriptyMimeTypes) {
    current = current.then(() => {
        return new Promise((resolve, reject) => {
            let script = document.createElement('script');
            script.addEventListener('error', (ev) => resolve(ev), false);
            script.type = 'module'
            script.src = `./contentTypeOptions/resources/script-with-header.pl?mime=${mimeType}`;
            document.body.appendChild(script);
        });
    });
}

current.then(done);

function done()
{
    debug('Module rejects scripts with incorrect mime types.');
    finishJSTest();
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
