summaryrefslogtreecommitdiff
path: root/toolkit/components/url-classifier/tests/mochitest/workerFrame.html
blob: 69e8dd0074ff8b81c79decf782e5cb8525c0287f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<html>
<head>
<title></title>

<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", "*");
    startUnwantedWorker();
  };

  worker.onerror = function(event) {
    window.parent.postMessage("success:blocked evilWorker.js", "*");
    startUnwantedWorker();
  };

  worker.postMessage("");
}

function startUnwantedWorker() {
  var worker = new Worker("unwantedWorker.js");

  worker.onmessage = function(event) {
    window.parent.postMessage("failure:failed to block unwantedWorker.js", "*");
    startCleanWorker();
  };

  worker.onerror = function(event) {
    window.parent.postMessage("success:blocked unwantedWorker.js", "*");
    startCleanWorker();
  };

  worker.postMessage("");
}

</script>

</head>

<body onload="startEvilWorker()">
</body>
</html>