summaryrefslogtreecommitdiffstats
path: root/dom/base/test/chrome/file_bug816340.xhtml
blob: 2ee0ec3365d776f6419e37af5cbfec337676dc7a (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
70
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                 type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=816340
-->
<window title="Mozilla Bug 816340"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  onload="start();">
  <label value="Mozilla Bug 816340"/>
  <!-- test code goes here -->
  <script type="application/javascript"><![CDATA[

    function ok(val, msg) {
      window.arguments[0].ok(val, msg);
    }

    var elems = 
      [
        "input",
        "textarea",
        "select",
        "fieldset",
        "button",
      ];

    var chromeDidGetEvent = false;
    function chromeListener() {
      chromeDidGetEvent = true;
    }

    function testElement(el, disabled, contentShouldGetEvent) {
      chromeDidGetEvent = false;
      var b = document.getElementById("browser");
      b.contentDocument.body.innerHTML = null;
      var e = b.contentDocument.createElement(el);
      if (disabled) {
        e.setAttribute("disabled", "true");
      }
      b.contentDocument.body.appendChild(e);
      var contentDidGetEvent = false;
      b.contentDocument.body.addEventListener("foo",
        function() { contentDidGetEvent = true }, true);

      b.addEventListener("foo", chromeListener, true);
      e.dispatchEvent(new Event("foo"));
      b.removeEventListener("foo", chromeListener, true);
      ok(contentDidGetEvent == contentShouldGetEvent, "content: " + el + (disabled ? " disabled" : ""));
      ok(chromeDidGetEvent, "chrome: " + el + (disabled ? " disabled" : ""));
    }
      
    function start() {
      // Test common element.
      testElement("div", false, true);
      testElement("div", true, true);

      for (var i = 0; i < elems.length; ++i) {
        testElement(elems[i], false, true);
        testElement(elems[i], true, false);
      }
      ok(true, "done");
      window.arguments[0].setTimeout(function() { this.done(); }, 0);
      window.close();
    }

  ]]></script>

  <browser id="browser" type="content" src="about:blank"/>
</window>