summaryrefslogtreecommitdiffstats
path: root/dom/xhr/tests/test_worker_xhr_parameters.html
blob: ae880aabb263449ca5213571ec96720b6bac1e41 (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
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Test for XMLHttpRequest with system privileges</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display">
</p>
<div id="content" style="display: none">

</div>
<pre id="test">
<script class="testbody" type="application/javascript;version=1.8">

function message(event) {
  if (event.data.test == 'ok')
    ok(event.data.a, event.data.event);
  else if(event.data.test == 'is')
    is(event.data.a, event.data.b, event.data.event);
  else if(event.data.test == 'finish') {
    run();
  }
};

function test1() {
  var worker = new Worker("test_worker_xhr_parameters.js");
  worker.onmessage = message;

  // Run the tests once without API privileges...
  worker.postMessage(false);
}

function test2() {
  // ...and once with privileges.
  SpecialPowers.pushPermissions([{type: "systemXHR", allow: true, context: document}],
    function () {
      var worker = new Worker("test_worker_xhr_parameters.js");
      worker.onmessage = message;
      worker.postMessage(true);
    }
  );
}

var tests = [ test1, test2 ];
function run() {
  if (!tests.length) {
    SimpleTest.finish();
    return;
  }

  var func = tests.shift();
  func();
}

SimpleTest.waitForExplicitFinish();
run();

</script>
</pre>
</body>
</html>