Bug 457825 - Support access control headers when downloading fonts. r=jonas,dbaron...
[wine-gecko.git] / testing / mochitest / tests / test_bug277724.html
blobace086776b55a42349cedf9b9a3cde7337b16a7e
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=277724
5 -->
6 <head>
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" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=277724">Mozilla Bug 277724</a>
14 <p id="display"></p>
15 <pre id="test">
16 <script class="testbody" type="text/javascript">
18 /** Test for Bug 277724 **/
20 var childUnloaded = false;
22 var nodes = [
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) {
47 var id = nodes[i][0];
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");
52 node.disabled = true;
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) {
71 var id = nodes[i][0];
72 var node = doc.getElementById(id);
73 ok(node === null,
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. :(
81 function goBack() {
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.
89 var testIs = is;
90 var once = false;
91 function flipper(a, b, c) {
92 if (once) {
93 todo(a == b, c);
94 } else {
95 once = true;
96 is(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") {
113 SimpleTest.finish();
114 } else {
115 childUnloaded = false;
117 // XXXbz this is a nasty hack to deal with the content sink. See above.
118 testIs = flipper;
120 $("frame2").onload = function () { startTest("frame2") };
121 $("frame2").src = "/static/bug277724_iframe2.xhtml";
125 SimpleTest.waitForExplicitFinish();
126 </script>
127 </pre>
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>
135 </div>
136 </body>
137 </html>