1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/general/test_outerHTML.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=92264 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 92264</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body onload="runTest();"> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=92264">Mozilla Bug 92264</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 +<div id="wrap"><dl></dl><p id="thep">foo<span>bar</span></p><ol></ol></div> 1.19 +<table id="thetable"><tbody><tr><td>1</td></tr><tr id="thetr"><td>2</td></tr><tr><td>3</td></tr></tbody></table> 1.20 +<iframe></iframe> 1.21 +<div id="fragmentwrap"></div> 1.22 +</div> 1.23 +<pre id="test"> 1.24 +<script type="application/javascript"> 1.25 +<![CDATA[ 1.26 + 1.27 +/** Test for Bug 92264 **/ 1.28 + 1.29 +SimpleTest.waitForExplicitFinish(); 1.30 + 1.31 +function runTest() { 1.32 + 1.33 + var thep = document.getElementById("thep"); 1.34 + var wrap = document.getElementById("wrap"); 1.35 + is(thep.outerHTML, '<p xmlns="http://www.w3.org/1999/xhtml" id="thep">foo<span>bar</span></p>', "Unexpected thep outerHTML"); 1.36 + thep.outerHTML = "<ul></ul><tr></tr><p></p>"; 1.37 + is(wrap.innerHTML, '<dl xmlns="http://www.w3.org/1999/xhtml"></dl><ul xmlns="http://www.w3.org/1999/xhtml"></ul><tr xmlns="http://www.w3.org/1999/xhtml"></tr><p xmlns="http://www.w3.org/1999/xhtml"></p><ol xmlns="http://www.w3.org/1999/xhtml"></ol>', "Bad outerHTML parsing inside wrap"); 1.38 + 1.39 + var thetr = document.getElementById("thetr"); 1.40 + thetr.outerHTML = "<tr><td>a</td></tr><div></div><tr><td>b</td></tr>"; 1.41 + var thetable = document.getElementById("thetable"); 1.42 + is(thetable.innerHTML, '<tbody xmlns="http://www.w3.org/1999/xhtml"><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"); 1.43 + 1.44 + var iframe = document.getElementsByTagName("iframe")[0]; 1.45 + var oldbody = iframe.contentDocument.body; 1.46 + iframe.contentDocument.body.outerHTML = "<body></body>"; 1.47 + isnot(oldbody, iframe.contentDocument.body, "Failed to replace body"); 1.48 + is(iframe.contentDocument.getElementsByTagName("body").length, 1, "Should have gotten one body"); 1.49 + // Yes, two heads per spec. Also Ragnarök and Chrome produce two heads. 1.50 + is(iframe.contentDocument.getElementsByTagName("head").length, 2, "Should have gotten two heads"); 1.51 + 1.52 + try { 1.53 + document.documentElement.outerHTML = "<html></html>"; 1.54 + ok(false, "Should have thrown an exception"); 1.55 + } catch(e) { 1.56 + is(e.name, "NoModificationAllowedError", "outerHTML should throw NoModificationAllowedError"); 1.57 + is(e.code, 7, "outerHTML should throw NO_MODIFICATION_ALLOWED_ERR"); 1.58 + } 1.59 + 1.60 + var f = document.createDocumentFragment(); 1.61 + var dl = document.createElement("dl"); 1.62 + var p = document.createElement("p"); 1.63 + var ol = document.createElement("ol"); 1.64 + f.appendChild(dl); 1.65 + f.appendChild(p); 1.66 + f.appendChild(ol); 1.67 + p.outerHTML = "<ul></ul><tr></tr><body></body><p></p>"; 1.68 + var fragmentwrap = document.getElementById("fragmentwrap"); 1.69 + fragmentwrap.appendChild(f); 1.70 + is(fragmentwrap.innerHTML, '<dl xmlns="http://www.w3.org/1999/xhtml"></dl><ul xmlns="http://www.w3.org/1999/xhtml"></ul><tr xmlns="http://www.w3.org/1999/xhtml"></tr><body xmlns="http://www.w3.org/1999/xhtml"></body><p xmlns="http://www.w3.org/1999/xhtml"></p><ol xmlns="http://www.w3.org/1999/xhtml"></ol>', "Bad outerHTML parsing in fragment"); 1.71 + 1.72 + SimpleTest.finish(); 1.73 +} 1.74 +]]> 1.75 +</script> 1.76 +</pre> 1.77 +</body> 1.78 +</html>