|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=92264 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 92264</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body onload="runTest();"> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=92264">Mozilla Bug 92264</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"> |
|
15 <div id="wrap"><dl></dl><p id="thep">foo<span>bar</span></p><ol></ol></div> |
|
16 <table id="thetable"><tbody><tr><td>1</td></tr><tr id="thetr"><td>2</td></tr><tr><td>3</td></tr></tbody></table> |
|
17 <iframe></iframe> |
|
18 <div id="fragmentwrap"></div> |
|
19 </div> |
|
20 <pre id="test"> |
|
21 <script type="application/javascript"> |
|
22 |
|
23 /** Test for Bug 92264 **/ |
|
24 |
|
25 SimpleTest.waitForExplicitFinish(); |
|
26 |
|
27 function runTest() { |
|
28 |
|
29 var thep = document.getElementById("thep"); |
|
30 var wrap = document.getElementById("wrap"); |
|
31 is(thep.outerHTML, '<p id="thep">foo<span>bar</span></p>', "Unexpected thep outerHTML"); |
|
32 thep.outerHTML = "<ul></ul><tr></tr><p></p>"; |
|
33 is(wrap.innerHTML, "<dl></dl><ul></ul><p></p><ol></ol>", "Bad outerHTML parsing inside wrap"); |
|
34 |
|
35 var thetr = document.getElementById("thetr"); |
|
36 thetr.outerHTML = "<tr><td>a</td></tr><div></div><tr><td>b</td></tr>"; |
|
37 var thetable = document.getElementById("thetable"); |
|
38 is(thetable.innerHTML, "<tbody><tr><td>1</td></tr><tr><td>a</td></tr><div></div><tr><td>b</td></tr><tr><td>3</td></tr></tbody>", "Wrong outerHTML parsing inside table"); |
|
39 |
|
40 var iframe = document.getElementsByTagName("iframe")[0]; |
|
41 var oldbody = iframe.contentDocument.body; |
|
42 iframe.contentDocument.body.outerHTML = "<body></body>"; |
|
43 isnot(oldbody, iframe.contentDocument.body, "Failed to replace body"); |
|
44 is(iframe.contentDocument.getElementsByTagName("body").length, 1, "Should have gotten one body"); |
|
45 // Yes, two heads per spec. Also Ragnarök and Chrome produce two heads. |
|
46 is(iframe.contentDocument.getElementsByTagName("head").length, 2, "Should have gotten two heads"); |
|
47 |
|
48 try { |
|
49 document.documentElement.outerHTML = "<html></html>"; |
|
50 ok(false, "Should have thrown an exception"); |
|
51 } catch(e) { |
|
52 is(e.name, "NoModificationAllowedError", "outerHTML should throw NoModificationAllowedError"); |
|
53 is(e.code, 7, "outerHTML should throw NO_MODIFICATION_ALLOWED_ERR"); |
|
54 } |
|
55 |
|
56 var f = document.createDocumentFragment(); |
|
57 var dl = document.createElement("dl"); |
|
58 var p = document.createElement("p"); |
|
59 var ol = document.createElement("ol"); |
|
60 f.appendChild(dl); |
|
61 f.appendChild(p); |
|
62 f.appendChild(ol); |
|
63 p.outerHTML = "<ul></ul><tr></tr><body></body><p></p>"; |
|
64 var fragmentwrap = document.getElementById("fragmentwrap"); |
|
65 fragmentwrap.appendChild(f); |
|
66 is(fragmentwrap.innerHTML, "<dl></dl><ul></ul><p></p><ol></ol>", "Bad outerHTML parsing in fragment"); |
|
67 |
|
68 SimpleTest.finish(); |
|
69 } |
|
70 |
|
71 </script> |
|
72 </pre> |
|
73 </body> |
|
74 </html> |