summaryrefslogtreecommitdiffstats
path: root/docshell/test/chrome/mozFrameType_window.xhtml
blob: e5d0126d224eab78de3f0c8db2f7ef4098d7d207 (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
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
   - http://creativecommons.org/publicdomain/zero/1.0/ -->
<window title="Test mozFrameType attribute"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  onload="runTests();">

  <html:iframe id="normalFrame"/>
  <html:iframe id="typeContentFrame" mozframetype="content"/>

  <script type="application/javascript"><![CDATA[
    function runTests() {
      let opener = window.arguments[0];
      let SimpleTest = opener.SimpleTest;

      function getDocShellType(frame) {
        return frame.contentWindow.docShell.itemType;
      }

      var normalFrame = document.getElementById("normalFrame");
      var typeContentFrame = document.getElementById("typeContentFrame");

      SimpleTest.is(getDocShellType(normalFrame), Ci.nsIDocShellTreeItem.typeChrome,
                    "normal iframe in chrome document is typeChrome");
      SimpleTest.is(getDocShellType(typeContentFrame), Ci.nsIDocShellTreeItem.typeContent,
                    "iframe with mozFrameType='content' in chrome document is typeContent");

      SimpleTest.executeSoon(function () {
        // First focus the parent window and then close this one.
        SimpleTest.waitForFocus(function() {
          let ww = SpecialPowers.Services.ww;
          ww.registerNotification(function windowObs(subject, topic, data) {
            if (topic == "domwindowclosed") {
              ww.unregisterNotification(windowObs);

              // Don't start the next test synchronously!
              SimpleTest.executeSoon(function() {
                SimpleTest.finish();
              });
            }
          });

          window.close();
        }, opener);
      });
    }
  ]]></script>
</window>