summaryrefslogtreecommitdiffstats
path: root/dom/xbl/test/test_bug379959.html
blob: 2b31b54c579133563366e91ed20ebd84023dbf3b (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
66
67
68
69
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=379959
-->
<head>
  <title>Test for Bug 379959</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTest();">
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=379959">Mozilla Bug 379959</a>
  <p id="display">
    Note: In order to re-run this test correctly you need to shift-reload
    rather than simply reload. If you just reload we will restore the
    previous url in the iframe which will result in an extra unexpected
    message.
  </p>
  <div id="content" style="display: none"></div>
  <iframe id="dataFrame"></iframe>
  <iframe id="originFrame"></iframe>

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

SimpleTest.waitForExplicitFinish();

var seenData = false;
var seenSameOrigin = false;
var seenCrossOrign = false;

function receiveMessage(e) {
  is(e.origin, "http://mochi.test:8888", "wrong sender!");

  if (e.data.test === "dataIsAllowed") {
    is(e.data.result, 1, "data-url load should have succeeded");
    seenData = true;
  }
  else if (e.data.test === "sameOriginIsAllowed") {
    is(e.data.result, 1, "same site load should have succeeded");
    seenSameOrigin = true;
  }
  else if (e.data.test === "crossOriginIsBlocked") {
    is(e.data.result, 0, "cross site load should have failed");
    seenCrossOrign = true;
  }
  else {
    ok (false, "unrecognized test");
  }

  if (seenData && seenSameOrigin && seenCrossOrign) {
    window.removeEventListener("message", receiveMessage, false);
    SimpleTest.finish();
  }
}

window.addEventListener("message", receiveMessage, false);

function runTest() {
  // make sure data: is allowed
  document.getElementById('dataFrame').src = "file_bug379959_data.html";
  // make sure same-origin is allowed but cross site is blocked
  document.getElementById('originFrame').src = "file_bug379959_cross.html";
}

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