diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/tests/mochitest/general/test_outerHTML.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/mochitest/general/test_outerHTML.html')
-rw-r--r-- | dom/tests/mochitest/general/test_outerHTML.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/dom/tests/mochitest/general/test_outerHTML.html b/dom/tests/mochitest/general/test_outerHTML.html new file mode 100644 index 0000000000..b4ebf4e866 --- /dev/null +++ b/dom/tests/mochitest/general/test_outerHTML.html @@ -0,0 +1,74 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=92264 +--> +<head> + <title>Test for Bug 92264</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body onload="runTest();"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=92264">Mozilla Bug 92264</a> +<p id="display"></p> +<div id="content" style="display: none"> +<div id="wrap"><dl></dl><p id="thep">foo<span>bar</span></p><ol></ol></div> +<table id="thetable"><tbody><tr><td>1</td></tr><tr id="thetr"><td>2</td></tr><tr><td>3</td></tr></tbody></table> +<iframe></iframe> +<div id="fragmentwrap"></div> +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 92264 **/ + +SimpleTest.waitForExplicitFinish(); + +function runTest() { + + var thep = document.getElementById("thep"); + var wrap = document.getElementById("wrap"); + is(thep.outerHTML, '<p id="thep">foo<span>bar</span></p>', "Unexpected thep outerHTML"); + thep.outerHTML = "<ul></ul><tr></tr><p></p>"; + is(wrap.innerHTML, "<dl></dl><ul></ul><p></p><ol></ol>", "Bad outerHTML parsing inside wrap"); + + var thetr = document.getElementById("thetr"); + thetr.outerHTML = "<tr><td>a</td></tr><div></div><tr><td>b</td></tr>"; + var thetable = document.getElementById("thetable"); + 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"); + + var iframe = document.getElementsByTagName("iframe")[0]; + var oldbody = iframe.contentDocument.body; + iframe.contentDocument.body.outerHTML = "<body></body>"; + isnot(oldbody, iframe.contentDocument.body, "Failed to replace body"); + is(iframe.contentDocument.getElementsByTagName("body").length, 1, "Should have gotten one body"); + // Yes, two heads per spec. Also Ragnarök and Chrome produce two heads. + is(iframe.contentDocument.getElementsByTagName("head").length, 2, "Should have gotten two heads"); + + try { + document.documentElement.outerHTML = "<html></html>"; + ok(false, "Should have thrown an exception"); + } catch(e) { + is(e.name, "NoModificationAllowedError", "outerHTML should throw NoModificationAllowedError"); + is(e.code, 7, "outerHTML should throw NO_MODIFICATION_ALLOWED_ERR"); + } + + var f = document.createDocumentFragment(); + var dl = document.createElement("dl"); + var p = document.createElement("p"); + var ol = document.createElement("ol"); + f.appendChild(dl); + f.appendChild(p); + f.appendChild(ol); + p.outerHTML = "<ul></ul><tr></tr><body></body><p></p>"; + var fragmentwrap = document.getElementById("fragmentwrap"); + fragmentwrap.appendChild(f); + is(fragmentwrap.innerHTML, "<dl></dl><ul></ul><p></p><ol></ol>", "Bad outerHTML parsing in fragment"); + + SimpleTest.finish(); +} + +</script> +</pre> +</body> +</html> |