Bug 449371 Firefox/Thunderbird crashes at exit [@ gdk_display_x11_finalize], p=Brian...
[wine-gecko.git] / testing / mochitest / tests / test_bug337631.html
blobb8e7bc41596a2825e5827f423974630618cf2175
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=337631
5 -->
6 <head>
7 <title>Test for Bug 337631</title>
8 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=337631">Mozilla Bug 337631</a>
14 <p id="display"></p>
15 <div id="content">
17 <a href="foo" id="test4">foo</a>
18 <input id="test1" value="test">
19 <p id="test2">adsf<a href="#" id="test3">asdf</a><input id="test5"></p>
21 </div>
22 <pre id="test">
23 <script class="testbody" type="text/javascript">
25 /** Test for Bug 337631 **/
27 function getActiveElement()
29 var rv;
31 var el = document.activeElement;
32 if (!el) {
33 rv = "none";
34 return rv;
37 if (el && el != document.documentElement) {
38 var nt;
39 try {
40 nt = el.nodeType;
41 } catch (e) {
42 rv = "[no permission]";
43 return rv;
45 if (!nt) {
46 rv = "[unknown]";
47 } else if (nt == 1) {
48 rv = el.tagName;
49 } else if (nt == 3) {
50 rv = "textnode"
51 } else {
52 rv = nt;
55 el = el.parentNode;
56 while (el && el != document.documentElement) {
57 rv += " in ";
58 try {
59 nt = el.nodeType;
60 } catch (e) {
61 rv += "[no permission]";
62 return rv;
64 if (!nt) {
65 rv += "[unknown]";
66 } else if (nt == 1) {
67 rv += el.tagName;
68 } else if (nt == 3) {
69 rv += "textnode"
70 } else {
71 rv += nt;
74 el = el.parentNode;
78 return rv;
81 $('test1').focus();
82 is(getActiveElement(), "INPUT in DIV in BODY", "getActiveElement tests");
84 $('test2').focus();
85 is(getActiveElement(), "INPUT in DIV in BODY", "getActiveElement tests");
87 $('test3').focus();
88 is(getActiveElement(), "A in P in DIV in BODY", "getActiveElement tests");
90 $('test4').focus();
91 is(getActiveElement(), "A in DIV in BODY", "getActiveElement tests");
93 $('test5').focus();
94 is(getActiveElement(), "INPUT in P in DIV in BODY", "getActiveElement tests");
96 </script>
97 </pre>
98 </body>
99 </html>