4 https://bugzilla.mozilla.org/show_bug.cgi?id=277724
7 <title>Test for Bug
277724</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" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=277724">Mozilla Bug
277724</a>
16 <script class=
"testbody" type=
"text/javascript">
18 /** Test for Bug
277724 **/
20 var childUnloaded = false;
23 [
"select", HTMLSelectElement ],
24 [
"textarea", HTMLTextAreaElement ],
25 [
"text", HTMLInputElement ],
26 [
"password", HTMLInputElement ],
27 [
"checkbox", HTMLInputElement ],
28 [
"radio", HTMLInputElement ],
29 [
"image", HTMLInputElement ],
30 [
"submit", HTMLInputElement ],
31 [
"reset", HTMLInputElement ],
32 [
"button input", HTMLInputElement ],
33 [
"hidden", HTMLInputElement ],
34 [
"file", HTMLInputElement ],
35 [
"submit button", HTMLButtonElement ],
36 [
"reset button", HTMLButtonElement ],
37 [
"button", HTMLButtonElement ]
40 function startTest(frameid) {
41 is(childUnloaded, false,
"Child not unloaded yet");
43 var doc = $(frameid).contentDocument;
44 ok(doc instanceof Document,
"Check for doc",
"doc should be a document");
46 for (var i =
0; i < nodes.length; ++i) {
48 var node = doc.getElementById(id);
49 ok(node instanceof nodes[i][
1],
50 "Check for " + id, id +
" should be a " + nodes[i][
1]);
51 is(node.disabled, false,
"check for " + id +
" state");
53 is(node.disabled, true,
"check for " + id +
" state change");
56 $(frameid).onload = function () { continueTest(frameid) };
58 // Do this off a timeout so it's not treated like a replace load.
59 function loadBlank() {
60 $(frameid).contentWindow.location =
"about:blank";
62 setTimeout(loadBlank,
0);
65 function continueTest(frameid) {
66 is(childUnloaded, true,
"Unload handler should have fired");
67 var doc = $(frameid).contentDocument;
68 ok(doc instanceof Document,
"Check for doc",
"doc should be a document");
70 for (var i =
0; i < nodes.length; ++i) {
72 var node = doc.getElementById(id);
74 "Check for " + id, id +
" should be null");
77 $(frameid).onload = function() { finishTest(frameid) };
79 // Do this off a timeout too. Why, I'm not sure. Something in session
80 // history creates another history state if we don't. :(
82 $(frameid).contentWindow.history.back();
84 setTimeout(goBack,
0);
87 // XXXbz this is a nasty hack to work around the XML content sink not being
88 // incremental, so that the _first_ control we test is ok but others are not.
91 function flipper(a, b, c) {
100 function finishTest(frameid) {
101 var doc = $(frameid).contentDocument;
102 ok(doc instanceof Document,
"Check for doc",
"doc should be a document");
104 for (var i =
0; i < nodes.length; ++i) {
105 var id = nodes[i][
0];
106 var node = doc.getElementById(id);
107 ok(node instanceof nodes[i][
1],
108 "Check for " + id, id +
" should be a " + nodes[i][
1]);
109 testIs(node.disabled, true,
"check for " + id +
" state restore");
112 if (frameid ==
"frame2") {
115 childUnloaded = false;
117 // XXXbz this is a nasty hack to deal with the content sink. See above.
120 $(
"frame2").onload = function () { startTest(
"frame2") };
121 $(
"frame2").src =
"/static/bug277724_iframe2.xhtml";
125 SimpleTest.waitForExplicitFinish();
129 <!-- Don't use display:none, since we don't support framestate restoration
130 without a frame tree -->
131 <div id=
"content" style=
"visibility: hidden">
132 <iframe src=
"/static/bug277724_iframe1.html" id=
"frame1"
133 onload=
"startTest('frame1')"></iframe>
134 <iframe src=
"" id=
"frame2"></iframe>