summaryrefslogtreecommitdiffstats
path: root/dom/html/test/bug196523-subframe.html
blob: ac53572a7a37382e94cc05b332df4173f38538d7 (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
<!DOCTYPE html>
<script>
  function checkDomain(str, msg) {
    window.parent.postMessage((str == document.domain) + ";" +msg,
                              "http://mochi.test:8888");
  }

  function reportException(msg) {
    window.parent.postMessage(false + ";" + msg, "http://mochi.test:8888");
  }

  var win1;
  try {
    win1 = window.open("", "", "width=100,height=100");
    var otherDomain1 = win1.document.domain;
    win1.close();
    checkDomain(otherDomain1, "Opened document should have our domain");
  } catch(e) {
    reportException("Exception getting document.domain: " + e);
  } finally {
    win1.close();
  }

  document.domain = "example.org";

  var win2;
  try {
    win2 = window.open("", "", "width=100,height=100");
    var otherDomain2 = win2.document.domain;
    checkDomain(otherDomain2, "Opened document should have our domain");
    win2.close();
  } catch(e) {
    reportException("Exception getting document.domain after domain set: " + e);
  } finally {
    win2.close();
  }
</script>