gecko/toolkit/components/url-classifier/tests/mochitest/workerFrame.html

44 lines
1.1 KiB
HTML

<html> <head>
<title></title>
</head>
<script type="text/javascript">
function startCleanWorker() {
var worker = new Worker("cleanWorker.js");
worker.onmessage = function(event) {
if (event.data == "success") {
window.parent.postMessage("success:blocked importScripts('evilWorker.js')", "*");
} else {
window.parent.postMessage("failure:failed to block importScripts('evilWorker.js')", "*");
}
window.parent.postMessage("finish", "*");
};
worker.onerror = function(event) {
window.parent.postmessage("failure:failed to load cleanWorker.js", "*");
window.parent.postMessage("finish", "*");
};
worker.postMessage("");
}
function startEvilWorker() {
var worker = new Worker("evilWorker.js");
worker.onmessage = function(event) {
window.parent.postMessage("failure:failed to block evilWorker.js", "*");
startCleanWorker();
};
worker.onerror = function(event) {
window.parent.postMessage("success:blocked evilWorker.js", "*");
startCleanWorker();
};
worker.postMessage("");
}
</script>
<body onload="startEvilWorker()">
</body> </html>